Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ flowchart TB
Decided, not yet implemented.
- Plugins are runtime-scoped harness resources: a harness declares `plugins:` as one list of directories in its own repository (same trust and fetch path as skills), and each entry's format decides which runtime loads it — a `plugin.json` bundle is Claude Code's, a directory pi's `-e` loader resolves is uploaded and loaded after a tree-hash preflight computed from the host copy. Each runtime names and skips the entries in the other format, so the list survives a runtime switch. Because `--no-extensions` plus explicit `-e` closes the set of code that can register tools, no per-tool declaration is needed ([ADR 0094](ADRs/0094-pi-extensions-are-harness-resources.md)).
- Decided, not yet implemented: extend the runner-owned native Codex child
policy to V2 alongside the 0.166.0 bump. Bootstrap requires the `Agent` tool,
policy to V2. Bootstrap requires the `Agent` tool,
harness security and a direct-route parent selecting V1 or V2 in the bundled
model catalog (absent means V1); other parents keep delegation off. The
runner binds child models and effort, registers roles and admits only
Expand Down
4 changes: 3 additions & 1 deletion docs/contributing/runtime-implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -1624,6 +1624,8 @@ Two artefacts of the run are worth knowing about:
| JSONL event structs, rollout line types and rollout file naming | the stream parser and transcript extraction; a rollout line type missing from `codexRolloutEnvelopes` discards the whole transcript | `codex-rs/exec/src/exec_events.rs`, `codex-rs/history/src/rollout_payload.rs` (`RolloutItemWire`), `codex-rs/thread-store/src/local/helpers.rs` |
| Stderr warning markers (`dropping in-process server notification (queue full)`, `thread/items/list failed during turn completion`, `thread/items/list returned a repeated cursor during turn completion`, and the prefix `thread/read failed while backfilling turn items`), their log targets and levels, and the `RUST_LOG` filter (`error,opentelemetry_sdk=off,opentelemetry_otlp=off,codex_exec=warn,codex_app_server::in_process=warn`; `info` with debug) | `codexStderrDrops` and the debug-log counts match these literals; changed text, targets, levels or filter semantics can silently stop the dropped-notification and failed-backfill warnings | `codex-rs/exec/src/lib.rs` (backfill `warn!` calls, `EXEC_DEFAULT_LOG_FILTER`), `codex-rs/app-server/src/in_process.rs` (drop `warn!` call) |
| The multi-agent tool names (`multi_agent_v1*`, `collaboration*`, the bare V1 `spawn_agent`), the block contract (exit 2 with non-empty stderr blocks; a timeout kills the handler and lets the call through), `agent_id` and `agent_type` in a child's payload, the spawn arguments, and what a child start rereads (`hooks.json` and the role file) | the spawn guard's matcher, pass-through set, policy, digest set and deadline rest on them; a renamed tool is denied (loud), but a payload without `agent_id` or `agent_type`, a new model or effort argument, a changed block contract or a child that rereads another file turns a deny into a pass | `codex-rs/core/src/tools/handlers/multi_agents_spec.rs`, `codex-rs/core/src/tools/registry.rs` (`function_hook_tool_name`), `codex-rs/hooks/src/engine/command_runner.rs` (the timeout branch), `codex-rs/core/src/agent/role.rs` (the role file, read at spawn) |
| The bundled catalog's `multi_agent_version`, `default_reasoning_level` and `supported_reasoning_levels` entries, the version codex supplies to an entry that carries none, and the floor model (`codex debug models --bundled`; at 0.166.0 `gpt-5.6-luna` is the listed model that selects `v1` and defaults to `medium`, and `gpt-5.5` carries no version, which the `multi_agent` feature, on by default, resolves to V1, and lists `low` to `xhigh`) | part two of the delegation gate, the child-model floor and the child-effort check rest on them: the floor must stay listed, or every delegating agent without `subagents.default` or `FULLSEND_CODEX_SUBAGENT_MODEL` fails Bootstrap, while the floor's own collaboration version does not matter for children (a child runs under its parent's; moving luna to V2 only stops luna parents from delegating); a bump that turns `multi_agent` off by default, or gives the null entry a version, changes which parents delegate; a changed level set changes which run efforts Bootstrap accepts; and the fixture `internal/runtime/testdata/codex/models-bundled-0.166.0.json` must be regenerated, never edited | `codex-rs/models-manager/models.json` in the bumped tag; regenerate the fixture with the one-liner in `codex_personas_test.go`'s `TestCodexCatalog` comment and run `go test ./internal/runtime/ -run 'TestCodexCatalog\|TestCodexParentResolvesV1\|TestResolveCodexChildModels_Effort'` |
| The bundled catalog's `multi_agent_version`, `default_reasoning_level` and `supported_reasoning_levels` entries, the version codex supplies to an entry that carries none, and the floor model (`codex debug models --bundled`; at 0.166.0 `gpt-5.6-luna` is the listed model that selects `v1` and defaults to `medium`, and `gpt-5.5` carries no version, which the `multi_agent` feature, on by default, resolves to V1, and lists `low` to `xhigh`) | part two of the delegation gate, the child-model floor and the child-effort check rest on them: the floor must stay listed, or every delegating agent without `subagents.default` or `FULLSEND_CODEX_SUBAGENT_MODEL` fails Bootstrap, while the floor's own collaboration version does not matter for children (a child runs under its parent's; moving luna to V2 only stops luna parents from delegating); a bump that turns `multi_agent` off by default, or gives the null entry a version, changes which parents delegate; a changed level set changes which run efforts Bootstrap accepts; and the fixture `internal/runtime/testdata/codex/models-bundled-0.166.0.json` must be regenerated, never edited | `codex-rs/models-manager/models.json` in the bumped tag; regenerate the fixture with the one-liner in `codex_personas_test.go`'s `TestCodexCatalog` comment and run `go test ./internal/runtime/ -run 'TestCodexCatalog\|TestCodexParentCollabVersion\|TestResolveCodexChildModels_Effort'` |
| The `[agents]` keys codex reads (`enabled`, `max_concurrent_threads_per_session`, `max_depth`, `default_subagent_model`, `default_subagent_reasoning_effort`, and `[agents.<name>]` `description` and `config_file`) and the order of the child path: with no model argument a child takes `default_subagent_model` and, with no effort argument, `default_subagent_reasoning_effort`, else that model's catalog default; a role file applies after and its effort is checked against its own model | `codexAgentsBlock` writes the keys and Bootstrap checks the child efforts on that order; a renamed key or a changed order silently changes every child's model or effort | `codex-rs/config/src/config_toml.rs` (`AgentsToml`), `codex-rs/core/src/config/mod.rs`, `codex-rs/core/src/agent/child_config.rs` (`apply_requested_spawn_agent_model_overrides`, `apply_spawn_agent_role`), `codex-rs/core/src/agent/role.rs` |
| What writes a rollout under the sessions directory in an exec run, rollout naming and the date layout, creation at a child's first recorded item, a PreToolUse block returning before the tool handler, and spawn-slot reservation before thread creation | the disk side of the admission cross-check (the four facts are in `internal/runtime/testdata/codex/README.md`) | `codex-rs/core/src/tools/registry.rs`, `codex-rs/core/src/agent/control/spawn.rs`, `codex-rs/rollout/src/rollout_file_name.rs`, `codex-rs/features/src/lib.rs` (the memories default) |
| The `enabled`, `disable_direct_message`, `expose_spawn_agent_model_overrides` and `max_concurrent_threads_per_session` keys of the `[features.multi_agent_v2]` table (codex parses it with `deny_unknown_fields`) and how codex derives the V2 child cap: the table's own key, else `[agents] max_concurrent_threads_per_session + 1`, else 4, minus one at reservation | ADR 0159 keeps the four-child cap under `[agents]`; once V2 parents delegate, a changed derivation silently gives a V2 parent three or five children, and once the runner renders the table, a renamed table key fails every run's config | `codex-rs/core/src/config/mod.rs` (`resolve_multi_agent_v2_config`, `effective_agent_max_threads`), `codex-rs/features/src/feature_configs.rs` (`MultiAgentV2ConfigToml`), codex's test `multi_agent_v2_uses_agents_max_concurrent_threads_per_session` in `codex-rs/core/src/config/config_tests.rs` |
| The V2 child-result delivery path: `notify_parent_of_terminal_turn` queues a terminal result to the parent, `record_inter_agent_communication` records it, and it reaches the parent's next model request as an `agent_message` item; at 0.166.0 no hook event, config key or app-server method reachable from `codex exec` withholds it before codex records it, and `SubagentStop` treats a deny as a request for the child to continue | ADR 0159 decision 4 requires every V2 child result to pass the ADR 0100 PostToolUse chain before it enters the parent's context, and Bootstrap declines V2 parents until a checked delivery path for those results is implemented and verified live; re-check on every bump whether codex offers a synchronous, fail-closed gate on this path | `codex-rs/core/src/agent/control/completion.rs`, `codex-rs/core/src/session/handlers.rs`, `codex-rs/core/src/hook_runtime.rs` (`inspect_pending_input`), `codex-rs/core/src/session/mod.rs` (`record_inter_agent_communication`), `codex-rs/hooks/src/events/stop.rs` |
19 changes: 13 additions & 6 deletions docs/runtimes/codex.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,18 @@ Delegation needs a parent model Codex resolves to collaboration V1: its entry in
the pinned CLI's bundled catalog selects V1, or carries no version and Codex's
`multi_agent` feature, on by default, supplies V1 (on the current pin
`gpt-5.6-luna`, `gpt-5.5` and a hidden catalog entry). Bootstrap reads that
catalog; for any other parent, a V2 model such as `gpt-5.6-sol` or a model the
catalog does not list included, it keeps Codex's multi-agent tools off, prints
one line saying why (`sub-agents: parent model "gpt-5.6-sol" selects
collaboration "v2"; native sub-agents need a parent Codex resolves to
collaboration V1, running in one context`), and the agent runs in one context.
catalog. [ADR 0159](../ADRs/0159-codex-subagents-on-collaboration-v2.md) admits
a parent that selects V2 (`gpt-5.6-sol`, `gpt-6.1-sol` and most of the current
catalog). Such a parent still runs in one context, because its child results
would reach it outside the PostToolUse chain. Bootstrap prints one line saying
so (`sub-agents: parent model "gpt-5.6-sol" selects collaboration "v2"; V2
delegation is off until its child-result delivery path is verified live
(ADR 0159), running in one context`). A model the catalog does not list runs
in one context the same way (`sub-agents: parent model "gpt-5.6-nova" is not
in the bundled catalog of the pinned codex, running in one context`), and so
does an entry whose `multi_agent_version` is `disabled`, with a line that says
so. An entry with any other collaboration value runs in one context the same
way, with a line that names the value.
A `gateway/` parent runs in one context the same way, whatever its id
(`sub-agents: parent model "gateway/gpt-5.6-luna" takes the inference gateway
route, where native sub-agents are not supported, running in one context`):
Expand All @@ -233,7 +240,7 @@ serve, and native children have not been run on that route.
| Artifacts | `output.jsonl` (the `codex exec --json` stream), `transcripts/<agent>-<rollout>.jsonl` for the root thread and `transcripts/<agent>-sub<seq>-<role>.jsonl` for each native child (`generic` for the `default` role, which codex records as no role when the spawn names no `agent_type`; `explore` keeps its name), `metrics.json` with `runtime: codex` (and `per_model_usage` for a delegating agent), plus `codex-debug.log` with `--debug`. Only uncompressed rollouts are extracted — codex compresses older sessions, so a `.jsonl.zst` is never the run's own transcript. The agent's final message is in the stream; `--output-last-message` also drops it in the runner-owned config directory inside the sandbox, which is a convenience when inspecting a kept sandbox rather than a downloaded artifact |
| Sub-agents | Native Codex children for an agent whose tools include `Agent` (or that declares no `tools:`), with harness security on, on a parent model Codex resolves to collaboration V1 on the direct route, under a runner-owned policy: registered roles only, fresh context, depth one, four open; see [Sub-agents](#sub-agents) |
| Extra knobs | `FULLSEND_CODEX_MODEL` (the runner-side model default for codex runs; see [Models](#models)), `FULLSEND_CODEX_SUBAGENT_MODEL` (the run-level child model; the GitHub fleet workflows do not pass it; see [Child models](#child-models)) |
| Not supported | `plugins:`, fallback chains, non-OpenAI providers (other than through a Responses-capable inference gateway), Chat Completions or Messages on a gateway, delegation from a parent model on collaboration V2 or from a `gateway/` parent (see [Sub-agents](#sub-agents)) |
| Not supported | `plugins:`, fallback chains, non-OpenAI providers (other than through a Responses-capable inference gateway), Chat Completions or Messages on a gateway, delegation from a parent model on collaboration V2 (ADR 0159 admits it; off until its child-result delivery path is implemented and verified live) or from a `gateway/` parent (see [Sub-agents](#sub-agents)) |

Cost is recorded as **zero** in `metrics.json` on codex: the
`codex exec --json` stream carries no cost field, so the value stays `0`.
Expand Down
29 changes: 17 additions & 12 deletions internal/runtime/codex_bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,22 +173,27 @@ func (r CodexRuntime) Bootstrap(input BootstrapInput) error {
if !ok || repoInput.RepoDir() == "" {
return fmt.Errorf("codex bootstrap: the target repository's sandbox path is required")
}
// ADR 0126 gate. Part one: tools include Agent and harness security is
// on. Part two needs the pinned CLI's catalog: codex must resolve the
// model Run will launch to collaboration V1, the only version whose spawn
// tool the guard admits (its entry selects V1, or carries no version and
// codex's multi_agent feature, on by default, supplies V1). A V2,
// unlisted or gateway/ parent keeps the multi-agent tools off and runs in
// one context, as an agent that does not delegate does.
// Delegation gate (ADR 0126, extended by ADR 0159). Part one: tools
// include Agent and harness security is on. Part two needs the pinned
// CLI's catalog: the gate takes the collaboration version from the entry
// of the model Run will launch, V1 when the entry selects V1 or carries
// no version (codex's multi_agent feature, on by default, supplies V1)
// and V2 when it selects V2. Only a V1 parent delegates: the gate reads
// the version, not the reason. Only the change that renders the V2
// config and the checked child-result delivery path widens the gate to V2,
// once that path is verified live (ADR 0159 decision 4). A V2, disabled,
// unknown-version, unlisted or gateway/ parent is declined with its own
// explanation, keeps the multi-agent tools off and runs in one context,
// as an agent that does not delegate does.
_, securityOn := input.(SandboxHooksBootstrap)
var catalog codexCatalog
delegating := false
if codexDelegates(def, securityOn) {
if catalog, err = codexPreflightCatalog(sandboxName); err != nil {
return err
}
var reason string
if delegating, reason = codexParentResolvesV1(catalog, input.ParentModel(), def.Model); !delegating {
version, reason := codexParentCollabVersion(catalog, input.ParentModel(), def.Model)
if delegating = version == "v1"; !delegating {
fmt.Fprintf(os.Stderr, "sub-agents: %s, running in one context\n", reason)
}
}
Expand Down Expand Up @@ -393,9 +398,9 @@ func codexDeveloperInstructions(agentName string, def *piAgentDef, roles []codex
// codexNoSubagentNote makes the absence of a sub-agent roster explicit so
// skills written for Claude Code's Agent tool (pr-review, retro) take their
// single-context path deliberately instead of recording a failed dispatch.
// Every agent the ADR 0126 gate declines gets it (tools without Agent,
// security off, a V2 or unlisted parent); a delegating agent gets
// codexSubagentNote.
// Every agent the delegation gate declines gets it (tools without Agent,
// security off, or a V2, disabled, unknown-version, unlisted or gateway/
// parent); a delegating agent gets codexSubagentNote.
const codexNoSubagentNote = "\n## Runtime note\n\n" +
"This agent runs on the codex runtime (FULLSEND_RUNTIME=codex). No fullsend sub-agent " +
"roster is available. When a skill says to dispatch sub-agents, execute each sub-agent " +
Expand Down
Loading
Loading