Skip to content

Python: Fix AzureAIClient dropping agent instructions (Responses API)#3636

Merged
moonbox3 merged 1 commit intomicrosoft:mainfrom
moonbox3:3622-fix
Feb 3, 2026
Merged

Python: Fix AzureAIClient dropping agent instructions (Responses API)#3636
moonbox3 merged 1 commit intomicrosoft:mainfrom
moonbox3:3622-fix

Conversation

@moonbox3
Copy link
Contributor

@moonbox3 moonbox3 commented Feb 3, 2026

Motivation and Context

The fix in #3563 (commit 184ee9d) addressed instructions being dropped in AzureAIAgentClient (Chat API), but the same bug existed in AzureAIClient (Responses API).

In _get_agent_reference_or_create(), the code was reading instructions from run_options:

for instructions in [messages_instructions, run_options.get("instructions")]

But the base class excludes instructions from run_options, so it should be read from chat_options instead (same pattern used for response_format on lines 351-352).

The fix: changed _client.py to read instructions from chat_options:

for instructions in [messages_instructions, chat_options.get("instructions") if chat_options else None]

  • Updated existing test to pass instructions via chat_options
  • Added new test test_agent_creation_with_instructions_from_chat_options to verify instructions are correctly passed

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 self-assigned this Feb 3, 2026
Copilot AI review requested due to automatic review settings February 3, 2026 06:45
@moonbox3 moonbox3 added python agents Issues related to single agents labels Feb 3, 2026
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Feb 3, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/azure-ai/agent_framework_azure_ai
   _client.py1931194%345, 347, 396, 424–427, 470, 507, 509, 585
TOTAL16250197887% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3752 221 💤 0 ❌ 0 🔥 1m 9s ⏱️

This comment was marked as off-topic.

@moonbox3 moonbox3 added this pull request to the merge queue Feb 3, 2026
Merged via the queue into microsoft:main with commit 8d939f8 Feb 3, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Issues related to single agents python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug] Instructions not passed to Azure AI Foundry agents - wrong variable in commit 184ee9d5

3 participants

Comments