Repository navigation
Description
This was generated by AI during triage.
What happens
On Codex, a session's Run metrics count only the parent thread. Two things are missing:
- Native sub-agent tokens. When the Codex session spawns its own sub-agents (Codex's built-in
thread_spawn), for example the two parallel reviewers thatthirdshift-code-reviewasks for, their tokens never reachrun_metrics.session_signals. - The observed Model. Every Codex session's
tokens_by_modelentry has"model": null, and.models.jsonhas"observed": [], even though Codex records the model it ran.
Evidence
From one Ticket run on Codex CLI 0.166.0 with gpt-6.1-sol high (thirdshift 0.18.5). The Codex rollouts are under the account's ~/.codex/sessions/<date>/:
| Codex thread | turn_context.model |
Final total_token_usage (input / cached / output) |
In thirdshift's implement totals? |
|---|---|---|---|
parent (exec) |
gpt-6.1-sol |
2,251,744 / 2,183,040 / 11,695 | yes, exactly |
sub-agent, source.subagent.thread_spawn.parent_thread_id = the parent |
gpt-6.1-sol |
424,798 / 398,976 / 4,375 | no |
| sub-agent, same parent | gpt-6.1-sol |
421,916 / 389,376 / 4,996 | no |
The implement session's recorded totals therefore under-count input by about 38% and output by about 80%. A Continuation of the same run showed the same pattern: parent 1,623,657 input counted, two sub-agents with 720,429 input not counted. The Security review session spawned no sub-agents, and its totals match its rollout exactly.
The parent's thread ID appears in thirdshift's Session trace (thread.started). Each sub-agent rollout names that ID as its parent_thread_id, so the rollouts can be joined to the session without guessing.
Why it matters
Per-Command token and cost figures, Experiment Arms (#1468) and any Process comparison under-count Codex work whenever a skill fans out to sub-agents. A Codex Ticket run with a two-axis code review looks cheaper than it is. Comparisons against a Claude Code Arm are skewed too, if Claude's Agent-tool subagents are counted there, which #1639 notes is inferred but not documented.
Related
- Decide Codex per-request evidence for Session traces #1047 asks whether Codex facts may come from rollout files. This bug is a concrete case for using them: the
exec --jsonstream carries neither the model nor the sub-agent usage. - Run metrics miss the tokens of agent CLIs a session starts itself #1639 covers a different gap: agent CLIs a session launches itself through Bash (
claude -p,codex exec), not the Harness's own sub-agents.
Recommendation
bug. State needs-triage: the obvious fix reads the session's Codex rollouts (the parent by thread ID, and sub-agents by parent_thread_id), adding sub-agent usage once, by observed model, and taking the parent's model from turn_context. Whether to rely on rollout files is #1047's open decision. Once that's settled, this is agent-sized.
Activity
JacobStephens2 commentedon Nov 10, 2026
Investigation summary
The gaps remain on selected Base main at ecaf0d4.
Confirmed from code and fixtures:
Existing rollout access is narrower than the proposed fix: src/harness/codex/patches.rs reconciles patch details, and src/harness/codex/limits.rs reads exact-session quota observations. Neither recovers Models or native descendant usage. These readers provide precedent and an implementation seam, but do not settle the additional accounting contract.
Decision and proposed shaping
#1047 remains open with no Trusted-account decision approving the additional evidence source. Decide whether optional rollout enrichment for observed Models and native usage may proceed independently of its per-request lifecycle question. Preserve the distinction between aggregate usage and model-request boundaries.
Propose two Tickets after that decision: (A) observed Model attribution and normalized parent usage through retained reconciliation; (B) native descendant usage by observed Model, including exact membership, deduplication and attribution across Resumes. Require both retained-trace and Run metrics/Arm projections to agree. Separately launched agent CLIs remain #1639's scope. No matching duplicate was found.
Validation and limits
cargo test --bin thirdshift codex: 31 passed, one ignored pending #1047. The recording-fixture check passed; session::usage::tests: 10 passed. scripts/affected-tests main reported no changed files. Tests emitted process-environment permission warnings but passed. The original account rollouts were not supplied within this worktree, so their schema and reported production totals were not independently verified.
Questionnaire
For the Day shift deciding #1651: local code and fixture checks confirm missing observed Models and no native child-usage ingestion. Existing rollout readers handle patches and quotas; #1047 still leaves broader evidence sourcing undecided.