Skip to content

Add reasoning parameter to ModelSettings #388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/agents/model_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ class ModelSettings:
max_tokens: int | None = None
"""The maximum number of output tokens to generate."""

reasoning: dict[str, str] | None = None
"""Controls reasoning behavior for reasoning-capable models.
For o-series models: Use 'effort' key with values 'low', 'medium', or 'high' to control
reasoning effort. For computer_use_preview: Use 'generate_summary' key with values
'concise' or 'detailed' to get reasoning summaries."""

store: bool | None = None
"""Whether to store the generated model response for later retrieval.
Defaults to True if not provided."""
Expand Down
2 changes: 2 additions & 0 deletions src/agents/models/openai_chatcompletions.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ async def _fetch_response(
stream=stream,
stream_options={"include_usage": True} if stream else NOT_GIVEN,
store=store,
reasoning=self._non_null_or_not_given(model_settings.reasoning),
extra_headers=_HEADERS,
)

Expand All @@ -555,6 +556,7 @@ async def _fetch_response(
temperature=model_settings.temperature,
tools=[],
parallel_tool_calls=parallel_tool_calls or False,
reasoning=model_settings.reasoning,
)
return response, ret

Expand Down
1 change: 1 addition & 0 deletions src/agents/models/openai_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ async def _fetch_response(
extra_headers=_HEADERS,
text=response_format,
store=self._non_null_or_not_given(model_settings.store),
reasoning=self._non_null_or_not_given(model_settings.reasoning),
)

def _get_client(self) -> AsyncOpenAI:
Expand Down