How each harness starts and configures subagents, what they can see and change, which lifecycle hooks run, and how their transcripts are saved and read.
Worktrees: creation, setup, integration and cleanup
Starting one
| Question | Codex CLIchecked at 0.162.1 |
|---|---|
| Is there one, and how does it start | Yes, and they are on by default ( Set |
| Built-in subagents | |
| Define your own | Add one standalone TOML file per agent under Malformed files are skipped with a startup warning rather than failing the session. |
| What a definition can set | Partly Besides There is no per-agent tool allowlist or memory setting; tools can only be removed through the |
While it runs
| Question | Codex CLIchecked at 0.162.1 |
|---|---|
| What it sees, and what comes back | By default a subagent starts fresh, with only the task message the main agent writes plus the usual project instructions and skills. If the main agent sets 0.162.0 removed partial-history forks: a fork now copies either all of the history or none of it. |
| Several at once | Yes. Several subagents can run at once, capped by The docs recommend running read-heavy work in parallel and warn that parallel edits can conflict. |
| Keep working while it runs | Partly
Separate background chats (desktop Worktree mode, |
| Your checkout or its own copy | Not supported Subagents work directly in the parent session's checkout; they get no worktree or copy of their own, so there is nothing to merge. Their edits land immediately, and parallel writers can collide. The built-in |
| Its permissions | Subagents inherit the parent turn's current sandbox and approval settings, including changes made with A definition can only narrow capabilities, e.g. |
| Subagents of subagents | Partly Nesting is controlled by
|
Watching and handing off
| Question | Codex CLIchecked at 0.162.1 |
|---|---|
| Watch, steer or stop one | In the CLI, type
|
| Hand work to a cloud agent | Partly Subagents always run locally; the main agent cannot spawn a cloud subagent. You can hand work to Codex Cloud yourself with
|
Notes and sources
Codex CLI, 14 sources
- Subagents inherit the parent sandbox and permission mode unless a custom agent overrides supported session settings.
- The orchestrating turn waits for requested results, but users can switch to, steer, stop, and close subagent threads; no detached-dispatch flag is documented.
- Custom sandbox policy is execution containment, not checkout isolation.
- Concurrency is bounded by agents.max_concurrent_threads_per_session, and parallel write-heavy work can conflict in the shared checkout.
Your checkout or its own copy, 4
Its permissions, 1
Subagents of subagents, 4
Watch, steer or stop one, 4
Hand work to a cloud agent, 3
Subagent lifecycle hooks
Recorded start and stop events, with their control semantics and availability caveats. A dash means no event is recorded here. General session or tool events do not establish a dedicated subagent hook.
Which moments a hook can attach to, and what it can do there. Event names link to each harness’s documentation. “Block”, “deny” and “modify” change what the agent does; “observe only” can watch but not intervene. Where hook files live is on the Locations page.
| Moment | Codex CLIHook commands |
|---|---|
| Hook types |
|
| Subagents | |
| Subagent starts | SubagentStartadd context |
| Subagent finishes | SubagentStopqueue follow-up, stop |
Notes and sources
Codex CLI
- Matching hooks are launched concurrently, so one hook cannot stop another from starting.
- Project hooks load only in a trusted project, and every non-managed hook must also be reviewed and trusted by its hash.
- Background (async) hooks cannot block, approve or rewrite the triggering operation.
- OpenAI describes tool hooks as a guardrail, not a complete enforcement boundary.
- Since 0.165.0 an execution environment can bring its own managed hooks from its requirements; they are always required, run on that environment's executor and appear as
<environment:ID>/requirements.toml. In 0.166.0, App Serverhooks/listwith athreadIdincludes them and marks each withenvironmentId. The App Server's own environment selection supplies none, so these come only from an environment owner that provides its configuration. - 0.167.0 managed prompt-user checkpoint, traced at 0.167.2: requirements.toml prefix rules can require fresh human approval for every execution attempt. Hooks and automatic review cannot satisfy it; approval cache/rule amendments do not replace it. A never/rejecting approval policy or enforced automatic-only review rejects the command instead. This is a managed-rule decision, not a fourth approval_policy mode. No runtime probe.
- November 16 plugin-format audit at Codex 0.169.0: the local loader parses OpenAI overlay hooks but explicitly skips hook sources for Agent Plugins packages; legacy compatibility packages use the hook loader. Executor-owned inline hooks have a separate cleanup admission policy. This updates the package-loading boundary without redating the older event/handler traces; no runtime probe ran.
- Codex hooks, Documentation, checked 2026-10-15
- Codex CLI 0.162.1 hook event names, Source code, checked 2026-10-14
- Codex CLI 0.162.1 hook output parsing, Source code, checked 2026-10-14
- Codex CLI 0.162.1 hook handler discovery, Source code, checked 2026-10-14
- Codex 0.166.0: codex-rs/core/src/tools/registry.rs, Source code, checked 2026-10-30
- Codex 0.166.0: codex-rs/core/src/tools/registry.rs, Source code, checked 2026-10-30
- Codex 0.166.0: codex-rs/core/src/tools/handlers/unified_exec/exec_command.rs, Source code, checked 2026-10-30
- Codex 0.166.0: codex-rs/hooks/src/events/common.rs, Source code, checked 2026-10-30
- Codex 0.166.0: codex-rs/hooks/src/events/pre_tool_use.rs, Source code, checked 2026-10-30
- Codex 0.166.0: codex-rs/hooks/src/events/permission_request.rs, Source code, checked 2026-10-30
- Codex 0.166.0: codex-rs/hooks/src/events/post_tool_use.rs, Source code, checked 2026-10-30
- Codex 0.166.0: codex-rs/protocol/src/environment.rs, Source code, checked 2026-10-30
- Codex 0.166.0: codex-rs/core/src/hook_environment_executor.rs, Source code, checked 2026-10-30
- Codex 0.166.0: codex-rs/hooks/src/engine/discovery.rs, Source code, checked 2026-10-30
- Codex 0.166.0: codex-rs/core/src/codex_thread.rs, Source code, checked 2026-10-30
- Codex 0.166.0: codex-rs/app-server-protocol/src/protocol/v2/plugin.rs, Source code, checked 2026-10-30
- Codex 0.166.0: codex-rs/app-server-protocol/src/protocol/v2/plugin.rs, Source code, checked 2026-10-30
- Codex 0.166.0: codex-rs/app-server/src/request_processors.rs, Source code, checked 2026-10-30
- codex rust-v0.167.2: codex-rs/core/src/tools/approvals.rs, Source code, checked 2026-11-12
- codex rust-v0.167.2: codex-rs/core/src/tools/approvals.rs, Source code, checked 2026-11-12
- Plugin formats: codex loader, Source code, checked 2026-11-16
- Plugin formats: codex component defaults, Source code, checked 2026-11-16
- Plugin formats: codex executor hooks, Source code, checked 2026-11-16
Subagent transcripts
Child storage and parent links are described separately from the harness’s general session format. Internal and source-observed formats can change between versions; these records do not promise a stable external schema.
| Question | Codex CLIsource-observed; checked at 0.169.0 |
|---|---|
| Child transcripts and parent links | Each subagent gets its own rollout file in the same Ephemeral subagents are unsaved. Side-chat persistence is separate: temporary versus persisted attached chat depends on workspace, parent history and server capability. |
| Session file format | Partly LocalThreadStore persists JSONL with timestamp, optional ordinal, type, payload and optional response metadata. The wire includes dynamic_tools_updated as well as session_meta, response_item, event_msg, turn_context, compacted, token_usage_record, retained_context and other families. history_mode distinguishes legacy and paginated persistence. This internal artifact has no published compatibility promise; App Server protocol generation describes a separate wire interface. Cold files may be stored as |
| What is recorded | The local rollout preserves selected model items and display events, settings, compaction and lineage. Persistence depends on legacy/paginated mode; it is not a complete record of all runtime events. Paginated display command/MCP output can be truncated to 64 KiB. Dynamic-tool updates, file-backed audio references, retained evidence and moderation metadata are covered by the 0.169.0 detailed format audit. File IDs retain identities, not the referenced bytes or their future availability. Reasoning is stored as the model returns it, usually a summary plus encrypted content rather than raw chain of thought. Since 0.162.0, paginated history caps persisted command output at 64 KiB and truncates oversized MCP results. 2026-11-13 supplement, Codex rust-v0.167.2 at ce21072c90d32c40af7a55b60b2fb35c84a43a6a: assistant text can contain :codex-file-citation{path="…" purpose="source"}. This is inline message markup, not a new JSONL record or memory_citation field. The TUI assistant renderer interprets it; external transcript/App Server consumers need their own rendering. HTTPS paths are live-observed; the inspected TUI treats non-local paths as relative, so its destination logic is not a web-link contract. See docs/research/codex-file-citations.md and docs/research/evidence/codex-file-citations-2026-11-13.json. The original supplement did not refresh the full schema; the 2026-11-15 audit supplies the current local format pin. |
| Read transcripts from code | The supported interface is
|
| Session record structure | Codex CLI |
|---|---|
| Envelope fields | timestamp, ordinal, type, payload, metadata |
| Record discriminator | type |
| Identifiers and lineage | session_meta.payload.id (thread id), session_meta.payload.session_id, rollout_id (filename suffix), forked_from_id, forked_from_ordinal_exclusive, parent_thread_id, history_base, source.subagent.thread_spawn.parent_thread_id, agent_role, agent_nickname, agent_path, turn_id, response_id |
| Ordering | file-order-or-ordinal |
Notes and sources
Codex CLI, 38 sources
- Rollout JSONL is a harness-owned durable artifact, not a published compatibility API.
- Prompt history.jsonl is a different artifact; history.persistence controls only that file.
- 0.164.0 source refresh: resume lookup visits plain/compressed rollout filenames, and App Server restores persisted thread settings from turn context/settings events. Older format and storage claims retain their original source pins.
- Automatic-approval findings specifically audited at rust-v0.164.0 / 6aaac694803004a63c6f393d153c96d22521a6b9 (2026-10-26); that historical baseline is retained in the 2026-11-15 evidence manifest, which separately refreshes the current local format.
- 0.164.0 parent turn_context records preserve approval_policy and approvals_reviewer; the current writer fills approvals_reviewer, and persisted thread_settings_applied snapshots also carry it. This establishes the selected reviewer, not a per-action review outcome.
- GuardianAssessment and GuardianWarning are transient and excluded from local rollout persistence. Do not treat missing guardian_assessment records in the parent transcript as evidence that no review occurred.
- The registered reviewer creates sessions with session_meta.source = {internal: guardian} and thread_source = guardian_review. Non-ephemeral reviewer trunks use normal session persistence and can contain the reviewed action/context plus final JSON outcome, risk_level, user_authorization and rationale. Low-risk output can contain only outcome = allow; the parser supplies defaults.
- A reviewer session can serve several reviews. Busy/incompatible reviews use ephemeral forks; an ephemeral parent also propagates its setting. Thus not every review has a saved reviewer transcript. These are internal sessions, distinct from ordinary subagent.thread_spawn lineage.
- For live reviews capture App Server item/autoApprovalReview/started and item/autoApprovalReview/completed, correlating threadId, turnId, reviewId and targetItemId when present. They contain action and review status/risk/authorization/rationale, but are notifications, not durable transcript items; payload is marked unstable. codex exec --json drops unmatched notifications and is not this audit stream. See docs/research/automatic-approval.md.
- Persistence conclusions apply to the ordinary local rollout store; desktop presentation, custom/cloud stores and hosted retention are not established by this source audit. No live classifier or transcript-production probe was run.
- 2026-11-13 supplement, Codex rust-v0.167.2 at ce21072c90d32c40af7a55b60b2fb35c84a43a6a: assistant text can contain :codex-file-citation{path="…" purpose="source"}. This is inline message markup, not a new JSONL record or memory_citation field. The TUI assistant renderer interprets it; external transcript/App Server consumers need their own rendering. HTTPS paths are live-observed; the inspected TUI treats non-local paths as relative, so its destination logic is not a web-link contract. See docs/research/codex-file-citations.md and docs/research/evidence/codex-file-citations-2026-11-13.json. The original supplement did not refresh the full schema; the 2026-11-15 audit supplies the current local format pin.
- 2026-11-15 source refresh: rust-v0.169.0 at d32063f96c2dff1dc96af839b3952abb6acfeda4. Source inspection, not a harness runtime probe. Historical supplements keep their independent evidence and dates.
- Older user-facing resume/export/history instructions retain their dated documentation evidence; the 0.169.0 refresh audits the local storage writer, parser, reconstruction and host/provider boundary. It does not establish proprietary desktop behavior.
- At 0.169.0 the opt-in terminal workspace can persist attached side chats; temporary chats remain ephemeral. The same /side UI action does not imply one storage policy across configurations.
Child transcripts and parent links, 8
What is recorded, 15
Read transcripts from code, 14
- Codex App Server documentation: list
- Codex App Server documentation: read
- Codex App Server documentation: resume
- Codex App Server documentation: fork
- Codex App Server documentation: approvals
- Codex App Server documentation: stream
- Codex App Server documentation: cancel
- Codex documentation: connect the CLI terminal UI
- Codex documentation: App Server protocol