-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Python: [BUG]: ChatClientException 400 invalid_payload when passing [tools] with an agent reference #5130
Description
Repository:
Azure/azure-sdk-for-python → agent_framework_foundry
Describe the bug
When calling. the SDK raises a ChatClientException with HTTP 400:
agent_framework.exceptions.ChatClientException: <class 'agent_framework_foundry._agent._FoundryAgentChatClient'>
service failed to complete the prompt: Error code: 400 - {
'error': {
'code': 'invalid_payload',
'message': 'Not allowed when agent is specified.',
'param': 'tools',
'type': 'invalid_request_error',
'details': [],
'additionalInfo': {'request_id': '2c95a877e6de2e61b228e1979c7a85ba'}
}
}Steps to reproduce
Provision an agent with function tools via
AIProjectClient.agents.create_version(agent_name=..., definition=PromptAgentDefinition(tools[FunctionTool(...)]))]
Run it with:
Expected behavior
FoundryAgent.run(tools=[...])
should use the provided callables only for local function dispatch (executing tool call results returned by the model) without re-sending the tool declarations to the service. The tool schema is already embedded in the agent definition on the server side.
Actual behavior
MAF includes the [tools] parameter in the API request body, which the Foundry service rejects because tool declarations are not allowed when an agent reference is specified.
Workaround
Remove [tools
The function tools are not dispatched locally, resulting in empty responses when the model issues a function_call.
Environment
azure-ai-projects >= 2.0.0
agent-framework==1.0.0