Skip to content

Python: [Bug]: Foundry agent rejects tools with HTTP 400 on the preview path (allow_preview=True) #6657

@vaibhav-patel

Description

@vaibhav-patel

Describe the bug

RawFoundryAgentChatClient (the client behind FoundryAgent) returns HTTP 400 invalid_payload"Not allowed when agent is specified." (param: tools) — when a caller passes tools while the preview path is active (allow_preview=True).

RawFoundryAgentChatClient always targets a pre-provisioned Foundry agent (agent_name is required), and the service rejects requests that carry both an agent reference and tool declarations.

PR #5101 added stripping of tools / tool_choice / parallel_tool_calls in RawFoundryAgentChatClient._prepare_options(), but gated it behind if not self.allow_preview:. The preview path also specifies an agent — the identity is bound on the OpenAI client via project_client.get_openai_client(agent_name=...) — so tool declarations are still sent (and rejected) on that path.

Where

python/packages/foundry/agent_framework_foundry/_agent.pyRawFoundryAgentChatClient._prepare_options().

Expected behavior

Since this client always targets a pre-provisioned agent, tool declarations should be stripped from the request body on both the preview and non-preview paths. Tools are still invoked client-side by the function-invocation layer; their schemas must be defined on the Foundry agent in the service.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    pythonIssues related to the Python codebasetriagePlaced on an issue or discussion that requires a maintainer to triage the item

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions