You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tools.md
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -503,6 +503,8 @@ Disabled tools are completely hidden from the LLM at runtime, making this useful
503
503
504
504
The `codex_tool` wraps the Codex CLI so an agent can run workspace-scoped tasks (shell, file edits, MCP tools)
505
505
during a tool call. This surface is experimental and may change.
506
+
By default, the tool name is `codex`. If you set a custom name, it must be `codex` or start with `codex_`.
507
+
When an agent includes multiple Codex tools, each must use a unique name (including vs non-Codex tools).
506
508
507
509
```python
508
510
from agents import Agent
@@ -542,11 +544,13 @@ What to know:
542
544
- Thread defaults: configure `default_thread_options` for `model_reasoning_effort`, `web_search_mode` (preferred over legacy `web_search_enabled`), `approval_policy`, and `additional_directories`.
543
545
- Turn defaults: configure `default_turn_options` for `idle_timeout_seconds` and cancellation `signal`.
544
546
- Safety: pair `sandbox_mode` with `working_directory`; set `skip_git_repo_check=True` outside Git repos.
545
-
- Behavior: `persist_session=True` reuses a single Codex thread and returns its `thread_id`.
- Run-context thread persistence: `use_run_context_thread_id=True` stores and reuses `thread_id` in run context, across runs that share that context. This requires a mutable run context (for example, `dict` or a writable object field).
548
+
- Run-context key defaults: the stored key defaults to `codex_thread_id` for `name="codex"`, or `codex_thread_id_<suffix>` for `name="codex_<suffix>"`. Set `run_context_thread_id_key` to override.
549
+
- Thread ID precedence: per-call `thread_id` input takes priority, then run-context `thread_id` (if enabled), then the configured `thread_id` option.
550
+
- Streaming: `on_stream` receives thread/turn lifecycle events and item events (`reasoning`, `command_execution`, `mcp_tool_call`, `file_change`, `web_search`, `todo_list`, and `error` item updates).
547
551
- Outputs: results include `response`, `usage`, and `thread_id`; usage is added to `RunContextWrapper.usage`.
548
552
- Structure: `output_schema` enforces structured Codex responses when you need typed outputs.
549
-
- See `examples/tools/codex.py`for a complete runnable sample.
553
+
- See `examples/tools/codex.py`and `examples/tools/codex_same_thread.py` for complete runnable samples.
0 commit comments