Skip to content

Passing verbosity in extra_body breaks structured output #1536

@holmbuar

Description

@holmbuar

Sorry for not providing a reproducible example, but just for illustration, in my test code running the agent will obey the structured output fields, while agent2 will make up extra JSON fields in the final_output, triggering various Pydantic JSON validation errors. Am I using ModelSettings correctly?

openai                    1.100.2
openai-agents             0.2.8
from pydantic import BaseModel
from agents import Agent

class CalendarEvent(BaseModel):
    name: str
    date: str
    participants: list[str]

agent = Agent(
    name="Calendar extractor",
    instructions="Extract calendar events from text",
    output_type=CalendarEvent,
    model="gpt-5"
)

agent2 = Agent(
    name="Calendar extractor 2",
    instructions="Extract calendar events from text",
    output_type=CalendarEvent,
    model="gpt-5",
    model_settings=ModelSettings(
         reasoning={"effort":"low"},
         extra_body={"text":{"verbosity":"low"}}
     ),
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions