Skip to content

Commit 2edef16

Browse files
authored
Merge branch 'main' into fix/sqlite-session-lock-bug-clean
2 parents 3969fe9 + 03dca68 commit 2edef16

File tree

16 files changed

+667
-313
lines changed

16 files changed

+667
-313
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# OpenAI Agents SDK
1+
# OpenAI Agents SDK [![PyPI](https://img.shields.io/pypi/v/openai-agents?label=pypi%20package)](https://pypi.org/project/openai-agents/)
22

33
The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows. It is provider-agnostic, supporting the OpenAI Responses and Chat Completions APIs, as well as 100+ other LLMs.
44

examples/realtime/cli/ui.py

Lines changed: 0 additions & 268 deletions
This file was deleted.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "openai-agents"
3-
version = "0.4.0"
3+
version = "0.4.1"
44
description = "OpenAI Agents SDK"
55
readme = "README.md"
66
requires-python = ">=3.9"

src/agents/extensions/memory/sqlalchemy_session.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,3 +319,16 @@ async def clear_session(self) -> None:
319319
await sess.execute(
320320
delete(self._sessions).where(self._sessions.c.session_id == self.session_id)
321321
)
322+
323+
@property
324+
def engine(self) -> AsyncEngine:
325+
"""Access the underlying SQLAlchemy AsyncEngine.
326+
327+
This property provides direct access to the engine for advanced use cases,
328+
such as checking connection pool status, configuring engine settings,
329+
or manually disposing the engine when needed.
330+
331+
Returns:
332+
AsyncEngine: The SQLAlchemy async engine instance.
333+
"""
334+
return self._engine

src/agents/extensions/models/litellm_model.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
from ...models.chatcmpl_stream_handler import ChatCmplStreamHandler
4545
from ...models.fake_id import FAKE_RESPONSES_ID
4646
from ...models.interface import Model, ModelTracing
47+
from ...models.openai_responses import Converter as OpenAIResponsesConverter
4748
from ...tool import Tool
4849
from ...tracing import generation_span
4950
from ...tracing.span_data import GenerationSpanData
@@ -367,15 +368,19 @@ async def _fetch_response(
367368
if isinstance(ret, litellm.types.utils.ModelResponse):
368369
return ret
369370

371+
responses_tool_choice = OpenAIResponsesConverter.convert_tool_choice(
372+
model_settings.tool_choice
373+
)
374+
if responses_tool_choice is None or responses_tool_choice is omit:
375+
responses_tool_choice = "auto"
376+
370377
response = Response(
371378
id=FAKE_RESPONSES_ID,
372379
created_at=time.time(),
373380
model=self.model,
374381
object="response",
375382
output=[],
376-
tool_choice=cast(Literal["auto", "required", "none"], tool_choice)
377-
if tool_choice is not omit
378-
else "auto",
383+
tool_choice=responses_tool_choice, # type: ignore[arg-type]
379384
top_p=model_settings.top_p,
380385
temperature=model_settings.temperature,
381386
tools=[],

src/agents/items.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@ def _maybe_get_output_as_structured_function_output(
361361
if isinstance(output, (ToolOutputText, ToolOutputImage, ToolOutputFileContent)):
362362
return output
363363
elif isinstance(output, dict):
364+
# Require explicit 'type' field in dict to be considered a structured output
365+
if "type" not in output:
366+
return None
364367
try:
365368
return ValidToolOutputPydanticModelsTypeAdapter.validate_python(output)
366369
except pydantic.ValidationError:

src/agents/realtime/model_inputs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ class RealtimeModelSendToolOutput:
9595
class RealtimeModelSendInterrupt:
9696
"""Send an interrupt to the model."""
9797

98+
force_response_cancel: bool = False
99+
"""Force sending a response.cancel event even if automatic cancellation is enabled."""
100+
98101

99102
@dataclass
100103
class RealtimeModelSendSessionUpdate:

0 commit comments

Comments
 (0)