Skip to content

Streaming runner doesn't emit complete arguments for tool call events #1651

@chcaru

Description

@chcaru

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_events.

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.

Image

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_events API.

Additionally, it seems like maintainers didn't expect this to happen based on the comment thread for the change:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingduplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions