Skip to content

Conversation

@moonbox3
Copy link
Contributor

@moonbox3 moonbox3 commented Jan 9, 2026

Motivation and Context

The Responses API expects tool calls to start with fc_*. AG-UI is passing tool call IDs that need this prefix. We also need to make sure we're only emitting ToolCallStartEvent once per tool call (when it's a new tool call).

Description

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@moonbox3 moonbox3 added the python label Jan 9, 2026
Copilot AI review requested due to automatic review settings January 9, 2026 06:04
@moonbox3 moonbox3 added the ag-ui label Jan 9, 2026
@moonbox3 moonbox3 self-assigned this Jan 9, 2026
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Jan 9, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/ag-ui/agent_framework_ag_ui
   _events.py2611195%197, 216, 245, 259, 282, 362–363, 392, 403, 426, 482
packages/core/agent_framework/openai
   _responses_client.py51710280%153, 158, 160–161, 172, 190, 198, 201–208, 210, 215, 221, 225, 240, 243–244, 246, 283, 313, 357–358, 380, 385, 419, 437, 440, 476, 530, 609, 614, 618–620, 624–625, 648, 663–664, 668–670, 717, 737–738, 751–752, 768–769, 858–859, 868–869, 900–901, 917, 919, 993–1001, 1024–1030, 1049, 1067–1068, 1077, 1082–1084, 1090–1091, 1104, 1119, 1155–1156, 1158–1160, 1174–1175, 1178, 1180, 1190–1191, 1197, 1212
TOTAL17626288883% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
2614 154 💤 0 ❌ 0 🔥 59.789s ⏱️

Copy link
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

This PR fixes a bug in the AzureAIClient tool call handling for AG-UI integration. The OpenAI Responses API requires tool call IDs to start with the fc_ prefix, and AG-UI was passing IDs without this prefix, causing failures. Additionally, the PR ensures that ToolCallStartEvent is only emitted once per tool call.

Key changes:

  • Added logic to prepend fc_ prefix to tool call IDs when missing
  • Updated event emission logic to prevent duplicate ToolCallStartEvent emissions
  • Improved code formatting across multiple files for better readability

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
python/packages/core/agent_framework/openai/_responses_client.py Added fc_ prefix validation and prepending logic for tool call IDs; improved code formatting across import statements and function calls
python/packages/ag-ui/agent_framework_ag_ui/_events.py Modified ToolCallStartEvent emission logic to only emit once per new tool call, preventing duplicate events
Comments suppressed due to low confidence (1)

python/packages/core/agent_framework/openai/_responses_client.py:635

  • The new logic to add the 'fc_' prefix to function call IDs lacks test coverage. Consider adding a unit test that verifies:
  1. When a FunctionCallContent has a call_id without 'fc_' prefix, it gets added
  2. When a FunctionCallContent has a call_id that already starts with 'fc_', it's not duplicated
  3. When fc_id is provided in additional_properties, it's used correctly
    This is critical functionality for AG-UI integration and should have explicit test coverage.
            case FunctionCallContent():
                # Use fc_id from additional_properties if available, otherwise fallback to call_id
                fc_id = call_id_to_id.get(content.call_id, content.call_id)
                # OpenAI Responses API requires IDs to start with `fc_`
                if not fc_id.startswith("fc_"):
                    fc_id = f"fc_{fc_id}"
                return {
                    "call_id": content.call_id,
                    "id": fc_id,
                    "type": "function_call",
                    "name": content.name,
                    "arguments": content.arguments,
                    "status": None,
                }

Copy link
Member

@eavanvalkenburg eavanvalkenburg left a comment

Choose a reason for hiding this comment

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

all those syntax changes are a bit strange...

@moonbox3
Copy link
Contributor Author

moonbox3 commented Jan 9, 2026

all those syntax changes are a bit strange...

I agree. Something is going on with ruff, even though it says it's using 120 line length.

@moonbox3 moonbox3 enabled auto-merge January 9, 2026 08:24
@moonbox3 moonbox3 added this pull request to the merge queue Jan 9, 2026
Merged via the queue into microsoft:main with commit 6445b6b Jan 9, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python - AGUI - CopilotKit - Errors when using AzureAIClient instead of samples using AzureOpenAIChatClient

4 participants