Skip to content
Closed
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
3 changes: 3 additions & 0 deletions docs/ADRs/0104-per-persona-model-resolution.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Date: 2026-09-05

Accepted

Codex-specific model precedence and protected native role dispatch are defined
in [ADR 0126](0126-runner-owned-codex-child-policy.md).
Comment on lines +20 to +21

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

5. An accepted decision edit lacks a callout 📘 Rule violation § Compliance

The PR adds a Codex-policy cross-reference to the already Accepted ADR 0104, but the PR description
does not identify ADR 0104 or summarize that edit. The description discusses the new ADR 0126, so a
reviewer of the accepted record is not explicitly told that the older record also changed.
Agent Prompt
## Issue description
The PR description does not identify the edit to accepted ADR 0104.

## Fix Focus Areas
- docs/ADRs/0104-per-persona-model-resolution.md[20-21]

## Recommended Fix
Add a PR-description note naming ADR 0104 and explaining that its Codex-specific policy now cross-references ADR 0126.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description now calls out the ADR 0104 cross-reference.


## Context

Sub-agent skills (pr-review, retro-analysis) dispatch children by passing a
Expand Down
73 changes: 73 additions & 0 deletions docs/ADRs/0126-runner-owned-codex-child-policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
title: "126. Runner-owned policy for native Codex children"
status: Accepted
relates_to:
- agent-architecture
- security-threat-model
topics:
- runtime
- sub-agents
- security
---

# 126. Runner-owned policy for native Codex children

Date: 2026-09-28

## Status

Accepted

## Context

Review and retrospective workflows need independent child contexts, selected
personas, bounded execution and attributable usage
([agent architecture](../problems/agent-architecture.md)). Codex provides native
children, but reads role configuration again when each child starts. Checking a
file only before the parent starts does not protect subsequent child dispatch.

[ADR 0104](0104-per-persona-model-resolution.md) makes model selection a runner
concern. Its Claude aliases and persona tool lists cannot be applied directly
to Codex. [ADR 0100](0100-codex-sandbox-hooks.md) translates the shared security
hooks; their wiring must also remain intact when native children load it.

## Decision

The runner provisions and protects the policy for native Codex children.
For an agent with the Agent tool, it registers skill personas plus generic and
Explore roles; other agents get no roles, as on Claude Code and pi. For Codex, model
precedence is an explicit persona mapping, `FULLSEND_CODEX_SUBAGENT_MODEL`,
`subagents.default`, then `gpt-5.6-luna`. Claude frontmatter models and tool
lists are reported as documentation only. Invalid or unavailable explicit
models never fall back to another model.

Before sourcing the sandbox environment or starting Codex, the runner applies
an inherited Linux Landlock write restriction. Role files, `CODEX_HOME`
configuration, hooks and their directory entries remain protected; exact
native state paths remain writable. The launcher closes inherited writable
descriptors and verifies authority files against runner-held hashes after
applying the restriction. A missing capability or changed policy fails the run.

Native configuration bounds open child IDs to four, including completed children
that have not been closed. A mandatory dispatch
hook rejects grandchildren, context inheritance, model overrides and resuming
any child, including when optional security scanning is disabled. Native
resume can replace a child's role policy with the parent's; a new task must
use a fresh spawn. Shared security hooks apply to parent and child tools.
Model metadata determines the native collaboration API: validation must cover
the selected model's lifecycle, not infer it from the CLI version alone.
The dispatch guard accepts only V1's explicit `fork_context: false` contract
and rejects V2-shaped arguments. A child model override does not select the
parent's collaboration API; a model-name allowlist is not a substitute for
enforcing the actual dispatch contract.

Native review and retro ship only as a paired runtime and companion release;
existing deployments keep their prior pins until they adopt the validated pair.

## Consequences

- Persona selection remains a workflow decision; models and dispatch constraints remain runner decisions.
- Codex requires a system Python outside the agent's write roots and Linux Landlock ABI 3 or newer inside its OpenShell sandbox, including for runs without children. Top-level `$HOME` entries that Bootstrap does not pre-create cannot be created during a run.
- Native state paths, role loading, hook inheritance and collaboration APIs require revalidation on CLI or model changes.
- Parent and child usage and transcripts are collected by native thread identity; incomplete evidence fails visibly, and unreported dollar cost remains unavailable.
- These restrictions protect the launched native hierarchy; tool hooks remain defense in depth within the outer sandbox, not a prohibition on every interpreter an agent can invoke.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[medium] cross-repo-coordination

Every runtime: codex run now requires Python, Landlock ABI 3+, and the native dispatch PreToolUse guard, including runs with no children (ADR 0126 consequences). There is no flag waiting on agents #1501/#1542. Companion instructions teach spawn shapes; Landlock/Python apply even if those PRs have not merged.

