Agents sdk reasoning argument

For some reason, without changing my code from last week, when I try to use the reasoning argument when using the Agents sdk, it gives me this error:

TypeError: ModelSettings.init() got an unexpected keyword argument ‘reasoning’

This is part of the code where I use it:

agent = Agent(
   name="Assistant",
   model="gpt-5",
   model_settings = ModelSettings(reasoning=Reasoning(effort="minimal"))
)

I have the latest version for reference.

1 Like

Welcome to the forum.

Make sure you also upgrade the openai package, as the class Reasoning comes from there:

from openai.types import Reasoning
from agents import Agent, Runner

agent = Agent(
    name="minimal_agent",
    model="gpt-5-mini",
    model_settings= ModelSettings(reasoning=Reasoning(effort="minimal")),
)
result = await Runner.run(agent, "hi")

Last week the dependencies for agents sdk got upgraded from openai 1.109.x to 2.x, so it might have caused some incompatibility. You can run this to update everything:
pip install --upgrade openai openai-agents

2 Likes