Commit 1f75464
authored
Feat: separate tool_call_item and tool_call_output_item in stream events (#974)
### 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](#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.
```bash
pytest -s test_stream_events.py
```
The test result is:
```text
======================================================================== 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](#831)
### Checks
- [x] I've added new tests (if relevant)
- [x] I've run `make lint` and `make format`
- [x] I've made sure tests pass1 parent fb68e77 commit 1f75464
File tree
4 files changed
+1943
-1835
lines changed- src/agents
- tests
4 files changed
+1943
-1835
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
914 | 914 | | |
915 | 915 | | |
916 | 916 | | |
917 | | - | |
| 917 | + | |
918 | 918 | | |
919 | | - | |
| 919 | + | |
920 | 920 | | |
921 | 921 | | |
922 | | - | |
| 922 | + | |
923 | 923 | | |
924 | 924 | | |
925 | 925 | | |
| |||
944 | 944 | | |
945 | 945 | | |
946 | 946 | | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
947 | 955 | | |
948 | 956 | | |
949 | 957 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
904 | 904 | | |
905 | 905 | | |
906 | 906 | | |
907 | | - | |
| 907 | + | |
908 | 908 | | |
909 | | - | |
910 | | - | |
| 909 | + | |
911 | 910 | | |
912 | 911 | | |
913 | 912 | | |
| |||
918 | 917 | | |
919 | 918 | | |
920 | 919 | | |
921 | | - | |
922 | | - | |
923 | | - | |
924 | 920 | | |
925 | 921 | | |
926 | 922 | | |
| |||
1023 | 1019 | | |
1024 | 1020 | | |
1025 | 1021 | | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
1026 | 1073 | | |
1027 | 1074 | | |
1028 | 1075 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
0 commit comments