Suggested fix: Stage rollout (same release/tag as companion PRs, or a config flag) so existing runtime: codex repos are not broken by an asynchronous merge, or confirm none pin runtime: codex in production.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update in commits 0dfd9f9 / b668fee (validation recorded in 8e78100):

ADR 0126 now requires a coordinated runtime, sandbox image and immutable companion-instructions release after both PRs have the required checks and human approvals. The runtime release must wait for the approved companion revision; existing deployments retain prior pins until they can adopt the tested pair. The prerequisites apply even to nondelegating Codex runs, and the docs do not assume that no existing production deployment uses Codex. Merge/release authorization remains a maintainer gate.

6 changes: 6 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ flowchart TB
- The `fullsend run` runner delegates in-sandbox agent execution to a `runtime.Runtime` interface; production orgs default to Claude Code, with [pi](https://github.com/earendil-works/pi) available as an opt-in second runtime (`runtime: pi`, Claude-on-Vertex through the same WIF credential path) and [codex](https://github.com/openai/codex) as a third (`runtime: codex`, OpenAI-only through a custom model provider whose bearer token comes from a runner-seeded file, with the sandbox tool hooks behind a translating adapter — [ADR 0099](ADRs/0099-codex-agent-runtime.md) and [ADR 0100](ADRs/0100-codex-sandbox-hooks.md)). Runtime selection is configured per repo with `runtime:` in `.fullsend/config.yaml` (per-agent `runtime`/`model`/`effort`/`subagents` on the agent's `agents:` entry sit above it and below the `--runtime`/`--model`/`--effort` flags and `FULLSEND_*` variables, [ADR 0091](ADRs/0091-per-agent-runtime-model-effort.md)) and resolved via `runtime.ResolveForAgent()`. Test-only runtimes — **dummy** (scripted operations) and **dummy-playback** (playlist-based replay of canned results) — execute in the real OpenShell sandbox for behaviour tests without inference. Bootstrap uses a portable `BootstrapInput` interface with optional extensions such as `SandboxHooksBootstrap` for the runtime-neutral sandbox tool hooks ([ADR 0090](ADRs/0090-runtime-neutral-sandbox-hooks-contract.md)); runtimes declare further capabilities through small optional interfaces (`DebugLogNamer`, `ContextBridger`) rather than `Name()` checks in the runner. Transcript and debug artifact handling use a separate `TranscriptHandler` interface. See [runtimes.md](runtimes.md) for the per-runtime security feature matrix required when adding a new backend.
- 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)).

Codex provisions native child roles with runner-selected models and protects
their configuration and hooks throughout the parent and child processes using
inherited Landlock restrictions. Native dispatch is bounded to four children;
usage and transcripts are collected by thread identity
([ADR 0126](ADRs/0126-runner-owned-codex-child-policy.md)).

### Behaviour testing

