Skip to content

Python: FoundryAgent strips model from PromptAgent requests in 1.2.0 (regression from #5447) #5525

@benke520

Description

@benke520

Bug Report

Describe the bug

FoundryAgent in agent-framework-foundry 1.2.0 unconditionally strips the model parameter from the Responses API request options in RawFoundryAgentChatClient._prepare_options(). This causes a 400 Bad Request error (Missing required parameter: 'model') when using PromptAgents that require model in the request body.

The regression was introduced in #5447 ("Update FoundryAgent for hosted agent sessions").

To Reproduce

  1. Create a PromptAgent on Azure AI Foundry with a name, version, and model.
  2. Connect to it using FoundryAgent with agent_version set:
agent = FoundryAgent(
    project_endpoint="...",
    agent_name="MyPromptAgent",
    agent_version="3",
    credential=AzureCliCredential(),
    default_options={"model": "gpt-5.4"},
    tools=[get_weather],
)
result = await agent.run("Hello", session=agent.create_session())
  1. The call fails with:
openai.BadRequestError: Error code: 400 - {'error': {'message': "Missing required parameter: 'model'.", 'type': 'invalid_request_error', 'param': 'model', 'code': 'missing_required_parameter'}}

Expected behavior

PromptAgent requests should include model in the Responses API call. Only HostedAgent sessions (where the model is managed server-side) should strip model.

Root cause

In python/packages/foundry/agent_framework_foundry/_agent.py, the _prepare_options method has:

run_options.pop("model", None)    # line ~353 — runs unconditionally

This should be conditional on whether a hosted agent session is being used:

if _uses_foundry_agent_session(conversation_id):
    run_options.pop("model", None)

Platform

  • OS: Windows 10
  • Python: 3.10.18
  • agent-framework-foundry: 1.2.0

Workaround

Pass model via extra_body which is not stripped:

default_options={
    "model": "gpt-5.4",
    "extra_body": {"model": "gpt-5.4"},
}

Metadata

Metadata

Assignees

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions