Skip to content

Commit 5ce5b00

Browse files
committed
Add reasoning parameter to ModelSettings
1 parent 382500d commit 5ce5b00

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/agents/model_settings.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ class ModelSettings:
4040
max_tokens: int | None = None
4141
"""The maximum number of output tokens to generate."""
4242

43+
reasoning: dict[str, str] | None = None
44+
"""Controls reasoning behavior for reasoning-capable models.
45+
For o-series models: Use 'effort' key with values 'low', 'medium', or 'high' to control
46+
reasoning effort. For computer_use_preview: Use 'generate_summary' key with values
47+
'concise' or 'detailed' to get reasoning summaries."""
48+
4349
store: bool | None = None
4450
"""Whether to store the generated model response for later retrieval.
4551
Defaults to True if not provided."""

src/agents/models/openai_chatcompletions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ async def _fetch_response(
536536
stream=stream,
537537
stream_options={"include_usage": True} if stream else NOT_GIVEN,
538538
store=store,
539+
reasoning=self._non_null_or_not_given(model_settings.reasoning),
539540
extra_headers=_HEADERS,
540541
)
541542

@@ -555,6 +556,7 @@ async def _fetch_response(
555556
temperature=model_settings.temperature,
556557
tools=[],
557558
parallel_tool_calls=parallel_tool_calls or False,
559+
reasoning=model_settings.reasoning,
558560
)
559561
return response, ret
560562

src/agents/models/openai_responses.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ async def _fetch_response(
247247
extra_headers=_HEADERS,
248248
text=response_format,
249249
store=self._non_null_or_not_given(model_settings.store),
250+
reasoning=self._non_null_or_not_given(model_settings.reasoning),
250251
)
251252

252253
def _get_client(self) -> AsyncOpenAI:

0 commit comments

Comments
 (0)