End-to-end **behaviour tests** use the shared framework in `pkg/behaviourtest/` (with live-test infrastructure in `internal/e2etest/`); the in-repo runner and Gherkin features live under `e2e/behaviour/`. They validate deterministic platform code — dispatch routing, harness loading, sandbox policy, SCM mutations — with the LLM layer removed via the dummy and dummy-playback runtimes. Tests exercise real GitHub (and GitLab) SCM and GitHub Actions CI through pluggable drivers; Gherkin scenarios stay install-mode agnostic while runner env vars select backends. This coverage is **orthogonal** to LLM and instruction testing in [testing-agents.md](problems/testing-agents.md). See [ADR 0066](ADRs/0066-behaviour-tests-with-gherkin-and-drivers.md).
Expand Down
8 changes: 5 additions & 3 deletions docs/cli/agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,13 @@ fullsend agent set review --fullsend-dir .fullsend --subagent correctness=opus -
| `--runtime` | Agent runtime for this agent (`claude`, `pi` or `codex`) |
| `--model` | Model for this agent — an alias, a model id, or `provider/id` on pi and codex (codex takes OpenAI ids only) |
| `--effort` | Effort level for this agent (`low`, `medium`, `high`, `xhigh`, `max`) |
| `--subagent` | Per-persona model override as `key=value` (repeatable). Key is a persona name or `default`; value is a model reference. Pass an empty value (`--subagent key=`) to clear an inherited entry — that writes `key: ~` in the config, after which the persona resolves the way an unmentioned one does (its frontmatter model, then `subagents.default`) |
| `--subagent` | Per-persona model override as `key=value` (repeatable). Key is a persona name or `default`; value is a model reference. Pass an empty value (`--subagent key=`) to clear an inherited entry — that writes `key: ~` in the config. Resolution depends on the runtime; see below and [Codex native children](../runtimes/codex.md#native-children) |

See [Runtimes — per-agent settings](../runtimes.md#per-agent-runtime-model-and-effort) for precedence.
See [pi § Per-persona model configuration](../runtimes/pi.md#per-persona-model-configuration) for
how `subagents` map to persona dispatch.
On [pi](../runtimes/pi.md#per-persona-model-configuration), an unmentioned or cleared persona
uses its frontmatter model, then `subagents.default`. On
[Codex](../runtimes/codex.md#native-children), Claude frontmatter is ignored; the fallback is
`FULLSEND_CODEX_SUBAGENT_MODEL`, then `subagents.default`, then `gpt-5.6-luna`.

## `agent remove`

Expand Down
31 changes: 15 additions & 16 deletions docs/cli/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ The **Runtime** line shows which runtime was selected and the config source it w

## Runtime selection

The runtime for a run is resolved once, in this order: `--runtime` flag, `FULLSEND_RUNTIME`, `runtime:` on the agent's `agents:` entry in `config.yaml` / `.fullsend/config.yaml`, the repo-wide `runtime:` there, then the built-in `claude`. The same order applies to the model (`--model`, `FULLSEND_MODEL`, `model:` on the agent's `agents:` entry, harness `model:`, agent frontmatter; `FULLSEND_PI_MODEL` on pi and `FULLSEND_CODEX_MODEL` on codex are lower-precedence aliases, each read only when that runtime is the one selected) and to effort (`--effort`, `FULLSEND_EFFORT`, `effort:` on the agent's `agents:` entry, harness `effort:`). `<agent>` is the name given to `fullsend run` (`triage`, `code`, …); see [Runtimes — per-agent settings](../runtimes.md#per-agent-runtime-model-and-effort). `FULLSEND_FALLBACK_MODELS=a,b` becomes Claude Code's `--fallback-model`; pi uses it for aliased models on the top-level run when Vertex does not serve the model (two specific 404/403 messages, same provider only; sub-agent children get none); codex ignores it with a warning.
The runtime for a run is resolved once, in this order: `--runtime` flag, `FULLSEND_RUNTIME`, `runtime:` on the agent's `agents:` entry in `config.yaml` / `.fullsend/config.yaml`, the repo-wide `runtime:` there, then the built-in `claude`. The same order applies to the model (`--model`, `FULLSEND_MODEL`, `model:` on the agent's `agents:` entry, harness `model:`, agent frontmatter; `FULLSEND_PI_MODEL` on pi and `FULLSEND_CODEX_MODEL` on codex are lower-precedence aliases, each read only when that runtime is the one selected) and to effort (`--effort`, `FULLSEND_EFFORT`, `effort:` on the agent's `agents:` entry, harness `effort:`). `<agent>` is the name given to `fullsend run` (`triage`, `code`, …); see [Runtimes — per-agent settings](../runtimes.md#per-agent-runtime-model-and-effort). For Codex native children, `--effort` sets the root only; child roles retain their native model defaults (see [Codex native children](../runtimes/codex.md#native-children)). `FULLSEND_FALLBACK_MODELS=a,b` becomes Claude Code's `--fallback-model`; pi uses it for aliased models on the top-level run when Vertex does not serve the model (two specific 404/403 messages, same provider only; sub-agent children get none); codex ignores it with a warning.

The plan block prints `Runtime: <name> (from <source>)` and, when an override applied, `Model: <value> (from <source>)`; stderr carries `runtime: selected "<name>" from <source>` (and `model: requested "<value>" from <source>`) for scripts. A value from the config file is labelled with the file path, suffixed ` agents.<name>` when the agent's entry decided. When `models.aliases` in `.fullsend/config.yaml` remaps the alias, the line keeps the alias and its source and adds the remap: `Model: sonnet (from <source>) → claude-sonnet-5 (from <config path> models.aliases)`, with `model: alias "sonnet" remapped to "claude-sonnet-5" from <config path> models.aliases` on stderr. Aliased entries in the `Fallback models` line show as `alias → id` (`sonnet → claude-sonnet-5, claude-opus-4-6 (from FULLSEND_FALLBACK_MODELS)`); literal ids print as written; pi uses the chain for aliased models when Vertex does not serve the model and ignores it for pinned ids. An invalid override — unknown runtime, unknown effort level, an `agents:` entry that names no agent, or a `models.aliases` key or value the block does not accept — fails before the sandbox is created.
The plan block prints `Runtime: <name> (from <source>)` and, when an override applied, `Model: <value> (from <source>)`; stderr carries `runtime: selected "<name>" from <source>` (and `model: requested "<value>" from <source>`) for scripts. A value from the config file is labelled with the file path, suffixed ` agents.<name>` when the agent's entry decided. When `models.aliases` in `.fullsend/config.yaml` remaps the alias, the line keeps the alias and its source and adds the remap: `Model: sonnet (from <source>) → claude-sonnet-5 (from <config path> models.aliases)`, with `model: alias "sonnet" remapped to "claude-sonnet-5" from <config path> models.aliases` on stderr. Aliased entries in the `Fallback models` line show as `alias → id` (`sonnet → claude-sonnet-5, claude-opus-4-6 (from FULLSEND_FALLBACK_MODELS)`); literal ids print as written; pi uses the chain for aliased models when Vertex does not serve the model and ignores it for pinned ids. An invalid override — unknown runtime, unknown effort level, an `agents:` entry that names no agent, or a `models.aliases` key or value the block does not accept — fails before the sandbox is created. Codex still requires an explicit OpenAI model ID: `models.aliases` does not make Claude aliases valid for Codex, even if the shared plan display shows a remap.

```bash
# try a repo's triage on pi with Gemini Flash, without touching its config
Expand Down Expand Up @@ -98,29 +98,28 @@ depend on the process cwd.
| `override_source` | Where `requested_model` came from (`--model flag`, `FULLSEND_MODEL`, `FULLSEND_PI_MODEL`, `FULLSEND_CODEX_MODEL`, `<config path> agents.<name>`, `harness`, `default`), suffixed `, remapped by <config path> models.aliases` when a per-repo alias override applied to it |
| `runtime_source` | Where `requested_runtime` came from (`--runtime flag`, `FULLSEND_RUNTIME`, the config file path — suffixed ` agents.<name>` when the agent's entry decided — or `default (config not found)`) |
| `total_cost_usd` | Total inference cost in USD, as reported by the runtime (raw floating-point aggregate across all iterations; no fullsend-side pricing-table fallback). See [Cost data contract](../guides/infrastructure/distributed-tracing.md#cost-data-contract) |
| `cost_unavailable` | When true, the runtime did not report complete dollar cost. Codex sets this; zero in `total_cost_usd` does not mean free inference. Omitted for runtimes with known cost |
| `num_turns` | Number of conversation turns |
| `iterations` | Number of agent iterations run; an iteration killed at the budget is not retried (see [Budget and deadline](#budget-and-deadline)) |
| `per_model_usage` | Per-model-spec breakdown, present only when a runtime reports one (today: `pi` with the `Agent` tool enabled). See below |
| `per_model_usage` | Per-model breakdown when supplied by the runtime (`pi` with the `Agent` tool enabled, and Codex). See below |

#### Per-model usage

A map from pi model spec (`anthropic-vertex/claude-opus-4-6`) to
`{requests, input_tokens, output_tokens, cache_creation_input_tokens, cache_read_input_tokens, cost_usd}`.
It exists because a pi sub-agent is a separate `pi` process whose tokens never appear in the
parent's stream, so without it `total_cost_usd` would grow with no way to attribute it.
A map from model spec (`anthropic-vertex/claude-opus-4-6` on pi, `gpt-5.6-luna` on Codex) to
`{requests, input_tokens, output_tokens, reasoning_tokens, cache_creation_input_tokens, cache_read_input_tokens, cost_usd, cost_unavailable}`.
Optional zero/false fields may be omitted. It attributes usage from both the parent and children;
child usage does not appear in the parent's ordinary stream counters.

- **What folds.** Tokens and cost, from both the parent and every child, summed across retry
iterations. Each iteration contributes one `requests` for the parent plus one per sub-agent call,
so `requests` counts inference *episodes*, not HTTP requests.
- **The invariant.** The breakdown sums to the run totals for the five fields an entry has:
`sum(cost_usd) == total_cost_usd`, and likewise for `input_tokens`, `output_tokens`,
`cache_creation_input_tokens` and `cache_read_input_tokens`. `reasoning_tokens` is a run-level
total with no per-model counterpart, so it is outside the invariant. The parent's entry is
recorded on every iteration of an `Agent`-enabled run, including ones that dispatched no
sub-agent, which is what keeps the invariant true across a retry.
iterations. Pi counts one `requests` for the parent plus one per sub-agent call. Codex counts
unique native thread/model invocations with recorded usage. Neither counts HTTP requests.
- **The invariant.** The breakdown sums to the run's input, output, cache-creation and cache-read
token totals. Codex also attributes reasoning tokens per model; pi child records do not yet
provide that split. Cost sums are meaningful only when cost is available. An incomplete Codex
collection preserves known usage and fails the run; it must not be read as complete accounting.
- **What stays parent-only.** `num_turns` and `tool_calls` are read from the parent's stream and are
not broken down or added to per model — a child's turns and tool calls are recorded in its own
session transcript (`transcripts/<agent>-sub<seq>-*.jsonl`) instead.
session transcript (pi's `<agent>-sub<seq>-*.jsonl`, Codex's native thread-ID filename) instead.
- A model spec of `unknown` is a usage record that carries no model spec at all; its cost is
bucketed there rather than dropped. A dispatch rejected *before* a model was resolved writes
no record, so it never reaches the breakdown.
Expand Down
Loading
Loading