-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Description
When using AzureAIClient (Azure Foundry v2 with Responses API) with HandoffBuilder workflows, the framework fails with a 400 Invalid Payload error when passing conversation history between agents during handoffs. The error occurs specifically when an agent with text-only assistant
8000
messages hands off to another agent.
Environment
- Framework Version:
agent-framework-python/1.0.0b251223 - Azure AI Projects SDK:
azsdk-python-ai-projects/2.0.0b2 - Python Version: 3.13.11
- Client Type:
AzureAIClient(v2 Responses API) - Region: Sweden Central
- Model: gpt-4.1-mini
- API Version: 2025-11-15-preview
Steps to Reproduce
- Create multiple declarative agents from YAML using
AgentFactory.create_agent_from_yaml() - Initialize each agent with separate
AzureAIClientinstances withagent_nameparameter:
chat_client = AzureAIClient(
endpoint=azure_project_endpoint,
model=azure_model_deployment,
credential=AzureCliCredential(),
agent_name="AgentName", # Bind to specific agent
http_client=httpx.AsyncClient()
)
agent = AgentFactory.create_agent_from_yaml(yaml_content, chat_client=chat_client)- Build a workflow with
HandoffBuilder:
workflow = (
HandoffBuilder(
name="multi_agent_workflow",
participants=[master_agent, diagnostic_agent, correction_agent, healthcheck_agent]
)
.set_coordinator(master_agent)
.add_handoff(master_agent, [diagnostic_agent, healthcheck_agent])
.with_termination_condition(lambda conv: len(conv) >= 15)
.with_interaction_mode("autonomous", autonomous_turn_limit=10)
.build()
.as_agent()
)- Send a user message that triggers a handoff with text content
- First agent responds with text + handoff tool call
- Framework attempts to pass conversation history to second agent
Expected Behavior
The workflow should successfully pass conversation history between agents, with messages properly formatted for Azure v2 Responses API:
{
"input": [{
"type": "message",
"role": "assistant",
"content": [{
"type": "text",
"text": "...",
"annotations": []
}]
}]
}Actual Behavior
Error: HTTP 400 - Invalid payload from Azure Responses API
{
"error": {
"code": "invalid_payload",
"message": "Invalid payload",
"type": "invalid_request_error",
"details": [
{
"code": "ValidationError",
"message": "type: Value is \"array\" but should be \"string\"",
"param": "/input",
"type": "error"
},
{
"code": "ValidationError",
"message": "required: Required properties [\"type\"] are not present",
"param": "/input/1",
"type": "error"
},
{
"code": "ValidationError",
"message": "type: Value is \"array\" but should be \"string\"",
"param": "/input/1/content",
"type": "error"
},
{
"code": "ValidationError",
"message": "required: Required properties [\"annotations\"] are not present",
"param": "/input/1/content/0",
"type": "error"
}
]
}
}Logs Showing the Issue
2026-01-06 15:18:37,002 - agent_framework._workflows._runner - INFO - Starting superstep 3
2026-01-06 15:18:37,003 - agent_framework._workflows._handoff - INFO - Handoff detected: MasterAgent -> HealthCheckAgent. Routing control to specialist 'HealthCheckAgent'.
2026-01-06 15:18:38,886 - azure.core.pipeline.policies.http_logging_policy - INFO - Request URL: 'https://my-project.services.ai.azure.com/api/projects/my-ai-project/agents/HealthCheckAgent/versions?api-version=REDACTED'
2026-01-06 15:18:42,105 - httpx - INFO - HTTP Request: POST https://my-project.services.ai.azure.com/api/projects/my-ai-project/openai/responses?api-version=2025-11-15-preview "HTTP/1.1 400 Bad Request"
2026-01-06 15:18:42,192 - agent_framework_devui._executor - ERROR - Error in agent execution: <class 'agent_framework_azure_ai._client.AzureAIClient'> service failed to complete the prompt: Error code: 400 - {...}
Root Cause Analysis
The framework's workflow/handoff implementation appears to incorrectly serialize conversation history when calling Azure v2's Responses API. Specifically:
- ✅ First agent execution works: Initial message and tool calls are correctly formatted
- ✅ Handoff detection works: Framework correctly identifies handoff and routes to next agent
- ❌ Second agent initialization fails: When passing conversation history containing assistant text messages, the payload format is invalid
The issue appears to be in how the framework converts internal message representations to Azure v2's strict Responses API schema during handoffs.
What Works
- ✅ Single agent execution with
AzureAIClient - ✅ Direct tool calls (non-handoff)
- ✅ Handoff tool registration and invocation
- ✅ Initial handoff from Agent A → Agent B succeeds
- ✅ Same workflow with
AzureAIAgentClient(v1) works fine
Additional Context
Agent Configuration (YAML)
kind: Prompt
name: HealthCheckAgent
model:
options:
temperature: 0.9
topP: 0.95
tools:
- kind: mcp
serverName: DiagnosticServer
serverDescription: Diagnostic tools
connection:
kind: AnonymousConnection
endpoint: https://mcp-server.example.com/mcpConversation Flow Before Error
- User:
"camera not working" - Master Agent:
- Text:
"🔧 About to execute: Comprehensive Device Health Check..." - Tool call:
handoff_to_healthcheckagent
- Text:
- Handoff occurs → Health Check Agent receives malformed payload
Workaround Attempted
Setting agent_name parameter on each AzureAIClient fixed tool registration issues but did not resolve the payload formatting problem during handoffs.
Impact
This bug prevents using Azure Foundry v2 (AzureAIClient) with multi-agent workflows that use HandoffBuilder, forcing users to either:
- Use v1 API (
AzureAIAgentClient) which lacks modern features - Avoid workflows and implement manual agent coordination
- Use single-agent architectures only
Suggested Fix
The framework should ensure that when serializing conversation history for Azure v2 Responses API calls during handoffs, all messages conform to the required schema:
- Messages must have
typeproperty - Content arrays must include
annotationsproperty - Input should be properly structured as message objects, not raw arrays
Related Issues
This may be related to Azure v2's stricter schema validation compared to v1, and appears specific to workflow/handoff scenarios rather than direct agent invocation.
Code Sample
Additional Context
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status