Skip to content

[FEATURE] Support for Direct Method Call Streaming #1436

@larrylp2

Description

@larrylp2

Problem Statement

Strands supports direct method calls (https://strandsagents.com/latest/documentation/docs/user-guide/concepts/tools/#direct-method-calls), which enables developers to invoke specific tools directly.

However, direct method calls currently do not support streaming results for developers. This means that there is a disjointed experience for the same Strands agent, where stream_async enables streaming responses to users for E2E Agent calls but are not possible for direct method calls.

Proposed Solution

To address this, the tools/_caller.py can be extended to also have an async version.

The current direct tool call method seems to use a streaming-friendly ToolExecutor call behind the scenes, but handles it synchronously before returning the full tool result.

https://github.com/strands-agents/sdk-python/blob/main/src/strands/tools/_caller.py#L89

Use Case

The use case would be a seamless streaming experience, even if an Agent built with Strands incorporates direct tool calls in certain flows behind the scenes.

A multi-agent app following the Agents as Tools (https://strandsagents.com/latest/documentation/docs/user-guide/concepts/multi-agent/agents-as-tools/) pattern that relies on streamed tool events (https://strandsagents.com/latest/documentation/docs/user-guide/concepts/streaming/#tool-events) can still stream results through direct method calls.

Alternatives Solutions

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions