Skip to content
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