Skip to content

Bugfix | Fixed a bug when calling reasoning models with store=False #920

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 1 commit into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions src/agents/model_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Any, Literal

from openai._types import Body, Headers, Query
from openai.types.responses import ResponseIncludable
from openai.types.shared import Reasoning
from pydantic import BaseModel

Expand Down Expand Up @@ -61,6 +62,10 @@ class ModelSettings:
"""Whether to include usage chunk.
Defaults to True if not provided."""

response_include: list[ResponseIncludable] | None = None
"""Additional output data to include in the model response.
[include parameter](https://platform.openai.com/docs/api-reference/responses/create#responses-create-include)"""

extra_query: Query | None = None
"""Additional query fields to provide with the request.
Defaults to None if not provided."""
Expand Down
6 changes: 5 additions & 1 deletion src/agents/models/openai_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ async def _fetch_response(
converted_tools = Converter.convert_tools(tools, handoffs)
response_format = Converter.get_response_format(output_schema)

include: list[ResponseIncludable] = converted_tools.includes
if model_settings.response_include is not None:
include = list({*include, *model_settings.response_include})

if _debug.DONT_LOG_MODEL_DATA:
logger.debug("Calling LLM")
else:
Expand All @@ -258,7 +262,7 @@ async def _fetch_response(
instructions=self._non_null_or_not_given(system_instructions),
model=self.model,
input=list_input,
include=converted_tools.includes,
include=include,
tools=converted_tools.tools,
prompt=self._non_null_or_not_given(prompt),
temperature=self._non_null_or_not_given(model_settings.temperature),
Expand Down
1 change: 1 addition & 0 deletions tests/model_settings/test_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def test_all_fields_serialization() -> None:
metadata={"foo": "bar"},
store=False,
include_usage=False,
response_include=["reasoning.encrypted_content"],
extra_query={"foo": "bar"},
extra_body={"foo": "bar"},
extra_headers={"foo": "bar"},
Expand Down