Skip to content

Commit 918ee6f

Browse files
committed
feat(realtime): include tool arguments in RealtimeToolEnd events, fixes consistency request from PR #2028
1 parent 3cea592 commit 918ee6f

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/agents/realtime/events.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ class RealtimeToolEnd:
9090
tool: Tool
9191
"""The tool that was called."""
9292

93+
arguments: str
94+
"""The arguments passed to the tool as a JSON string."""
95+
9396
output: Any
9497
"""The output of the tool call."""
9598

src/agents/realtime/session.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ async def _handle_tool_call(
437437
tool=func_tool,
438438
output=result,
439439
agent=agent,
440+
arguments=event.arguments,
440441
)
441442
)
442443
elif event.name in handoff_map:

tests/realtime/test_session.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,7 @@ async def test_function_tool_execution_success(
994994
assert tool_end_event.tool == mock_function_tool
995995
assert tool_end_event.output == "function_result"
996996
assert tool_end_event.agent == mock_agent
997+
assert tool_end_event.arguments == '{"param": "value"}'
997998

998999
@pytest.mark.asyncio
9991000
async def test_function_tool_with_multiple_tools_available(self, mock_model, mock_agent):
@@ -1144,6 +1145,11 @@ async def test_tool_call_with_complex_arguments(
11441145
assert isinstance(tool_start_event, RealtimeToolStart)
11451146
assert tool_start_event.arguments == complex_args
11461147

1148+
# Verify tool_end event includes arguments
1149+
tool_end_event = await session._event_queue.get()
1150+
assert isinstance(tool_end_event, RealtimeToolEnd)
1151+
assert tool_end_event.arguments == complex_args
1152+
11471153
@pytest.mark.asyncio
11481154
async def test_tool_call_with_custom_call_id(self, mock_model, mock_agent, mock_function_tool):
11491155
"""Test that tool context receives correct call_id"""

0 commit comments

Comments
 (0)