Skip to content

Commit 760e48d

Browse files
authored
Merge branch 'main' into python-3.14
2 parents c610214 + 4ba2e8a commit 760e48d

25 files changed

+1002
-345
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
enable-cache: true
2323
- name: Install dependencies
2424
run: make sync
25+
- name: Verify formatting
26+
run: make format-check
2527
- name: Run lint
2628
run: make lint
2729

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/basic/lifecycle_example.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
import random
3-
from typing import Any, Optional
3+
from typing import Any, Optional, cast
44

55
from pydantic import BaseModel
66

@@ -15,6 +15,7 @@
1515
function_tool,
1616
)
1717
from agents.items import ModelResponse, TResponseInputItem
18+
from agents.tool_context import ToolContext
1819

1920

2021
class LoggingHooks(AgentHooks[Any]):
@@ -71,16 +72,22 @@ async def on_agent_end(self, context: RunContextWrapper, agent: Agent, output: A
7172

7273
async def on_tool_start(self, context: RunContextWrapper, agent: Agent, tool: Tool) -> None:
7374
self.event_counter += 1
75+
# While this type cast is not ideal,
76+
# we don't plan to change the context arg type in the near future for backwards compatibility.
77+
tool_context = cast(ToolContext[Any], context)
7478
print(
75-
f"### {self.event_counter}: Tool {tool.name} started. name={context.tool_name}, call_id={context.tool_call_id}, args={context.tool_arguments}. Usage: {self._usage_to_str(context.usage)}" # type: ignore[attr-defined]
79+
f"### {self.event_counter}: Tool {tool.name} started. name={tool_context.tool_name}, call_id={tool_context.tool_call_id}, args={tool_context.tool_arguments}. Usage: {self._usage_to_str(tool_context.usage)}"
7680
)
7781

7882
async def on_tool_end(
7983
self, context: RunContextWrapper, agent: Agent, tool: Tool, result: str
8084
) -> None:
8185
self.event_counter += 1
86+
# While this type cast is not ideal,
87+
# we don't plan to change the context arg type in the near future for backwards compatibility.
88+
tool_context = cast(ToolContext[Any], context)
8289
print(
83-
f"### {self.event_counter}: Tool {tool.name} finished. result={result}, name={context.tool_name}, call_id={context.tool_call_id}, args={context.tool_arguments}. Usage: {self._usage_to_str(context.usage)}" # type: ignore[attr-defined]
90+
f"### {self.event_counter}: Tool {tool.name} finished. result={result}, name={tool_context.tool_name}, call_id={tool_context.tool_call_id}, args={tool_context.tool_arguments}. Usage: {self._usage_to_str(tool_context.usage)}"
8491
)
8592

8693
async def on_handoff(

examples/realtime/app/agent.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import asyncio
2+
13
from agents import function_tool
24
from agents.extensions.handoff_prompt import RECOMMENDED_PROMPT_PREFIX
35
from agents.realtime import RealtimeAgent, realtime_handoff
@@ -13,20 +15,26 @@
1315
name_override="faq_lookup_tool", description_override="Lookup frequently asked questions."
1416
)
1517
async def faq_lookup_tool(question: str) -> str:
16-
if "bag" in question or "baggage" in question:
18+
print("faq_lookup_tool called with question:", question)
19+
20+
# Simulate a slow API call
21+
await asyncio.sleep(3)
22+
23+
q = question.lower()
24+
if "wifi" in q or "wi-fi" in q:
25+
return "We have free wifi on the plane, join Airline-Wifi"
26+
elif "bag" in q or "baggage" in q:
1727
return (
1828
"You are allowed to bring one bag on the plane. "
1929
"It must be under 50 pounds and 22 inches x 14 inches x 9 inches."
2030
)
21-
elif "seats" in question or "plane" in question:
31+
elif "seats" in q or "plane" in q:
2232
return (
2333
"There are 120 seats on the plane. "
2434
"There are 22 business class seats and 98 economy seats. "
2535
"Exit rows are rows 4 and 16. "
2636
"Rows 5-8 are Economy Plus, with extra legroom. "
2737
)
28-
elif "wifi" in question:
29-
return "We have free wifi on the plane, join Airline-Wifi"
3038
return "I'm sorry, I don't know the answer to that question."
3139

3240

examples/realtime/app/server.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ async def connect(self, websocket: WebSocket, session_id: str):
4747

4848
agent = get_starting_agent()
4949
runner = RealtimeRunner(agent)
50+
# If you want to customize the runner behavior, you can pass options:
51+
# runner_config = RealtimeRunConfig(async_tool_calls=False)
52+
# runner = RealtimeRunner(agent, config=runner_config)
5053
model_config: RealtimeModelConfig = {
5154
"initial_model_settings": {
5255
"turn_detection": {

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.2"
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

0 commit comments

Comments
 (0)