Skip to content

Python: [Bug]: AzureAIProjectAgentProvider Foundry agents ignore / don’t accept response_format at runtime (agent.run) #3230

@ekinsenler

Description

@ekinsenler

Description

When using AzureAIProjectAgentProvider with Azure AI Foundry hosted agents, I can set response_format when creating the agent, but I cannot override response_format per-run. agent.run(..., response_format=...) is ignored. This differs from other Agent Framework flows where per-call structured output is possible.

Code Sample

import asyncio, os
from typing import List
from pydantic import BaseModel
from azure.ai.projects.aio import AIProjectClient
from azure.identity import InteractiveBrowserCredential
from azure.core.exceptions import ResourceNotFoundError
from agent_framework.azure import AzureAIProjectAgentProvider

class SchemaA(BaseModel):
    title: str
    summary: str

class SchemaB(BaseModel):
    topic: str
    bullets: List[str]

async def main():
    cred = InteractiveBrowserCredential()
    async with AIProjectClient(
        endpoint=os.environ["AZURE_AI_FOUNDRY_PROJECT_ENDPOINT"],
        credential=cred,
    ) as pc:
        provider = AzureAIProjectAgentProvider(project_client=pc)
        name = "repro-runtime-response-format"
        try:
            agent = await provider.get_agent(name=name)
        except ResourceNotFoundError:
            agent = await provider.create_agent(
                name=name,
                model="gpt-5.2",
                description="Repro: runtime response_format override",
                instructions="Return JSON matching the requested schema.",
                response_format=SchemaA,  # works
            )

        prompt = "Summarize: observability for LLM apps. Add key points."
        r1 = await agent.run(input=prompt)  # follows SchemaA
        r2 = await agent.run(input=prompt, response_format=SchemaB)  # expected SchemaB
        print("SchemaA:", r1)
        print("SchemaB override:", r2)

if __name__ == "__main__":
    asyncio.run(main())

Error Messages / Stack Traces

Package Versions

agent-framework: 1.0.0b260114

Python Version

Python 3.13

Additional Context

No response

Metadata

Metadata

Assignees

Labels

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

Type

Projects

Status

Planned

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions