Repository navigation
feat(native-chat): Codex sessions write their subagents into the host status store - #22553
Conversation
There was a problem hiding this comment.
Important
Two correctness gaps in the new producer's run fencing and lifecycle, both latent until the next PR starts reading the records.
Reviewed changes
This run reviewed the full 18-file diff at 1df7e358c0 (base brennanb2025/c3-claude-producer).
- New Codex child-work producer (
codex-child-work-evidence.ts,codex-child-work-translation.ts) — re-derives one child's whole observation per frame: open calls, last message, tokens, waiting, and the child's ownturn/completedas the terminal edge. Decodes, shared reducer decides. - Tracker/command wiring (
codex-background-task-tracker.ts,codex-background-command-tracker.ts) —observenow returns astarted/endedcommand decision, addsthreadTasks, and drains/publishes evidence via a session-bound sink. - Delivery ordering (adapter
emit,handleCodexSessionExit, runtime) — evidence is delivered after the journal row and the legacy republish on every notification, andsession-endedon every close path. - Contract change — new
turn_idrun-alias kind; a task runs undertool_use_id, a thread underturn_id; owner lookup still accepts only spawn calls. I traced this against the existing task path and the store's alias-key scoping and found it behavior-preserving there. - Tests — ran the three new files locally: 22/22 pass.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| ...(lastMessage ? { lastMessage } : {}), | ||
| ...(totalTokens !== undefined ? { totalTokens } : {}) | ||
| })) | ||
| return |
There was a problem hiding this comment.
When the child's turn ends before its announcement, this branch emits only an ended edge and returns before requeueOwnedBy. The reducer can settle but never create from ended, so a child that started and finished before its subAgentActivity announcement gets no record at all, and any persistent command or nested child it launched stays ownerless.
Technical details
# A child that ends before its announcement is dropped
## Affected sites
- `src/main/codex/codex-child-work-evidence.ts:194-209` — ended branch emits `ended` and returns
- `:233-235` — `requeueOwnedBy` is reached only from the working branch
- `src/shared/agent-status-child-work-reconciliation.ts:49-51` — `applyEnded` returns when no record exists
## Required outcome
A child the producer has seen run a turn gets a record even if the turn ended before the announcement, and work it launched is re-announced with its owner.
## Suggested approach
On the first observation (`facts.published === undefined`) in the ended branch, emit a live edge (to admit the record) before the ended edge, and/or call `requeueOwnedBy` before returning.
## Open questions for the human
Is dropping such a child acceptable as matching today's strip, which never showed it? The PR body's "no record until the announcement lands" claim implies it should still land.There was a problem hiding this comment.
ℹ️ No new issues in the delta — one lifecycle observation inline; the earlier run-fencing concern is fixed.
Reviewed changes
This run reviewed the two commits since the prior pullfrog review (1df7e358c0 → f098d8db9e) against the full 18-file diff (base brennanb2025/c3-claude-producer).
- Run fence fixed for turn-less child item frames —
recordnow falls back to the child's tracked turn andofTurnis strict, so an open call or last message recorded under one run can no longer leak into the next. - A child turn now ends without
turn/completed— a newturn-endedframe kind ends the child's turn on a non-retryerror(→failed) or athread/closed(→unverifiable) through a newCodexSubagentExecutions.endTurn, so the strip and the record settle on the same frame; asystemErrorstatus deliberately does not end a turn. - Tests — new evidence tests for each ending (error naming a turn / naming none / thread close), first-ending-wins, retried-error and
systemErrorkeeping the turn running, and a turn-less message never leaking into the next run; plus aLINTERchild in the parity script that ends on a fatal error.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| return event.method === 'thread/closed' | ||
| ? { kind: 'turn-ended', threadId: event.threadId, turnId: null, state: 'unverifiable' } | ||
| : null |
There was a problem hiding this comment.
thread/closed may not be reachable while Orca holds the session. Codex emits it only from its "unload a thread with no subscribers" path, and Orca's connection is auto-subscribed to every thread it creates, including children — so a child's close may never notify us, leaving this arm defensive-only. Worth confirming with a live capture; if it cannot fire, a child whose only ending is a close still reads working until session end.
Technical details
# Is a child's `thread/closed` reachable through Orca's connection?
## Affected sites
- `src/main/codex/codex-background-task-frames.ts:58-60` — the `thread/closed` → `turn-ended` (`unverifiable`) arm
- `src/main/codex/codex-subagent-executions.ts:93-103` — `endTurn` with a null `turnId` is reached only from this arm
## Evidence
- Codex emits `ThreadClosedNotification` from `unload_thread_without_subscribers`, which fires only when the thread's subscriber set is empty (codex-rs `app-server/src/request_processors/thread_lifecycle.rs`).
- Orca's connection is attached as a listener to every created thread (codex-rs `app-server/src/lib.rs` → `try_attach_thread_listener`), so a child's subscriber set stays non-empty while the session is held.
- Attribution itself is sound: `ThreadClosedNotification` carries a required `threadId` and is broadcast, and `readCodexThreadId(params)` resolves it.
## Open questions for the human
Can a child's `thread/closed` reach Orca's connection in any supported scenario (a second client unloading the thread, a session-end unsubscribe race)? If not, the arm is dead and the `unverifiable` ending it produces never fires.fc7fd5d to
6818421
Compare
f098d8d to
c99160f
Compare
c99160f to
8e22ed0
Compare
d5ffa7f to
eada18c
Compare
8e22ed0 to
08ca92b
Compare
There was a problem hiding this comment.
ℹ️ No new issues in the delta — the only net-new commit is a test-only parity assertion that passes; nothing to change.
Reviewed changes
Compared 08ca92b26c against the prior run's head (8e22ed0ad2). The branch was rebased onto a newer base, so 11 of the 12 PR commits are SHA churn; the only commit with no counterpart at the prior head is 08ca92b26c. All production files are unchanged.
- Journal↔record run numbering pinned —
codex-structured-child-work-producer.test.tsnow stamps each childagentMessagejournal row and asserts the journal's runattemptequals the record'sinvocation.generationacross the child's first three runs, including the case where Codex reports the child's first turn before the spawn that announces it. The assertion is exact, so it fails if either numbering diverges (e.g. an unstamped run-2 row readsattempt: 1againstgeneration: 2); the file's 4 tests pass at this head.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
eada18c to
503eb83
Compare
08ca92b to
358d1a9
Compare
503eb83 to
fa71175
Compare
36242df to
bc928a2
Compare
There was a problem hiding this comment.
ℹ️ No code issues in the delta — one stale note in the PR description.
Reviewed changes
This run reviewed the net-new commit bc928a2949 since the prior pullfrog review; the branch was also rebased onto a newer c3-claude-producer (94e5159f52), whose session-ended handling now settles live children instead of erasing them. No production logic changed.
- Session-end assertions updated to settlement —
codex-child-work-evidence.test.tsandcodex-structured-child-work-producer.test.tsnow assert a live child and its persistent command settleunknownwhen the session ends, and that already-ended children keep their recorded outcome.clear()'s doc comment was updated to match. All 28 tests in the three Codex child-work files pass at this head. - Runtime test comment —
structured-codex-child-work-runtime.test.tsnow describes a provider exit as reporting the session's end rather than taking its children with it.
ℹ️ The PR description still says a session's end removes the records
The body's frame table ends with "provider exit / close → session-ended → the session's records are removed", and the Decisions and deviations list repeats "Session end removes records instead of settling them". The base branch inverted that rule (35f97191b5, settleLive in agent-status-child-work-reconciliation.ts:93-99 now settles every live owned record unknown), and this delta's tests assert the new behavior. The description should be updated so the next reviewer and the #22614 cutover are not working from the old contract.
Technical details
# Stale session-end decision in the PR description
## Affected sites
- PR description, frame table last row: "provider exit / close | tracker cleared | `session-ended` | the session's records are removed"
- PR description, "Decisions and deviations": "**Session end removes records instead of settling them** (the same rule #22536 applies)."
- Actual behavior: `src/shared/agent-status-child-work-reconciliation.ts:93-99` — `settleLive` settles every live owned record `unknown` on `session-ended`; settled records are trimmed at `STRUCTURED_CHILD_WORK_MAX_SETTLED = 32`.
## Required outcome
The description matches the merged base behavior: session end settles a still-live child (and its owned commands) as `unknown`, and keeps an already-ended child's outcome, rather than erasing the session's records.
## Suggested approach
Update the two description spots to describe settlement. No code change is needed; this delta already pins the behavior.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…ods as a set Behavior-neutral: the same two methods stamp receipt time. Keeps the file under the size limit once the child-work sink lands.
… status store A Codex child thread and each persistent command become host child records, fed through the same delivery, ingest and reducer the Claude lane uses. The child's own turn decides it: turn start is live, turn completion settles it with the outcome Codex reports, and a follow-up turn reopens the same record as a new run. Its open tool call, last message, usage and waiting-on-user flag come from its own thread's frames. A parent turn ending settles nothing.
A completion frame need not restate the tool it ran, so reading the tool name before closing left the call open and the record naming a finished tool.
… the host's records Child turn start/end/follow-up, open tool call, last message, usage, waiting, the persistent command a child owns and its monitoring display, a primary turn end settling nothing, and session end. End to end through the real adapter: evidence after the journal and the legacy republish, and the parent state the records imply equals today's at every frame of a scripted session. Through the production runtime: a Codex session's child work reaches the status sink under its own address, and a provider exit ends it there.
…ex does, before counting edges
…e the runtime test's fake opener
…ugh the shared fold's waiting arm
…s generation The journal numbers a Codex child's runs by the turns it observed on the child's thread; the host record numbers them by the runs its evidence opened. Both are keyed by the child's own turn id, so they must agree run for run, including when Codex reports the child's first turn before the spawn that announces it.
bc928a2 to
307537d
Compare
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (9)
💤 Files with no reviewable changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe change adds Codex child-work evidence for child threads and background commands. It tracks thread and turn identity, activity, outcomes, waiting state, and ownership. Structured sessions publish evidence after notification processing and when a session exits. Shared alias resolution supports turn-based run identifiers. Tests cover evidence collection, reconciliation, producer ordering, and runtime delivery. Priority: ⬇️ Low Merge Risk: 🟡 Moderate · up to A child that finishes before its announcement can be absent from the host status store, with its work left without the correct owner. Resolve this ordering case before merging unless that loss is explicitly acceptable. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to Codex subagent activity will become lasting status records rather than only a temporary working indicator. The records do not grant tool or approval authority, but their accuracy during interruption and recovery matters. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…d keeps the ended ones The host no longer erases a session's children when its provider goes away: a child still running settles with an outcome nobody reported, and a child that had already ended keeps what it said. The producer tests now expect exactly that, from the close path and from an unexpected exit.
307537d to
e7239f1
Compare
… process exits Codex runs every agent shell through unified exec, so every subagent shell arrives with the source the persistent-command tracker keys on. The producer skipped those items, so a working subagent never named its shell, and an approved command (started on the approval path, completed from unified exec) stayed its open tool until the turn ended. The tracker still records the process separately, so a command that outlives the turn reads as monitoring.
There was a problem hiding this comment.
✅ No new issues found in this delta.
Reviewed changes
This run reviewed the single net-new commit since the prior pullfrog run (b22661d8 → e930da150c); every other PR file is unchanged since that run.
- A subagent's shell is now its open tool —
CodexChildWorkEvidence.recordstops filtering outcommandExecutionitems whosesourceisunifiedExecStartup, so a running shell is reported as the child'soperation(for exampleBash: npm run dev) until its process exits, or until its turn ends (which clears open calls). - Tests updated to match —
codex-child-work-evidence.test.tsgains a case for a unified-exec shell opening and closing the operation (24 tests now), and the parity script incodex-structured-child-work-producer.test.tsnow expects a running dev server to be the child's open call.
I verified against the upstream openai/codex protocol that every agent-initiated shell goes through the unified-exec exec_command tool and is emitted with ExecCommandSource::UnifiedExecStartup (Agent is only the enum default used by synthetic items and tests). The removed filter was therefore a no-op against real Codex child frames, so this is a fix rather than a regression, and the repo's other codexCommandOutlivesTurn users are untouched. All 29 tests in the three child-work files pass at the head.
Approval is withheld only because the earlier thread on a child that ends before its announcement is still open and this commit does not touch it.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…ce it outlives its turn Codex runs every agent shell through unified exec and never says when one is left running, so the producer turned every shell, even a millisecond `rg`, into a command record the moment it started. Each settled into the session's pool of 32 settled records, so a busy turn evicted a finished subagent's record (its outcome row would vanish) and listed dozens of finished shells beside it. A command now becomes a record at the first turn boundary of the thread that launched it while its process still runs: until then it is the agent's open call. A shell that exits within its turn never becomes a record.
There was a problem hiding this comment.
ℹ️ No code issues in the delta — the change is a correct fix; the PR description now describes the old command-recording timing.
Reviewed changes
This run reviewed the single net-new commit since the prior pullfrog review (e930da150c → 754da3a914); the other 18 PR files are unchanged.
- A shell becomes a command record only once it outlives its turn —
CodexBackgroundCommandTracker.observestops reporting command starts (its type is nowCodexBackgroundCommandExit, an exit only), andCodexChildWorkEvidencerecords the commands a thread still has running at eachturn/turn-endedboundary via the newrecordCommandsOf(codex-child-work-evidence.ts:155). A shell that starts and exits inside its turn now produces no command record and noendededge; an exit only surfaces once the command was recorded. - Tests —
codex-child-work-evidence.test.ts(25) andcodex-structured-child-work-producer.test.ts(4) updated: a running dev server stays the child's open call until its turn ends, and 60 short shells across two turns leave the records untouched. All six child-work / command-tracker files pass locally (66 tests).
ℹ️ The PR description still says command records are created on item/started
Technical details
# Stale command-recording rows in the PR description
## Affected sites
- PR body, frame-table row for `commandExecution` with source `unifiedExecStartup`: says `item/started` yields a `live` kind `command` record. It is now recorded only at the thread's next `turn`/`turn-ended` boundary, and only if it outlived the turn.
- PR body, "Supporting changes": "`CodexBackgroundCommandTracker.observe` now returns the decision it made (started, or ended with the item)". `observe` now returns exits only (`CodexBackgroundCommandExit`).
- PR body, "Testing": "27 new tests in 3 new files … `codex-child-work-evidence.test.ts` (23)". Now 25 + 4 + 1 = 30.
## Required outcome
The description matches the merged behavior so the #22614 cutover reads the right contract: a command record is created at the turn boundary the command outlived, not on `item/started`.
## Open questions for the human
None — documentation only; the code and its tests are consistent.One follow-on for #22614, not a change here: the main agent's own persistent command (primary thread) now gets its record only at the primary turn's end, whereas today's strip lists it immediately (commands.tasks only hides the commands of working child threads). The folded parent state is unaffected, but the raw row set can differ during a main-agent turn.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
… be removed outright Settled child records now stay until the host drops the session's row; the 32-record trim is gone. A producer can say work stopped with nothing to report, and its record (and the handles it answered to) goes instead of settling. Evidence stays host-internal: the producer and the store share one process.
…ts process stops The command tracker is now the one owner of a Codex command's lifetime. It admits every command whatever `source` Codex tags it with (the approval path starts one as `agent`), and ends it when its process exits, when its thread closes (Codex stops the processes first, so no exit ever arrives), or when the session ends. The producer mirrors that one-to-one: a live record from the start, removed when the command stops, never settled. This removes the turn-boundary rule: a command that was only recorded at its turn's end left the parent reading done for one publish when the main agent's turn ended with a shell still running. The parity script now checks the parent at every journal write, not only at frame end.
There was a problem hiding this comment.
Important
The new command lifetime fixes the main-agent flash but introduces one regression: an approval-path commandExecution that a turn transition aborts leaves a command row that never clears. Details inline.
Reviewed changes
This run reviewed the two net-new commits since the prior pullfrog review (754da3a914 → d85668e995); the rest of the branch matches the previously reviewed state. The new test files pass locally (48 tests across the child-work, command-tracker and reconciliation suites).
- A command is a record from its process start until it stops (
d85668e995) —CodexBackgroundCommandTrackeradmits everycommandExecutionexceptunifiedExecInteraction, returns astarted/endedchange, ends a closed thread's commands (endThread) and returns the ended changes fromclear(). The producer mirrors it one-to-one: aliverecord at start, and a newremovededge (record deleted, not settled) when the process stops. The earlier turn-boundary rule is gone, so a main agent whose turn ends with a shell still running no longer flashesdone. - The per-session settled cap is removed (
6b2e70c5ff) —STRUCTURED_CHILD_WORK_MAX_SETTLED/trimSettledare deleted andapplyRemovedis added; settled children now stay until the parent row is dropped. This is shared reconciliation, so the Claude producer changes with it. - Tests —
codex-child-work-evidence.test.ts(27),codex-structured-child-work-producer.test.ts(the parity script now folds the parent at every journal write, not only at frame end) and the runtime test were updated to the new lifetime.
ℹ️ The PR description still describes the previous command semantics
The frame table now contradicts the code on command endings: the commandExecution item/started row correctly says a live command record, but the "same command's item/completed" row still says the command settles (succeeded/failed/cancelled/unknown) — it is now removed, and codexCommandOutcome no longer exists. The final frame-table row still says records are removed "or at the 32-settled cap", which 6b2e70c5ff deleted, and the "Supporting changes" bullet still describes observe returning the old decision shape. The "Testing" counts (23/27) are stale too. Update these before #22614 reads the contract.
ℹ️ Removing the per-session settled cap changes shared behavior
6b2e70c5ff deletes STRUCTURED_CHILD_WORK_MAX_SETTLED = 32 and trimSettled from agent-status-child-work-reconciliation.ts, so a session's settled agent records are now bounded only by the store's aggregate limits (AGENT_STATUS_STORE_LIMITS: 8,192 children / 16 MB). Once that aggregate is reached the store refuses the mutation, and new live children in that session are rejected rather than admitted. The old cap kept per-session headroom and was careful never to drop a settled child that still owns live work; now the trim is gone entirely. This is deliberate per the commit message but shared with the Claude producer and not described in the PR body's "What Changed" — worth confirming the bound is intended.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…ever ran Codex starts an approval's command item before it asks, and when the turn ends with the question unanswered (the user stops at the approval), it drops the question and never completes the item. The command tracker admitted that start as a running process, so the strip kept a phantom command row and the session row read working until the session ended. The prompt registry, which owns which approvals are still unanswered, reports the command approvals a turn ended without; the tracker ends those commands with the frame that ended the turn. An answered approval keeps its command.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviewed the single net-new commit since the prior pullfrog review (d85668e995 → 77bf4ca065); the other 22 PR files are unchanged since that run.
- An approval abandoned by a turn transition no longer strands a live command —
CodexPromptRegistrynow records the item's own unanswered command approval (anapprovalIdsubcommand prompt is excluded) when a turn is cleared, and the adapter hands that list to the tracker, whose newendUnapprovedends the matching command. This closes the orphan flagged last run: anagent-sourcecommandExecutionwhose approval the app-server drops on a turn transition used to show a running command row with no exit until thread close or session end. An answered approval is forgotten before turn end, so its command correctly stays live. - Tests —
codex-prompt-registry-retention.test.tspins that only an unanswered item-level command approval is reported (theapprovalIdprompt and afileChangeprompt are excluded, and a second drain is empty);codex-structured-child-work-producer.test.tscovers a child's and the primary agent's approval aborted at turn end, plus an answered approval whose command stays live past its turn. Verified locally at77bf4ca065: 5/5 retention tests, 65/65 across the child-work, command-tracker and runtime suites, andpnpm tc:nodeexits 0.
Approval is withheld only because the two earlier open threads (a child that ends before its subAgentActivity announcement, and the live reachability of a child's thread/closed) remain open and this commit does not touch them.
The prior review's inline thread on the agent-source command orphan is resolved.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…e removed hold Main no longer has host.hold: creating the session starts its child, and nothing a viewer does keeps it running. The test attaches and asserts the one child that attach started, then drives it as before.
Review status — ready for reviewHead: Review loops. Five review passes, run until one came back clean, plus a separate architecture challenge once the same kind of defect turned up twice.
Live QA. Six rounds on a real Codex (0.157.1, multi-agent v2) in a background dev build on a separate Mac, reading the host's records at every change. All pass at the heads they tested; the final smoke run was at
No renderer or main-process errors came from this code. Screenshots are in the PR body. Readiness checklist. PASS at the start and at the end, with no P0 or P1 items. CI. All checks green on For the reviewer to decide:
Follow-ups, not in this PR:
|
…-producer # Conflicts: # src/main/codex/codex-structured-session-state.ts
|
| private queueChild(threadId: string): void { | ||
| const child = this.executions.find(threadId) | ||
| const facts = this.facts.get(threadId) | ||
| if (!child?.registered || !child.execution || !facts) { |
There was a problem hiding this comment.
Follow-ups lose their status After more than 128 distinct subagents have been observed, the tracker can evict a finished child's registration. If that child receives a follow-up turn, Codex does not announce it again, and this check skips its evidence. The retained status record stays finished while the child works, and the new run is not recorded.
Knowledge Base Used: Agent workspaces and sessions
| // own ending, or `unknown` when its session ends while it is still live. It owns only the records | ||
| // its own producer admitted, and never claims an outcome the evidence did not report. | ||
| // own ending, or `unknown` when its session ends while it is still live; work with nothing to | ||
| // report once it stops is removed instead. Settled children stay until the host drops the parent's |
There was a problem hiding this comment.
Finished children exhaust shared capacity Settled agents now remain until their session's parent is removed. Because child, alias, and byte limits apply to the whole status store, a long-lived session can fill those limits and cause new child records—including records for other sessions—to be rejected. This makes retained history a risk to later status updates.
Knowledge Base Used: Agent workspaces and sessions
Comments Outside DiffThese findings could not be posted inline.
|
…ts own turn/completed (#23783) * fix(native-chat): a Codex child's turn ends on its own turn/completed #22553 ended a child thread's turn on an `error` Codex will not retry, reading the verdict module #23682 deleted when it made turn/completed the only end of a Codex turn. The two landed minutes apart with no textual conflict, so main no longer typechecks. Codex runs every thread's events, spawned children included, through the same per-thread handler: a turn-ending error is recorded as the turn's last error and the turn then completes as failed. So a child's failed turn/completed is its end, as on the primary thread, and a closed thread stays the one child ending with no completion. * refactor(native-chat): a closed Codex child thread is its own frame With a child's turn now ending only on its own turn/completed, the turn-ended frame carried a fixed turnId (null) and state (unverifiable), and endTurn took parameters nothing passed. Name the one remaining case: a thread-closed frame, and closeThread ending the running turn as unverifiable. Drop a test step that no longer exercised anything.

Scope
Codex native chat only: the structured chat that runs Codex through its app-server, behind the experimental structured native chat setting. Codex running in a terminal pane is unchanged; its subagent rows come from Codex's hooks, a separate lane.
ELI5
When a Codex chat starts a subagent, or runs a shell command, Orca now keeps one record for it on the machine that runs the chat. A subagent's record says whether it is working, which command it is running right now (for example
Bash: npm test), whether it is waiting for your approval, what it said last, its token use, and how it ended (finished, failed, stopped, or ended with no reason given). A command's record exists only while the command's process is running, and goes away the moment it stops. The sidebar and the chat strip will read these records (#22565, #22614), so both show the same thing for Codex as they already do for Claude.What Changed
What you see with this PR alone. Almost nothing on screen reads the new records yet. Three things in today's chat strip do change, all fixes:
Once #22565 and #22614 land, a Codex subagent gets its own row in the sidebar and the strip, like CLI and Claude subagents: it shows its current command and approval waits, keeps a finished/failed row after it ends, reopens the same row as a second run on a follow-up, and the parent reads "monitoring background tasks" while a command it left running is still alive.
Mechanism. This PR adds the Codex producer for the per-child records #22536 introduced for Claude, reusing that PR's delivery path, ingest and reducer.
turn/startedopens a run; its ownturn/completedsettles it (completed→succeeded,interrupted→cancelled,failed→failed, elseunknown). A non-retryerrorsettles itfailed;thread/closedsettles itunknown; session end settles any still-live childunknown. A parent turn ending settles nothing, because Codex children routinely outlive the turn that spawned them. A follow-up turn on a finished child reopens the same record as generation 2. Current command, last message, tokens and waiting (from the child's ownthread/status/changedflags) ride along.commandExecutionwhateversourceCodex tags it with, and ends it when its process exits, when its thread closes, when an approval the turn abandoned leaves it never-run, or when the session ends. The producer mirrors that owner one-to-one: a command is a live record from its start (owned by the subagent that launched it, or by nobody for the main agent) and is removed when it stops. A running shell is also its subagent's current command.removededge (never serialized or sent across a process), and no cap on settled children: the previous 32-per-session cap is gone, for Claude too. Settled subagent records stay until the host drops the session's row.turn_id(a task's run staystool_use_id). Aliases are host memory only, so no wire negotiation is needed.Why
Both providers have to write the same kind of record per subagent, so one piece of UI can show them the same way and the sidebar and strip cannot disagree. Without this PR, Claude chats get the new rows and Codex chats stay on today's one-line "working" display.
Why commands are keyed on the process, not on
source. Current Codex runs every agent shell through unified exec, so every shell (even a 0 msrg) arrives taggedunifiedExecStartup, and the approval path starts a command taggedagentand completes it taggedunifiedExecStartup. The tag says how Codex launched a command, not how long it lives, and Codex never says a command was left running. Two earlier versions of this PR read the tag as a lifetime and each produced a user-visible defect: a subagent never named its shell, and every quick shell became a kept "finished" record that pushed finished subagents out of the 32-record cap. Tracking every command from start to process exit in one owner removes that class: nothing reads the tag, "still running" is true from the start (so the parent never flickers to done at a turn end with a command still running), and every live command has a way to end.Why finished commands are removed rather than kept. A finished command is history, which the transcript already shows. Keeping it as a status record adds nothing a user needs and crowds the records that do matter.
Alternatives considered:
agent) were never tracked at all.item/startedwould mean readingsourceagain.backgroundresidency, which the reducer's turn sweep never touches.Deviations, recorded:
succeeded) and reopens the same record as a new run, rather than modelling an idle, resumable child. Otherwise a Codex child could never show "finished".&,nohup, a new session) is invisible to Codex too, so the chat reads done while it runs; nothing Orca receives can see it.Merge order
#22532, #22520, #22521 and #22536 are merged. This PR merges next, then #22619 → #22565 → #22614.
turn-startededge, drop the cap and trim, carry theremovededge); a command that exited is now gone rather than settled instructured-child-records-switch.test.ts; keep this PR's parent-at-every-journal-write check in the producer test. feat(native-chat): the chat strip and the sidebar read the host's child records #22614 republishes the whole child list per change, so it should decide how finished subagent rows are bounded for display now that the store keeps all of them.Linked Issue
None — part of the structured chat status program.
Visual Proof
Live on a real Codex (codex-cli 0.157.1, multi-agent v2) in a background dev build on a separate Mac, with the host's records read in-process at every change. Final head:
d514f6a1710; the approval and subagent-left-running shots are from the rounds that tested those paths (no code on those paths changed since).A subagent runs a shell. Its record is live with
Bash: /bin/zsh -lc 'sleep 20; echo CHILD_DONE'as its current command, and the shell is a live command record owned by it. At the process exit the command record is removed; the subagent then settlessucceededand stays.A follow-up to the finished subagent reopens the same record as generation 2 and settles it again.
The main agent leaves
sleep 45running and replies. The command record stays live past the turn end and the strip lists it; the parent never reads done while it runs. At the exit the record is removed and the parent goes done.A subagent leaves a command running after it finishes. The subagent settles
succeeded; its command stays a live record it owns for the ~41 s it keeps running.An approval dismissed before it is answered. While the card is up the command is a live record; after the turn is stopped it is removed, nothing ran, and the chat settles.
Also verified live: 40 separate quick shells leave 0 command records and no finished subagent is dropped; an approved command stays live until it exits; closing a chat tab removes every record of that session; a plain turn makes no records; no renderer or main-process errors from this code.
Testing
pnpm run typecheckexit 0 at the final head; fulloxlinton every changed file andcheck:code-quality:changedreport 0 findings.Vitest over
src/main/codex,src/shared/agent-status*,src/main/runtimeandsrc/main/claude(the real-CLI test excluded): 13,132 passed, 0 failed at77bf4ca0657, the PR head before the last main merge. At the merged head the Codex, agent-status and runtime scope passes except one load-timing test (codex-session-index-heal-state) that passes when run alone and is untouched here.30 tests in 3 new files plus additions to the prompt-registry and reconciliation tests. Among them: a parity script through the real adapter that checks, at every journal write (not only at frame end), that the parent state folded from the records equals today's and never reads done while a command is live; every child ending (turn status, non-retry error, thread closed, session end); follow-up runs and late-ending fences; current command open/close including the approval path; a 0 ms shell and 40 shells leaving no command records; 100 settled subagents all kept; stop at an unanswered approval for the main agent and a subagent; an answered approval kept running past the turn; the runtime hop to the status sink under the session's own address.
Ablations: each removed mechanism turns tests red — source-tag admission restored (2), thread-close ending dropped (1), settle instead of remove (6), the 32 trim restored (1), records only at the turn boundary (7), the abandoned-approval hand-off dropped (1) or its registry recording dropped (2), the runtime wiring hop (1).
Platforms: unit tests on macOS; live QA on macOS. The code is platform-neutral and host-side (runs where the chat runs, including an SSH host).
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Known, not fixed here:
sourcetag, so an approved dev server's transcript row reads "interrupted" at turn end while its record and the strip correctly show it running. Follow-up.thread/backgroundTerminals/listcould later re-derive the live command set from Codex itself and make commands stoppable.Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)