Skip to content

Commit 48f7dc8

Browse files
Update to the latest 'main' changes
2 parents 6c3ca71 + 50a909a commit 48f7dc8

File tree

172 files changed

+8915
-2756
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+8915
-2756
lines changed

.github/codex/home/config.toml

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/codex/labels/codex-attempt.md

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

.github/codex/labels/codex-review.md

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

.github/codex/labels/codex-triage.md

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

.github/workflows/codex.yml

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

.github/workflows/update-docs.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ jobs:
5555
with:
5656
commit-message: "Update all translated document pages"
5757
title: "Update all translated document pages"
58-
body: "Automated update of translated documentation"
58+
body: |
59+
Automated update of translated documentation.
60+
61+
Triggered by commit: [${{ github.event.head_commit.id }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.event.head_commit.id }}).
62+
Message: `${{ github.event.head_commit.message }}`
5963
branch: update-translated-docs-${{ github.run_id }}
6064
delete-branch: true

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ lint:
1717

1818
.PHONY: mypy
1919
mypy:
20-
uv run mypy .
20+
uv run mypy . --exclude site
2121

2222
.PHONY: tests
2323
tests:

README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,28 @@ Explore the [examples](examples) directory to see the SDK in action, and read ou
1919

2020
## Get started
2121

22-
1. Set up your Python environment
22+
To get started, set up your Python environment (Python 3.9 or newer required), and then install OpenAI Agents SDK package.
2323

24-
- Option A: Using venv (traditional method)
24+
### venv
2525

2626
```bash
27-
python -m venv env
28-
source env/bin/activate # On Windows: env\Scripts\activate
27+
python -m venv .venv
28+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
29+
pip install openai-agents
2930
```
3031

31-
- Option B: Using uv (recommended)
32+
For voice support, install with the optional `voice` group: `pip install 'openai-agents[voice]'`.
3233

33-
```bash
34-
uv venv
35-
source .venv/bin/activate # On Windows: .venv\Scripts\activate
36-
```
34+
### uv
3735

38-
2. Install Agents SDK
36+
If you're familiar with [uv](https://docs.astral.sh/uv/), using the tool would be even similar:
3937

4038
```bash
41-
pip install openai-agents
39+
uv init
40+
uv add openai-agents
4241
```
4342

44-
For voice support, install with the optional `voice` group: `pip install 'openai-agents[voice]'`.
43+
For voice support, install with the optional `voice` group: `uv add 'openai-agents[voice]'`.
4544

4645
## Hello world example
4746

docs/agents.md

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ from agents import Agent, ModelSettings, function_tool
1616

1717
@function_tool
1818
def get_weather(city: str) -> str:
19-
"""returns weather info for the specified city."""
19+
"""returns weather info for the specified city."""
2020
return f"The weather in {city} is sunny"
2121

