Skip to content

Python: Improve AG-UI tool call argument protocol conformance#6342

Open
White-Mouse wants to merge 2 commits into
microsoft:mainfrom
White-Mouse:codex/agui-tool-call-args-conformance
Open

Python: Improve AG-UI tool call argument protocol conformance#6342
White-Mouse wants to merge 2 commits into
microsoft:mainfrom
White-Mouse:codex/agui-tool-call-args-conformance

Conversation

@White-Mouse
Copy link
Copy Markdown

Summary

  • make AG-UI TOOL_CALL_ARGS handling check the event toolCallId against the active tool call
  • ignore argument fragments that do not belong to the active tool call instead of attaching them to another call
  • clear active tool-call state only when the matching TOOL_CALL_END arrives
  • add converter and client regression coverage for mismatched argument events

Details

This is a robustness and AG-UI protocol conformance fix. TOOL_CALL_ARGS events carry a tool-call identifier, and the client-side converter should keep streamed argument fragments bound to that identifier while it builds FunctionCallContent.

With this change, malformed or out-of-order argument fragments no longer get attached to the currently active tool call when their toolCallId points at a different call.

Validation

From python/:

  • uv run --group dev pytest -q --disable-warnings packages/ag-ui/tests/ag_ui/test_event_converters.py::TestAGUIEventConverter::test_tool_call_args_must_match_current_tool_call_id packages/ag-ui/tests/ag_ui/test_ag_ui_client.py::TestAGUIChatClient::test_tool_call_args_id_mismatch_does_not_execute_current_client_tool
  • uv run --group dev pytest -q --disable-warnings packages/ag-ui/tests/ag_ui/test_event_converters.py packages/ag-ui/tests/ag_ui/test_ag_ui_client.py
  • uv run --group dev pytest -q --disable-warnings packages/ag-ui/tests/ag_ui
  • uv run --group dev python -m py_compile packages/ag-ui/agent_framework_ag_ui/_event_converters.py packages/ag-ui/tests/ag_ui/test_event_converters.py packages/ag-ui/tests/ag_ui/test_ag_ui_client.py
  • uv run --group dev ruff check packages/ag-ui/agent_framework_ag_ui/_event_converters.py packages/ag-ui/tests/ag_ui/test_event_converters.py packages/ag-ui/tests/ag_ui/test_ag_ui_client.py
  • git diff --check

Copilot AI review requested due to automatic review settings June 4, 2026 15:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds safeguards to prevent TOOL_CALL_ARGS events from being incorrectly associated with the “current” tool call when IDs mismatch, with regression tests covering the expected behavior.

Changes:

  • Ignore TOOL_CALL_ARGS when toolCallId doesn’t match the active tool call ID (and log a warning).
  • Update tool-call end handling to conditionally clear current tool state based on matching IDs.
  • Add tests to ensure mismatched IDs don’t rebind arguments or execute the wrong client tool.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
python/packages/ag-ui/agent_framework_ag_ui/_event_converters.py Adds toolCallId mismatch checks for TOOL_CALL_ARGS and conditional state reset on TOOL_CALL_END.
python/packages/ag-ui/tests/ag_ui/test_event_converters.py Adds regression test ensuring mismatched TOOL_CALL_ARGS don’t attach to the wrong tool call.
python/packages/ag-ui/tests/ag_ui/test_ag_ui_client.py Adds client-level regression test ensuring mismatched args don’t cause execution of the current tool.

Comment thread python/packages/ag-ui/agent_framework_ag_ui/_event_converters.py
Comment thread python/packages/ag-ui/agent_framework_ag_ui/_event_converters.py Outdated
Comment thread python/packages/ag-ui/tests/ag_ui/test_event_converters.py
@moonbox3 moonbox3 added the python label Jun 4, 2026
@github-actions github-actions Bot changed the title Improve AG-UI tool call argument protocol conformance Python: Improve AG-UI tool call argument protocol conformance Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants