Skip to content

feat: #864 support streaming nested tool events in Agent.as_tool #1057

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

vrtnis
Copy link
Contributor

@vrtnis vrtnis commented Jul 10, 2025

  • Add stream_inner_events flag to allow sub-agent tool call visibility
  • Use Runner.run_streamed for streaming inner agents
  • Emit nested tool_called/tool_output events in parent stream
  • Add test coverage for inner streaming behavior

Resolves #864

@vrtnis vrtnis force-pushed the enhancement/add-streaming-inner-events branch 2 times, most recently from 5a0ce3a to dcfaf3f Compare July 10, 2025 23:47
@seratch seratch added enhancement New feature or request feature:core labels Jul 11, 2025
@seratch seratch requested a review from rm-openai July 11, 2025 02:06
@seratch seratch changed the title feat: support streaming nested tool events in Agent.as_tool feat: #864 support streaming nested tool events in Agent.as_tool Jul 11, 2025
@vrtnis
Copy link
Contributor Author

vrtnis commented Jul 16, 2025

@rm-openai i’ve resolved the merge conflict in tool_context.py. The branch is now up to date and ready for your feedback.

@chrisptang
Copy link

looking forward to this new feature

Action isn't published yet, so gotta do this
@vrtnis vrtnis force-pushed the enhancement/add-streaming-inner-events branch from 31af63e to 243462e Compare July 22, 2025 21:04
@yxh-y
Copy link

yxh-y commented Jul 24, 2025

  if stream_inner_events:
      from .stream_events import RunItemStreamEvent
  
      sub_run = Runner.run_streamed(
          self,
          input=input,
          context=context.context,
      )
  
      parent_queue = getattr(context, "_event_queue", None)

When I test on my project, in the above codes in agent.py, the parent_queue will be None and the sub_run event will not be streaming, I manually init it as:

  parent_queue = asyncio.Queue()
  context._event_queue = parent_queue

It is right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature:core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Agent.as_tool hides nested tool‑call events — blocks parallel sub‑agents with streaming
5 participants