2222
agent = Agent(
@@ -71,9 +71,47 @@ agent = Agent(
7171

7272
When you pass an `output_type`, that tells the model to use [structured outputs](https://platform.openai.com/docs/guides/structured-outputs) instead of regular plain text responses.
7373

74-
## Handoffs
74+
## Multi-agent system design patterns
7575

76-
Handoffs are sub-agents that the agent can delegate to. You provide a list of handoffs, and the agent can choose to delegate to them if relevant. This is a powerful pattern that allows orchestrating modular, specialized agents that excel at a single task. Read more in the [handoffs](handoffs.md) documentation.
76+
There are many ways to design multi‑agent systems, but we commonly see two broadly applicable patterns:
77+
78+
1. Manager (agents as tools): A central manager/orchestrator invokes specialized sub‑agents as tools and retains control of the conversation.
79+
2. Handoffs: Peer agents hand off control to a specialized agent that takes over the conversation. This is decentralized.
80+
81+
See [our practical guide to building agents](https://cdn.openai.com/business-guides-and-resources/a-practical-guide-to-building-agents.pdf) for more details.
82+
83+
### Manager (agents as tools)
84+
85+
The `customer_facing_agent` handles all user interaction and invokes specialized sub‑agents exposed as tools. Read more in the [tools](tools.md#agents-as-tools) documentation.
86+
87+
```python
88+
from agents import Agent
89+
90+
booking_agent = Agent(...)
91+
refund_agent = Agent(...)
92+
93+
customer_facing_agent = Agent(
94+
name="Customer-facing agent",
95+
instructions=(
96+
"Handle all direct user communication. "
97+
"Call the relevant tools when specialized expertise is needed."
98+
),
99+
tools=[
100+
booking_agent.as_tool(
101+
tool_name="booking_expert",
102+
tool_description="Handles booking questions and requests.",
103+
),
104+
refund_agent.as_tool(
105+
tool_name="refund_expert",
106+
tool_description="Handles refund questions and requests.",
107+
)
108+
],
109+
)
110+
```
111+
112+
### Handoffs
113+
114+
Handoffs are sub‑agents the agent can delegate to. When a handoff occurs, the delegated agent receives the conversation history and takes over the conversation. This pattern enables modular, specialized agents that excel at a single task. Read more in the [handoffs](handoffs.md) documentation.
77115

78116
```python
79117
from agents import Agent
@@ -84,9 +122,9 @@ refund_agent = Agent(...)
84122
triage_agent = Agent(
85123
name="Triage agent",
86124
instructions=(
87-
"Help the user with their questions."
88-
"If they ask about booking, handoff to the booking agent."
89-
"If they ask about refunds, handoff to the refund agent."
125+
"Help the user with their questions. "
126+
"If they ask about booking, hand off to the booking agent. "
127+
"If they ask about refunds, hand off to the refund agent."
90128
),
91129
handoffs=[booking_agent, refund_agent],
92130
)
@@ -115,7 +153,7 @@ Sometimes, you want to observe the lifecycle of an agent. For example, you may w
115153

116154
## Guardrails
117155

118-
Guardrails allow you to run checks/validations on user input, in parallel to the agent running. For example, you could screen the user's input for relevance. Read more in the [guardrails](guardrails.md) documentation.
156+
Guardrails allow you to run checks/validations on user input in parallel to the agent running, and on the agent's output once it is produced. For example, you could screen the user's input and agent's output for relevance. Read more in the [guardrails](guardrails.md) documentation.
119157

120158
## Cloning/copying agents
121159

@@ -155,13 +193,14 @@ agent = Agent(
155193
name="Weather Agent",
156194
instructions="Retrieve weather details.",
157195
tools=[get_weather],
158-
model_settings=ModelSettings(tool_choice="get_weather")
196+
model_settings=ModelSettings(tool_choice="get_weather")
159197
)
160198
```
161199

162200
## Tool Use Behavior
163201

164202
The `tool_use_behavior` parameter in the `Agent` configuration controls how tool outputs are handled:
203+
165204
- `"run_llm_again"`: The default. Tools are run, and the LLM processes the results to produce a final response.
166205
- `"stop_on_first_tool"`: The output of the first tool call is used as the final response, without further LLM processing.
167206

@@ -182,6 +221,7 @@ agent = Agent(
182221
```
183222

184223
- `StopAtTools(stop_at_tool_names=[...])`: Stops if any specified tool is called, using its output as the final response.
224+
185225
```python
186226
from agents import Agent, Runner, function_tool
187227
from agents.agent import StopAtTools
@@ -203,6 +243,7 @@ agent = Agent(
203243
tool_use_behavior=StopAtTools(stop_at_tool_names=["get_weather"])
204244
)
205245
```
246+
206247
- `ToolsToFinalOutputFunction`: A custom function that processes tool results and decides whether to stop or continue with the LLM.
207248

208249
```python
@@ -242,4 +283,3 @@ agent = Agent(
242283
!!! note
243284

244285
To prevent infinite loops, the framework automatically resets `tool_choice` to "auto" after a tool call. This behavior is configurable via [`agent.reset_tool_choice`][agents.agent.Agent.reset_tool_choice]. The infinite loop is because tool results are sent to the LLM, which then generates another tool call because of `tool_choice`, ad infinitum.
245-

docs/assets/images/graph.png

-59.2 KB
Loading

0 commit comments

Comments
 (0)