-
Notifications
You must be signed in to change notification settings - Fork 1k
Python: Fix AzureAIClient tool call bug for AG-UI use #3148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this 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:
- When a FunctionCallContent has a call_id without 'fc_' prefix, it gets added
- When a FunctionCallContent has a call_id that already starts with 'fc_', it's not duplicated
- 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,
}
eavanvalkenburg
left a comment
There was a problem hiding this 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...
I agree. Something is going on with ruff, even though it says it's using 120 line length. |
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