Skip to content

Python: [Bug]: strict field does not exist in JSON schema in Foundry when using with Create Agent API for Azure V2 #3229

@mhmtkcm

Description

@mhmtkcm

Description

When an agent is created using the Create API in the new Foundry V2 update, the JSON schema details of the newly created agent do not include the "strict: true" field. I also tried using Pydantic's "ConfigDict(extra="forbid")" setting, but it didn't work.

Image

Code Sample

import asyncio
import os

from agent_framework.azure import AzureAIProjectAgentProvider
from azure.ai.projects.aio import AIProjectClient
from azure.core.exceptions import ResourceNotFoundError
from azure.identity import InteractiveBrowserCredential
from pydantic import BaseModel


class TestSchema(BaseModel):
    subject: str
    summary: str


async def main():
    credential = InteractiveBrowserCredential()
    async with AIProjectClient(
        endpoint=os.environ["AZURE_AI_FOUNDRY_PROJECT_ENDPOINT"],
        credential=credential,
    ) as project_client:
        provider = AzureAIProjectAgentProvider(project_client=project_client)
        agent_name = "summarizer-agent"
        try:
            agent = await provider.get_agent(name=agent_name)
            print(f"Agent found: {agent.name}")
        except ResourceNotFoundError:
            agent = await provider.create_agent(
                name=agent_name,
                model="gpt-5.2",
                instructions="You are responsible for writing a brief summary of a few sentences on the given subject.",
                description="An agent that summarizes a given subject.",
                response_format=TestSchema,
            )
            print(f"Agent created: {agent.name}")

        response = await agent.run(subject="Artificial Intelligence")
        print("===== Agent Response =====")
        print(response)


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

Error Messages / Stack Traces

Package Versions

1.0.0b260114

Python Version

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

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions