Skip to content

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

Merged
moonbox3 merged 1 commit into
microsoft:mainfrom
White-Mouse:codex/agui-tool-call-args-conformance
Jul 10, 2026
Merged

Python: Improve AG-UI tool call argument protocol conformance#6342
moonbox3 merged 1 commit into
microsoft:mainfrom
White-Mouse:codex/agui-tool-call-args-conformance

Conversation

@White-Mouse

@White-Mouse White-Mouse commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Motivation & Context

AG-UI TOOL_CALL_ARGS events carry a tool-call identifier. The converter previously attached every argument fragment to the currently active call without checking that identifier. Out-of-order or malformed events could therefore associate arguments with a different tool call.

Description & Review Guide

  • What are the major changes? Normalize the supported tool-call ID field names, ignore argument fragments whose ID does not match the active call, and clear call state only for the matching TOOL_CALL_END.
  • What is the impact of these changes? Valid event streams keep their existing behavior. Mismatched fragments are ignored instead of being rebound to another call.
  • What do you want reviewers to focus on? The matching rules when an event omits its ID, which preserve compatibility with streams that do not repeat the ID on every event.

Validation completed from python/:

  • uv run pytest -q packages/ag-ui/tests/ag_ui/test_event_converters.py packages/ag-ui/tests/ag_ui/test_ag_ui_client.py (45 passed)
  • uv run ruff check ...
  • uv run ruff format --check ...
  • uv run poe pyright -P ag-ui
  • uv run poe test-typing -P ag-ui

Related Issue

Not linked yet.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI review requested due to automatic review settings June 4, 2026 15:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 Usage: [Issues, PRs], Target: 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
@moonbox3

moonbox3 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Please link the PR to an open issue

@White-Mouse
White-Mouse force-pushed the codex/agui-tool-call-args-conformance branch from 15545ac to 96a2522 Compare July 10, 2026 05:48
@moonbox3 moonbox3 added the ag-ui Usage: [Issues, PRs], Target: AG-UI protocol integration label Jul 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/ag-ui/agent_framework_ag_ui
   _event_converters.py110199%169
TOTAL44137526588% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
8842 33 💤 0 ❌ 0 🔥 2m 23s ⏱️

@moonbox3
moonbox3 enabled auto-merge July 10, 2026 06:54
@moonbox3
moonbox3 added this pull request to the merge queue Jul 10, 2026
Merged via the queue into microsoft:main with commit 32a547a Jul 10, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ag-ui Usage: [Issues, PRs], Target: AG-UI protocol integration python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants