Skip to content

Commit 2a8934c

Browse files
authored
Merge branch 'main' into session-docs-improvements
2 parents 9fc5891 + 22a63aa commit 2a8934c

Some content is hidden

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

60 files changed

+6696
-650
lines changed

.github/workflows/issues.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ jobs:
1515
days-before-issue-stale: 7
1616
days-before-issue-close: 3
1717
stale-issue-label: "stale"
18+
exempt-issue-labels: "skip-stale"
1819
stale-issue-message: "This issue is stale because it has been open for 7 days with no activity."
1920
close-issue-message: "This issue was closed because it has been inactive for 3 days since being marked as stale."
2021
any-of-issue-labels: 'question,needs-more-info'
2122
days-before-pr-stale: 10
2223
days-before-pr-close: 7
2324
stale-pr-label: "stale"
24-
exempt-issue-labels: "skip-stale"
25+
exempt-pr-labels: "skip-stale"
2526
stale-pr-message: "This PR is stale because it has been open for 10 days with no activity."
2627
close-pr-message: "This PR was closed because it has been inactive for 7 days since being marked as stale."
2728
repo-token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,6 @@ cython_debug/
144144
# PyPI configuration file
145145
.pypirc
146146
.aider*
147+
148+
# Redis database files
149+
dump.rdb

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ pip install openai-agents
3131

3232
For voice support, install with the optional `voice` group: `pip install 'openai-agents[voice]'`.
3333

34+
For Redis session support, install with the optional `redis` group: `pip install 'openai-agents[redis]'`.
35+
3436
### uv
3537

3638
If you're familiar with [uv](https://docs.astral.sh/uv/), using the tool would be even similar:
@@ -42,6 +44,8 @@ uv add openai-agents
4244

4345
For voice support, install with the optional `voice` group: `uv add 'openai-agents[voice]'`.
4446

47+
For Redis session support, install with the optional `redis` group: `uv add 'openai-agents[redis]'`.
48+
4549
## Hello world example
4650

4751
```python
@@ -211,8 +215,13 @@ print(result.final_output) # "Approximately 39 million"
211215
```python
212216
from agents import Agent, Runner, SQLiteSession
213217

214-
# Custom SQLite database file
218+
# SQLite - file-based or in-memory database
215219
session = SQLiteSession("user_123", "conversations.db")
220+
221+
# Redis - for scalable, distributed deployments
222+
# from agents.extensions.memory import RedisSession
223+
# session = RedisSession.from_url("user_123", url="redis://localhost:6379/0")
224+
216225
agent = Agent(name="Assistant")
217226

218227
# Different session IDs maintain separate conversation histories

docs/agents.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get_weather(city: str) -> str:
2222
agent = Agent(
2323
name="Haiku agent",
2424
instructions="Always respond in haiku form",
25-
model="o3-mini",
25+
model="gpt-5-nano",
2626
tools=[get_weather],
2727
)
2828
```
@@ -163,7 +163,7 @@ By using the `clone()` method on an agent, you can duplicate an Agent, and optio
163163
pirate_agent = Agent(
164164
name="Pirate",
165165
instructions="Write like a pirate",
166-
model="o3-mini",
166+
model="gpt-4.1",
167167
)
168168

169169
robot_agent = pirate_agent.clone(

docs/guardrails.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,4 @@ async def main():
151151
1. This is the actual agent's output type.
152152
2. This is the guardrail's output type.
153153
3. This is the guardrail function that receives the agent's output, and returns the result.
154-
4. This is the actual agent that defines the workflow.
154+
4. This is the actual agent that defines the workflow.

docs/ja/agents.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ search:
44
---
55
# エージェント
66

7-
エージェントはアプリの中核となる構成要素です。エージェントは、instructions とツールで構成された大規模言語モデル ( LLM ) です。
7+
エージェントはアプリにおける中核の構成要素です。エージェントは、instructions と tools で構成された大規模言語モデル( LLM です。
88

9-
## 基本設定
9+
## 基本構成
1010

11-
最も一般的に設定するエージェントのプロパティは次のとおりです
11+
エージェントで最も一般的に設定するプロパティは次のとおりです
1212

13-
- `name`: エージェントを識別する必須の文字列です
14-
- `instructions`: developer メッセージまたは system prompt とも呼ばれます。
15-
- `model`: 使用する LLM と、temperature、top_p などのモデル調整パラメーターを構成する任意の `model_settings`
16-
- `tools`: エージェントがタスク達成のために使用できるツールです
13+
- `name`: エージェントを識別する必須の文字列
14+
- `instructions`: developer メッセージ、または system prompt とも呼ばれます。
15+
- `model`: 使用する LLM と、temperature、top_p などのモデル調整用の任意の `model_settings`
16+
- `tools`: エージェントがタスク達成のために使用できるツール
1717

1818
```python
1919
from agents import Agent, ModelSettings, function_tool
@@ -26,14 +26,14 @@ def get_weather(city: str) -> str:
2626
agent = Agent(
2727
name="Haiku agent",
2828
instructions="Always respond in haiku form",
29-
model="o3-mini",
29+
model="gpt-5-nano",
3030
tools=[get_weather],
3131
)
3232
```
3333

3434
## コンテキスト
3535

36-
エージェントは `context` 型に対してジェネリックです。コンテキストは依存性注入のためのツールで、あなたが作成して `Runner.run()` に渡すオブジェクトです。これはすべてのエージェント、ツール、ハンドオフなどに渡され、エージェントの実行における依存関係と状態の詰め合わせとして機能します。任意の Python オブジェクトをコンテキストとして提供できます
36+
エージェントはその `context` 型に対してジェネリックです。Context は依存性注入のためのツールです。あなたが作成して `Runner.run()` に渡すオブジェクトで、すべてのエージェント、ツール、ハンドオフなどに渡され、エージェントの実行に必要な依存関係と状態の寄せ集めとして機能します。任意の Python オブジェクトを context として提供できます
3737

3838
```python
3939
@dataclass
@@ -52,7 +52,7 @@ agent = Agent[UserContext](
5252

5353
## 出力タイプ
5454

55-
デフォルトでは、エージェントはプレーンテキスト (すなわち `str`) を出力します。特定の型の出力をエージェントに生成させたい場合は、`output_type` パラメーターを使用できます。一般的な選択肢は [Pydantic](https://docs.pydantic.dev/) オブジェクトを使うことですが、Pydantic の [TypeAdapter](https://docs.pydantic.dev/latest/api/type_adapter/) でラップできる任意の型をサポートします—dataclasses、list、TypedDict など。
55+
デフォルトでは、エージェントはプレーンテキスト`str`)出力を生成します。特定の型の出力をエージェントに生成させたい場合は、`output_type` パラメーターを使用できます。一般的な選択肢は [Pydantic](https://docs.pydantic.dev/) オブジェクトですが、Pydantic の [TypeAdapter](https://docs.pydantic.dev/latest/api/type_adapter/) でラップできる任意の型(dataclasses、lists、TypedDict など)をサポートします
5656

5757
```python
5858
from pydantic import BaseModel
@@ -73,20 +73,20 @@ agent = Agent(
7373

7474
!!! note
7575

76-
`output_type` を渡すと、モデルは通常のプレーンテキスト応答ではなく [structured outputs](https://platform.openai.com/docs/guides/structured-outputs) を使用するよう指示されます
76+
`output_type` を渡すと、通常のプレーンテキスト応答ではなく、[structured outputs](https://platform.openai.com/docs/guides/structured-outputs) を使用するようにモデルに指示します
7777

78-
## マルチエージェント システムの設計パターン
78+
## マルチエージェントの設計パターン
7979

80-
マルチエージェント システムを設計する方法は多岐にわたりますが、広く適用できるパターンとして次の 2 つがよく見られます
80+
マルチエージェントシステムの設計方法は多数ありますが、一般的に広く適用できるパターンは次の 2 つです
8181

82-
1. マネージャー(ツールとしてのエージェント): 中央のマネージャー/オーケストレーターが、ツールとして公開された特化型サブエージェントを呼び出し、会話の制御を保持します
83-
2. ハンドオフ: 対等なエージェント間で、会話を引き継ぐ特化型エージェントに制御をハンドオフします。これは分散型です。
82+
1. マネージャー(エージェントをツールとして): 中央のマネージャー/オーケストレーターが、ツールとして公開された専門のサブエージェントを呼び出し、会話の制御を維持します
83+
2. ハンドオフ: ピアのエージェントが制御を専門のエージェントに引き渡し、そのエージェントが会話を引き継ぎます。これは分散型です。
8484

8585
詳細は [エージェント構築の実践ガイド](https://cdn.openai.com/business-guides-and-resources/a-practical-guide-to-building-agents.pdf) を参照してください。
8686

87-
### マネージャー(ツールとしてのエージェント
87+
### マネージャー(エージェントをツールとして
8888

89-
`customer_facing_agent` はすべてのユーザー対応を行い、ツールとして公開された特化型サブエージェントを呼び出します。詳しくは [ツール](tools.md#agents-as-tools) のドキュメントを参照してください
89+
`customer_facing_agent` はすべてのユーザー対応を処理し、ツールとして公開された専門のサブエージェントを呼び出します。詳細は [ツール](tools.md#agents-as-tools) ドキュメントをご覧ください
9090

9191
```python
9292
from agents import Agent
@@ -115,7 +115,7 @@ customer_facing_agent = Agent(
115115

116116
### ハンドオフ
117117

118-
ハンドオフは、エージェントが委任できるサブエージェントです。ハンドオフが発生すると、委任先のエージェントは会話履歴を受け取り、会話を引き継ぎます。このパターンにより、単一のタスクに秀でたモジュール型・特化型エージェントが可能になります。詳しくは [ハンドオフ](handoffs.md) のドキュメントを参照してください
118+
ハンドオフは、エージェントが委譲できるサブエージェントです。ハンドオフが発生すると、委譲先のエージェントは会話履歴を受け取り、会話を引き継ぎます。このパターンにより、単一タスクに特化したモジュール式のエージェントが可能になります。詳細は [ハンドオフ](handoffs.md) ドキュメントをご覧ください
119119

120120
```python
121121
from agents import Agent
@@ -136,7 +136,7 @@ triage_agent = Agent(
136136

137137
## 動的 instructions
138138

139-
多くの場合、エージェント作成時に instructions を指定できますが、関数を介して動的な instructions を提供することもできます。この関数はエージェントとコンテキストを受け取り、プロンプトを返す必要があります。通常の関数と `async` 関数のどちらも使用できます
139+
多くの場合、エージェントを作成するときに instructions を指定できますが、関数を通じて動的な instructions を提供することもできます。この関数はエージェントと context を受け取り、プロンプトを返す必要があります。通常の関数と `async` 関数の両方を受け付けます
140140

141141
```python
142142
def dynamic_instructions(
@@ -153,11 +153,11 @@ agent = Agent[UserContext](
153153

154154
## ライフサイクルイベント(フック)
155155

156-
場合によっては、エージェントのライフサイクルを観察したいことがあります。たとえば、イベントのログ記録や、特定のイベント発生時にデータを事前取得したい場合です`hooks` プロパティでエージェントのライフサイクルにフックできます[`AgentHooks`][agents.lifecycle.AgentHooks] クラスをサブクラス化し、関心のあるメソッドをオーバーライドしてください。
156+
場合によっては、エージェントのライフサイクルを観測したいことがあります。たとえば、イベントをログに記録したり、特定のイベント発生時にデータを事前取得したりします`hooks` プロパティを使ってエージェントのライフサイクルにフックできます[`AgentHooks`][agents.lifecycle.AgentHooks] クラスをサブクラス化し、関心のあるメソッドをオーバーライドしてください。
157157

158158
## ガードレール
159159

160-
ガードレールにより、エージェントの実行と並行してユーザー入力に対するチェック/検証を行い、エージェントの出力が生成された後にもチェックを実行できます。たとえば、ユーザー入力とエージェント出力の関連性をスクリーニングできます。詳しくは [ガードレール](guardrails.md) のドキュメントを参照してください
160+
ガードレールにより、エージェントの実行と並行してユーザー入力に対するチェック/バリデーションを実行し、エージェントの出力が生成された後にも同様のチェックを行えます。たとえば、ユーザーの入力とエージェントの出力の妥当性をスクリーニングできます。詳細は [ガードレール](guardrails.md) ドキュメントをご覧ください
161161

162162
## エージェントのクローン/コピー
163163

@@ -167,7 +167,7 @@ agent = Agent[UserContext](
167167
pirate_agent = Agent(
168168
name="Pirate",
169169
instructions="Write like a pirate",
170-
model="o3-mini",
170+
model="gpt-4.1",
171171
)
172172

173173
robot_agent = pirate_agent.clone(
@@ -178,12 +178,12 @@ robot_agent = pirate_agent.clone(
178178

179179
## ツール使用の強制
180180

181-
ツールのリストを渡しても、LLM が必ずツールを使うとは限りません[`ModelSettings.tool_choice`][agents.model_settings.ModelSettings.tool_choice] を設定してツール使用を強制できます。有効な値は次のとおりです。
181+
ツールのリストを渡しても、LLM が必ずしもツールを使うとは限りません[`ModelSettings.tool_choice`][agents.model_settings.ModelSettings.tool_choice] を設定することで、ツール使用を強制できます。有効な値は次のとおりです。
182182

183-
1. `auto`: LLM にツールを使うかどうかを判断させます
184-
2. `required`: LLM にツールの使用を要求します(どのツールを使うかは賢く判断できます)。
185-
3. `none`: LLM にツールを使用しないことを要求します
186-
4. 特定の文字列(例: `my_tool`を設定すると、その特定のツールを LLM に使用させます
183+
1. `auto`: LLM にツールを使うかどうかの判断を任せます
184+
2. `required`: LLM にツールの使用を要求します(ただし、どのツールを使うかは賢く判断できます)。
185+
3. `none`: LLM にツールを使わないよう要求します
186+
4. 特定の文字列(例: `my_tool`を設定し、その特定のツールの使用を要求します
187187

188188
```python
189189
from agents import Agent, Runner, function_tool, ModelSettings
@@ -201,12 +201,12 @@ agent = Agent(
201201
)
202202
```
203203

204-
## ツール使用の挙動
204+
## ツール使用の動作
205205

206206
`Agent``tool_use_behavior` パラメーターは、ツール出力の扱いを制御します。
207207

208208
- `"run_llm_again"`: デフォルト。ツールを実行し、その結果を LLM が処理して最終応答を生成します。
209-
- `"stop_on_first_tool"`: 最初のツール呼び出しの出力を、その後の LLM 処理なしで最終応答として使用します。
209+
- `"stop_on_first_tool"`: 最初のツール呼び出しの出力を、追加の LLM 処理なしに最終応答として使用します.
210210

211211
```python
212212
from agents import Agent, Runner, function_tool, ModelSettings
@@ -224,7 +224,7 @@ agent = Agent(
224224
)
225225
```
226226

227-
- `StopAtTools(stop_at_tool_names=[...])`: 指定したいずれかのツールが呼び出されたら停止し、その出力を最終応答として使用します。
227+
- `StopAtTools(stop_at_tool_names=[...])`: 指定したツールが呼び出された場合に停止し、その出力を最終応答として使用します。
228228

229229
```python
230230
from agents import Agent, Runner, function_tool
@@ -248,7 +248,7 @@ agent = Agent(
248248
)
249249
```
250250

251-
- `ToolsToFinalOutputFunction`: ツール結果を処理し、停止するか LLM を続行するかを判断するカスタム関数です
251+
- `ToolsToFinalOutputFunction`: ツール結果を処理し、停止するか LLM を継続するかを判断するカスタム関数です
252252

253253
```python
254254
from agents import Agent, Runner, function_tool, FunctionToolResult, RunContextWrapper
@@ -286,4 +286,4 @@ agent = Agent(
286286

287287
!!! note
288288

289-
無限ループを防ぐため、フレームワークはツール呼び出し後に `tool_choice` を自動的に "auto" にリセットします。この挙動は [`agent.reset_tool_choice`][agents.agent.Agent.reset_tool_choice] で設定可能です。無限ループは、ツール結果が LLM に送られ、`tool_choice` のために LLM が再びツール呼び出しを生成し続けることによって発生します
289+
無限ループを防ぐため、フレームワークはツール呼び出し後に `tool_choice` を自動的に "auto" にリセットします。この動作は [`agent.reset_tool_choice`][agents.agent.Agent.reset_tool_choice] で設定できます。無限ループは、ツール結果が LLM に送られ、`tool_choice` により LLM がさらに別のツール呼び出しを生成し続けるために発生します

0 commit comments

Comments
 (0)