-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Please read this first
- Have you read the docs? ✅
- Have you searched for related issues? ✅
Describe the bug
Fix: Emit tool_called events immediately in streaming runs regressed presence of arguments
for tool calls in any run_item_stream_event
s.
Previously, arguments
were present on the tool call when event.type == 'run_item_stream_event' and event.item.type == "tool_call_item"
. The above PR emits the tool call immediately during streaming (as the change intended), before arguments
are accumulated from the stream. This alone could be fine, if there were an alternative method to acquire completed tool call arguments on completion, but there isn't.

It is possible to accumulate the tool call args using raw events: event=RawResponsesStreamEvent(data=ResponseFunctionCallArgumentsDeltaEvent(delta
stream, but this is cumbersome and imo breaks the non-raw higher-level run_item_stream_event
s API.
Additionally, it seems like maintainers didn't expect this to happen based on the comment thread for the change:
- Fix: Emit tool_called events immediately in streaming runs #1300 (comment)
- and was left unchecked per Fix: Emit tool_called events immediately in streaming runs #1300 (comment)
Debug information
- Agents SDK version:
v0.2.10
- Python version:
3.10.12
Repro steps
Setup an Agent with a single tool that has args. Using the streaming runner and observe the events noted above and their properties.
Expected behavior
When using the streaming runner, have some way in the high-level run_item_stream_event
API to acquire the complete arguments
payload for a tool call.
Proposed fix, some variant of:
My suggestion would be to have separate events for "tool call start" and "tool call end". tool_called
is now ambiguous, depending on the semantics of what you consider "a tool has been called" to mean: whether it's the initial indication of a tool call or the actual tool call after args are complete, you could think about these different ways.