Skip to content

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

@frdeange

Description

@frdeange

Bug Description

The fix in commit 184ee9d5 intended to pass instructions to Azure AI Foundry agents, but it uses the wrong variable name.

Location

File: agent_framework_azure_ai/_client.py
Method: _get_agent_reference_or_create
Line: ~357

The Bug

The current code at line 357:

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

But the method signature at line 293-299 is:

async def _get_agent_reference_or_create(
    self,
    run_options: dict[str, Any],
    messages_instructions: str | None,
    chat_options: Mapping[str, Any] | None = None,  # <-- This is the correct variable
) -> dict[str, str]:

The instructions field is in chat_options, not in run_options. The base class explicitly excludes instructions from run_options (similar to how response_format is handled on line 351-352).

The Fix

Change line 357 from:

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

To:

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

Impact

All agents created via Azure AI Foundry are created WITHOUT their YAML-defined instructions, making them respond with generic behavior instead of following their configured personas/instructions.

Steps to Reproduce

  1. Create a YAML agent definition with kind: Prompt and custom instructions
  2. Run a workflow using AzureAIClient
  3. Observe that the agent in Azure AI Foundry has no instructions (visible in Foundry portal)
  4. The agent responds generically instead of following the instructions

Environment

  • agent-framework version: 1.0.0b260130
  • azure-ai-projects version: 2.0.0b3
  • Python: 3.12

Workaround

Apply this patch manually:

sed -i 's/run_options.get("instructions")/chat_options.get("instructions")/g' \
  /path/to/site-packages/agent_framework_azure_ai/_client.py

Related

This bug was introduced in the same commit that was supposed to fix it: 184ee9d5

The commit correctly identified the issue but used the wrong variable name in the fix.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpythonv1.0Features being tracked for the version 1.0 GA

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions