Repository navigation
Python: Fix AzureAIClient failure when conversation history contains assistant messages - #3076
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical bug in AzureAIClient that caused 400 invalid_payload errors when handling multi-turn conversations with assistant messages in the conversation history. The issue stems from schema divergence between OpenAI's Responses API and Azure AI Projects' "create responses" API.
Key Changes
- Added
_transform_input_for_azure_ai()workaround method to transform input payloads to match Azure's schema requirements - Integrated the transformation into
_prepare_options()to apply it before sending requests to Azure - Added 3 unit tests to verify the transformation logic handles various scenarios correctly
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
python/packages/azure-ai/agent_framework_azure_ai/_client.py |
Added _transform_input_for_azure_ai() method to transform input items by adding required type: "message" field at item level and annotations field to output_text content items; integrated transformation into _prepare_options() method |
python/packages/azure-ai/tests/test_azure_ai_client.py |
Added 3 unit tests covering basic transformation, preservation of existing fields, and handling of non-dict content items |
Mark Wallace (markwallace-microsoft)
approved these changes
Jan 5, 2026
Contributor
Author
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
Eduard van Valkenburg (eavanvalkenburg)
approved these changes
Jan 5, 2026
This was referenced Jan 5, 2026
Laveesh Rohra (larohra)
added a commit
that referenced
this pull request
Jan 9, 2026
Motivation and Context
AzureAIClientfails with400 invalid_payloaderrors when sending requests that include prior assistant messages in the conversation history. This affects any multi-turn conversation scenario, including sequential workflows.The issue is related to a schema divergence between OpenAI's Responses API and Azure AI Projects' "create responses" API:
type: "message"at the input item levelannotationsfield onoutput_textcontent itemsannotationsoninput_textcontent itemsA tracked upstream Azure SDK issue: Azure/azure-sdk-for-python#44493
To unblock: added
_transform_input_for_azure_ai()workaround inAzureAIClientthat transforms input payloads to match Azure's expected schema before sending requests. The workaround is clearly marked with TODO comments linking to both issues for easy removal once Azure SDK aligns with OpenAI.Description
Contribution Checklist