From 81bccc4e31d81392ab0785e1d281089caccbf3dc Mon Sep 17 00:00:00 2001 From: Anish Mehta Date: Thu, 24 Sep 2026 23:00:02 +0530 Subject: [PATCH] Python: fix(ag-ui): read tool_call_id on TOOL_CALL_RESULT events --- .../agent_framework_ag_ui/_event_converters.py | 2 +- .../ag-ui/tests/ag_ui/test_event_converters.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/python/packages/ag-ui/agent_framework_ag_ui/_event_converters.py b/python/packages/ag-ui/agent_framework_ag_ui/_event_converters.py index 5a2c732006d..447af1654d9 100644 --- a/python/packages/ag-ui/agent_framework_ag_ui/_event_converters.py +++ b/python/packages/ag-ui/agent_framework_ag_ui/_event_converters.py @@ -197,7 +197,7 @@ def _handle_tool_call_end(self, event: dict[str, Any]) -> ChatResponseUpdate | N def _handle_tool_call_result(self, event: dict[str, Any]) -> ChatResponseUpdate: """Handle TOOL_CALL_RESULT event.""" - tool_call_id = event.get("toolCallId", "") + tool_call_id = self._get_tool_call_id(event) or "" result = event.get("result") if event.get("result") is not None else event.get("content") return ChatResponseUpdate( diff --git a/python/packages/ag-ui/tests/ag_ui/test_event_converters.py b/python/packages/ag-ui/tests/ag_ui/test_event_converters.py index 625c83da95e..53f02c434c8 100644 --- a/python/packages/ag-ui/tests/ag_ui/test_event_converters.py +++ b/python/packages/ag-ui/tests/ag_ui/test_event_converters.py @@ -195,6 +195,20 @@ def test_tool_call_result_event(self) -> None: assert update.contents[0].call_id == "call_123" assert update.contents[0].result == '{"temperature": 22, "condition": "sunny"}' + def test_tool_call_result_event_snake_case_id(self) -> None: + """TOOL_CALL_RESULT accepts tool_call_id like the other tool call events.""" + converter = AGUIEventConverter() + event = { + "type": "TOOL_CALL_RESULT", + "tool_call_id": "call_snake", + "content": "sunny", + } + + update = converter.convert_event(event) + + assert update is not None + assert update.contents[0].call_id == "call_snake" + def test_run_finished_event(self) -> None: """Test conversion of RUN_FINISHED event.""" converter = AGUIEventConverter()