Skip to content

Conversation

@seratch
Copy link
Member

@seratch seratch commented Dec 11, 2025

This pull request adds a new feature equivalent to openai/openai-agents-js#749

@ihower
Copy link
Contributor

ihower commented Dec 11, 2025

@seratch I came up with an alternative API design and sent PR #2176 for your consideration.

event: StreamEvent
"""The streaming event from the nested agent run."""

agent_name: str
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of agent_name, why not pass the Agent object?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this is true. i will revisit the properties in this object

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed by 7f1672a

Comment on lines +463 to +469
maybe_result = on_stream(payload)
if inspect.isawaitable(maybe_result):
await maybe_result
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be kinda bad since on_stream will block you from going to the next event. fine for now, but we should consider a queue based pattern where we write to a queue from here and the consumer reads from the queue, and we aren't blocking

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call; actually i made these executions async in the TS SDK. so will make this more efficient and consistent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

improved by 94d2239

@seratch seratch force-pushed the agent-as-tool-streaming branch 2 times, most recently from 573e483 to 24088d3 Compare December 15, 2025 07:48
@seratch seratch force-pushed the agent-as-tool-streaming branch from 24088d3 to 94d2239 Compare December 15, 2025 07:54
@seratch
Copy link
Member Author

seratch commented Dec 15, 2025

@codex review this PR again

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 493 to 496
payload: AgentToolStreamEvent = {
"event": event,
"agent": self,
"tool_call": getattr(context, "tool_call", None),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use current agent for tool stream events

When a tool-invoked agent hands off to another agent, run_result.stream_events() will emit AgentUpdatedStreamEvent and subsequent events belong to the new agent, but the payload always sets agent to self (the original tool agent). In runs that include handoffs, this misattributes events and can break on_stream handlers that route or label output by the emitting agent, because they will never see the actual current agent after a handoff. Consider populating agent from the streaming run state (e.g., run_result.current_agent or updates from AgentUpdatedStreamEvent) instead of the initial agent.

Useful? React with 👍 / 👎.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will fix this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed by dbcb6e3

@seratch seratch mentioned this pull request Dec 15, 2025
@seratch
Copy link
Member Author

seratch commented Dec 15, 2025

@codex review again

@seratch seratch mentioned this pull request Dec 15, 2025
@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Hooray!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

4 participants