Skip to content

feat: add streaming to direct tool calls#1955

Open
emaan-c wants to merge 1 commit intostrands-agents:mainfrom
emaan-c:feat/add-streaming-to-tool-calls
Open

feat: add streaming to direct tool calls#1955
emaan-c wants to merge 1 commit intostrands-agents:mainfrom
emaan-c:feat/add-streaming-to-tool-calls

Conversation

@emaan-c
Copy link

@emaan-c emaan-c commented Mar 23, 2026

Description

Direct tool calls (agent.tool.tool_name()) currently block without providing streaming events, while agent-level calls expose rich streaming from the same underlying infrastructure. This creates inconsistent developer experience and prevents building responsive UIs for long-running operations, multi-agent systems, and debugging workflows.

This adds stream() and stream_async() methods to tool calls, enabling real-time observability without recording to message history.

Resolves: #1436

Public API Changes

Tool calls now support three execution modes:

# Synchronous (unchanged - backward compatible)
result = agent.tool.fetch_data(query="users")

# NEW: Sync streaming
for event in agent.tool.fetch_data.stream(query="users"):
    print(f"Progress: {event.get('type')}")

# NEW: Async streaming
async for event in agent.tool.fetch_data.stream_async(query="users"):
    await ui.update_progress(event)

Streaming methods yield the same events as ToolExecutor._stream() without recording to message history. 100% backward compatible.

Use Cases

  • Multi-agent composition: Stream sub-agent execution with full visibility
  • Real-time progress: Display live indicators during long-running operations
  • Debugging: Inspect execution flow without polluting conversation history

Related Issues

#1436

Documentation PR

No documentation PR needed.

Type of Change

New feature

Testing

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Support for Direct Method Call Streaming

1 participant