Skip to content

Feat: separate tool_call_item and tool_call_output_item in stream events #974

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 1 commit into
base: main
Choose a base branch
from

Conversation

gdisk
Copy link

@gdisk gdisk commented Jun 30, 2025

Summary

During my analysis of the streaming API (run_streamed) results, I noticed that tool_call_item and tool_call_output_item events are currently being emitted concurrently upon tool call completion (as evidenced in #831). This implementation conflates what should logically be distinct events. The current PR addresses this by properly separating these event triggers to better reflect the actual workflow.

Test plan

The test file is created in tests named test_stream_events.py.Run the test script below to test.

pytest -s test_stream_events.py

The test result is:

======================================================================== test session starts ======================================================================== 
platform win32 -- Python 3.12.10, pytest-8.3.5, pluggy-1.5.0
rootdir: D:\moon\projects\openai-agents-python
configfile: pyproject.toml
plugins: anyio-4.9.0, inline-snapshot-0.22.3, asyncio-0.26.0, mock-3.14.0
asyncio: mode=Mode.AUTO, asyncio_default_fixture_loop_scope=session, asyncio_default_test_loop_scope=function
collected 1 item                                                                                                                                                      

tests\test_stream_events.py === Run starting ===
Agent updated: Joker
-- Message output:
 a_message
-- Tool was called at 1751271106971851300
-- Tool output: success! at 1751271109987313900
-- Message output:
 done
=== Run complete ===
.

========================================================================= 1 passed in 3.07s =========================================================================

Issue number

#831

Checks

  • I've added new tests (if relevant)
  • I've run make lint and make format
  • I've made sure tests pass

@legeRise
Copy link

hi i was just trying to get an effect of calling a tool with its name displays with a spinner and then after sometime the output
and
noticed both events are emitting at the same time

so is it fixed Now? can i use it

@gdisk
Copy link
Author

gdisk commented Jul 1, 2025

hi i was just trying to get an effect of calling a tool with its name displays with a spinner and then after sometime the output and noticed both events are emitting at the same time

so is it fixed Now? can i use it

Yeah, just check out this PR and run the tests to verify.

@legeRise
Copy link

legeRise commented Jul 1, 2025

hi i was just trying to get an effect of calling a tool with its name displays with a spinner and then after sometime the output and noticed both events are emitting at the same time
so is it fixed Now? can i use it

Yeah, just check out this PR and run the tests to verify.

thank you so much. it works. hope it gets merged soon

@Suneel5
Copy link

Suneel5 commented Jul 3, 2025

Waiting for it to get merged soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants