Skip to content

Commit 4d56548

Browse files
authored
Merge branch 'openai:main' into main
2 parents 34b8ca7 + b09d37d commit 4d56548

32 files changed

+694
-608
lines changed

.github/codex/home/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
model = "o3"

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Attempt to solve the reported issue.
2+
3+
If a code change is required, create a new branch, commit the fix, and open a pull request that resolves the problem.
4+
5+
Here is the original GitHub issue that triggered this run:
6+
7+
### {CODEX_ACTION_ISSUE_TITLE}
8+
9+
{CODEX_ACTION_ISSUE_BODY}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Review this PR and respond with a very concise final message, formatted in Markdown.
2+
3+
There should be a summary of the changes (1-2 sentences) and a few bullet points if necessary.
4+
5+
Then provide the **review** (1-2 sentences plus bullet points, friendly tone).
6+
7+
{CODEX_ACTION_GITHUB_EVENT_PATH} contains the JSON that triggered this GitHub workflow. It contains the `base` and `head` refs that define this PR. Both refs are available locally.

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Troubleshoot whether the reported issue is valid.
2+
3+
Provide a concise and respectful comment summarizing the findings.
4+
5+
### {CODEX_ACTION_ISSUE_TITLE}
6+
7+
{CODEX_ACTION_ISSUE_BODY}

.github/workflows/codex.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Codex
2+
3+
on:
4+
issues:
5+
types: [opened, labeled]
6+
pull_request:
7+
branches: [main]
8+
types: [labeled]
9+
10+
jobs:
11+
codex:
12+
# This `if` check provides complex filtering logic to avoid running Codex
13+
# on every PR. Admittedly, one thing this does not verify is whether the
14+
# sender has write access to the repo: that must be done as part of a
15+
# runtime step.
16+
#
17+
# Note the label values should match the ones in the .github/codex/labels
18+
# folder.
19+
if: |
20+
(github.event_name == 'issues' && (
21+
(github.event.action == 'labeled' && (github.event.label.name == 'codex-attempt' || github.event.label.name == 'codex-triage'))
22+
)) ||
23+
(github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == 'codex-review')
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: write # can push or create branches
27+
issues: write # for comments + labels on issues/PRs
28+
pull-requests: write # for PR comments/labels
29+
steps:
30+
# TODO: Consider adding an optional mode (--dry-run?) to actions/codex
31+
# that verifies whether Codex should actually be run for this event.
32+
# (For example, it may be rejected because the sender does not have
33+
# write access to the repo.) The benefit would be two-fold:
34+
# 1. As the first step of this job, it gives us a chance to add a reaction
35+
# or comment to the PR/issue ASAP to "ack" the request.
36+
# 2. It saves resources by skipping the clone and setup steps below if
37+
# Codex is not going to run.
38+
39+
- name: Checkout repository
40+
uses: actions/checkout@v4
41+
42+
# We install the dependencies like we would for an ordinary CI job,
43+
# particularly because Codex will not have network access to install
44+
# these dependencies.
45+
- name: Setup uv
46+
uses: astral-sh/setup-uv@v5
47+
with:
48+
enable-cache: true
49+
50+
- name: Install dependencies
51+
run: make sync
52+
53+
# Note it is possible that the `verify` step internal to Run Codex will
54+
# fail, in which case the work to setup the repo was worthless :(
55+
- name: Run Codex
56+
uses: openai/codex/.github/actions/codex@main
57+
with:
58+
openai_api_key: ${{ secrets.PROD_OPENAI_API_KEY }}
59+
github_token: ${{ secrets.GITHUB_TOKEN }}
60+
codex_home: ./.github/codex/home

docs/ja/agents.md

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

7-
エージェントはアプリの中心的な構成要素です。エージェントは、instructions と tools で設定された大規模言語モデル ( LLM ) です。
7+
エージェントはアプリケーションの主要な構成要素です。エージェントとは、instructions と tools で構成された大規模言語モデル (LLM) です。
88

99
## 基本設定
1010

1111
エージェントでよく設定するプロパティは次のとおりです。
1212

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

1818
```python
1919
from agents import Agent, ModelSettings, function_tool
@@ -32,7 +32,7 @@ agent = Agent(
3232

3333
## コンテキスト
3434

35-
エージェントは汎用的な `context` 型を取ります。コンテキストは依存性注入用のツールで、あなたが作成して `Runner.run()` に渡すオブジェクトです。これはすべてのエージェント、tool、handoff などに渡され、実行時に必要な依存関係や状態を格納する入れ物として機能します。コンテキストには任意の Python オブジェクトを渡せます。
35+
エージェントは汎用的に `context` 型を取り込みます。コンテキストは dependency-injection (依存性注入) 用のオブジェクトで、あなたが作成して `Runner.run()` に渡すことで、すべてのエージェント、tool、ハンドオフなどに共有されます。実行中の依存関係や状態をまとめて保持する入れ物として機能し、任意の Python オブジェクトを渡せます。
3636

3737
```python
3838
@dataclass
@@ -50,7 +50,7 @@ agent = Agent[UserContext](
5050

5151
## 出力タイプ
5252

53-
デフォルトでは、エージェントはプレーンテキストつまり `str` を出力します。特定の型で出力させたい場合は、`output_type` パラメーターを使用します。一般的には [Pydantic](https://docs.pydantic.dev/) オブジェクトを使うことが多いですが、Pydantic の [TypeAdapter](https://docs.pydantic.dev/latest/api/type_adapter/) でラップできる型であれば何でもサポートされています。たとえば dataclass、list、TypedDict などです
53+
デフォルトでは、エージェントはプレーンテキスト (つまり `str`) を出力します。特定の型で出力させたい場合は、`output_type` パラメーターを使用してください。よく使われる選択肢として [Pydantic](https://docs.pydantic.dev/) オブジェクトがありますが、Pydantic の [TypeAdapter](https://docs.pydantic.dev/latest/api/type_adapter/) でラップできる型であれば、dataclass、list、TypedDict など何でも対応しています
5454

5555
```python
5656
from pydantic import BaseModel
@@ -71,11 +71,11 @@ agent = Agent(
7171

7272
!!! note
7373

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

7676
## ハンドオフ
7777

78-
ハンドオフは、エージェントが委譲できるサブエージェントです。ハンドオフのリストを渡すと、エージェントは関連性がある場合にそれらへ委譲できます。これは、単一タスクに特化したモジュール型エージェントを編成する強力なパターンです。詳細は [ハンドオフ](handoffs.md) のドキュメントをご覧ください。
78+
ハンドオフは、エージェントが委任できるサブエージェントです。ハンドオフのリストを渡すと、エージェントは必要に応じてそれらに委任できます。これは、単一タスクに特化したモジュール化されたエージェントをオーケストレーションする強力なパターンです。詳しくは [ハンドオフ](handoffs.md) のドキュメントをご覧ください。
7979

8080
```python
8181
from agents import Agent
@@ -96,7 +96,7 @@ triage_agent = Agent(
9696

9797
## 動的 instructions
9898

99-
通常はエージェント作成時に instructions を渡しますが、関数を通じて動的に instructions を提供することもできます。この関数はエージェントとコンテキストを受け取り、プロンプトを返す必要があります。同期関数でも `async` 関数でも利用可能です
99+
多くの場合、エージェント作成時に instructions を渡せますが、関数を介して動的に instructions を生成することも可能です。その関数は agent と context を受け取り、プロンプトを返さなければなりません。同期関数と `async` 関数のどちらも利用できます
100100

101101
```python
102102
def dynamic_instructions(
@@ -113,15 +113,15 @@ agent = Agent[UserContext](
113113

114114
## ライフサイクルイベント (hooks)
115115

116-
エージェントのライフサイクルを監視したい場合があります。たとえば、イベントをログに記録したり、特定のイベント発生時にデータを事前取得したりするケースです`hooks` プロパティを使うことでエージェントのライフサイクルにフックを追加できます[`AgentHooks`][agents.lifecycle.AgentHooks] クラスを継承し、必要なメソッドをオーバーライドしてください
116+
エージェントのライフサイクルを監視したい場合があります。たとえば、イベントをログに記録したり、特定のイベント発生時にデータを事前取得したりできます`hooks` プロパティを使ってエージェントのライフサイクルにフックできます[`AgentHooks`][agents.lifecycle.AgentHooks] クラスを継承し、関心のあるメソッドをオーバーライドしてください
117117

118118
## ガードレール
119119

120-
ガードレールを使うと、エージェントの実行と並行してユーザー入力に対するチェック/バリデーションを実行できます。たとえば、ユーザー入力の関連性をフィルタリングすることが可能です。詳細は [guardrails](guardrails.md) のドキュメントをご参照ください
120+
ガードレールを利用すると、エージェントの実行と並行してユーザー入力のチェックやバリデーションを行えます。たとえば、ユーザー入力の関連性をスクリーニングできます。詳細は [ガードレール](guardrails.md) のドキュメントをご覧ください
121121

122-
## エージェントのクローンとコピー
122+
## エージェントのクローン/コピー
123123

124-
エージェントの `clone()` メソッドを使用すると、エージェントを複製し、必要に応じて任意のプロパティを変更できます。
124+
エージェントの `clone()` メソッドを使うと、既存のエージェントを複製し、必要に応じて任意のプロパティを変更できます。
125125

126126
```python
127127
pirate_agent = Agent(
@@ -138,15 +138,15 @@ robot_agent = pirate_agent.clone(
138138

139139
## ツール使用の強制
140140

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

143-
1. `auto` : LLM がツールを使用するかどうかを判断します
144-
2. `required` : LLM にツールの使用を必須とします (どのツールを使うかは LLM が判断)。
145-
3. `none` : LLM にツールを使用しないことを要求します
146-
4. 特定の文字列 (例: `my_tool`) を設定すると、そのツールの使用を必須とします
143+
1. `auto`LLM がツールを使うかどうかを判断します
144+
2. `required`LLM にツール使用を必須とします (ただしどのツールを使うかは賢く選択します)。
145+
3. `none`LLM にツールを使用しないことを必須とします
146+
4. 具体的な文字列 (例: `my_tool`) を設定すると、LLM はそのツールを必ず使用します
147147

148148
!!! note
149149

150-
無限ループを防ぐため、フレームワークはツール呼び出し後に `tool_choice` を自動的に "auto" にリセットします。この挙動は [`agent.reset_tool_choice`][agents.agent.Agent.reset_tool_choice] で設定できます。無限ループが発生するのは、ツールの結果が LLM へ送られ、`tool_choice` により再びツール呼び出しが生成されるというサイクルが続くためです
150+
無限ループを防ぐため、フレームワークはツール呼び出し後に自動で `tool_choice` "auto" にリセットします。この挙動は [`agent.reset_tool_choice`][agents.agent.Agent.reset_tool_choice] で設定可能です。ツールの実行結果が再び LLM に送られ、`tool_choice` の設定により新たなツール呼び出しが発生し続けるのが無限ループの原因です
151151

152-
ツール呼び出し後に自動モードへ移行せず完全に処理を終了したい場合は、[`Agent.tool_use_behavior="stop_on_first_tool"`] を設定してください。これにより、ツールの出力をそのまま最終応答として使用し、追加の LLM 処理を行いません。
152+
ツール呼び出し後に自動モードで継続せず完全に停止したい場合は、[`Agent.tool_use_behavior="stop_on_first_tool"`] を設定してください。ツールの出力をそのまま最終応答として使用し、追加の LLM 処理を行いません。

0 commit comments

Comments
 (0)