- Notifications
You must be signed in to change notification settings - Fork2.8k
feat: Add streaming tool output support#1964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Draft
pokliu wants to merge1 commit intoopenai:mainChoose a base branch frompokliu:feature/tool-output-streaming
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Draft
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
This comment was marked as off-topic.
This comment was marked as off-topic.
1 similar comment
This comment was marked as off-topic.
This comment was marked as off-topic.
Thanks for sharing this idea. I see this could be useful for some use cases and it's an interesting enhancement idea. That being said, this requires a careful design decision, so we'll look into it later on. |
This PR is stale because it has been open for 10 days with no activity. |
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support forstreaming tool output in the OpenAI Agents SDK. Previously, users could only receive tool results after complete execution. Now, tools can yield incremental output during execution, enabling real-time progress feedback for long-running operations.
Key improvements:
ToolOutputStreamEventfor receiving incremental tool outputAsyncIterator[str])Runner.run_streamed()andRunner.run()modesType system fix:
Fixed the type signature of
FunctionTool.on_invoke_toolfrom:to:
This properly represents that the function always returns an awaitable, which then yields either a regular value or an async iterator.
Test plan
New tests (
tests/test_tool_streaming.py):test_basic_streaming_tool- Verifies basic streaming functionalitytest_streaming_tool_with_arguments- Tests parameter handlingtest_mixed_streaming_and_non_streaming_tools- Validates coexistencetest_streaming_tool_accumulation- Confirms proper output accumulationtest_streaming_tool_in_non_streaming_mode- TestsRunner.run()modetest_streaming_tool_agent_association- Checks event metadataExample (
examples/tools/streaming_tool_example.py):Validation:
Issue number
N/A - New feature enhancement
Checks
make lintandmake format(all passed)Usage Example
Documentation
Updated streaming documentation in 4 languages:
docs/streaming.mddocs/zh/streaming.mddocs/ja/streaming.mddocs/ko/streaming.mdAll include complete examples and key points about streaming tools.