Repository navigation
fix(native-chat): record which Codex agent produced each journal row - #22532
Conversation
…evises The reducer rebuilds a row's producer linkage from its NEWEST revision, and absence is a positive claim: no agent id means the session's own agent wrote the row. So any revision written without the stamp hands a subagent's row back to its parent, permanently. Three host paths revise rows they did not write, from the render item they already hold, and all three dropped the stamp: - answering a prompt re-appended the asker's row with the fence only; - dead-generation settlement failed running tool calls and cancelled pending prompts through a lifecycle batch; - stale-session settlement on acquire cancelled lost prompts the same way. The batch path could not carry a producer at all: linkage was removed from the batch row because one row covers N mutations, with a note that a mixed batch would have to stamp per mutation. Dead-generation settlement is such a batch already, and Codex settlement is about to become one. So each item mutation now names its own producer, inline like the row base. A mutation that names none falls back to the row's linkage, which is what a batch read before. Parse sanitizes a bad per-mutation id the same way it does a row's: the field is dropped and the mutation kept. No schema version bump. An older host's mutation validator ignores unknown keys, so it reads a stamped mutation as the session's own, which is exactly what it shows today. Old journals carry no stamp and read as before. Turn revisions still carry nothing: a turn is the session's unit of work, and the live-turn scans rely on a turn row never carrying linkage. The note recording that invariant is updated to the new write sites.
…bagent Codex journals every thread on its app-server connection into the session's journal, and a spawned subagent's items arrive on the child's own thread. None of those rows carried producer linkage, so under the journal's rule that absence means the session's own agent wrote a row, every child's command, message, reasoning, prompt and status row read as the PARENT's: the parent could show its child's running command, its child's reasoning as "thinking", and its child's prose as its own latest line. The Claude lane's model is reused, not reinvented: the same fields and the same absence rule. What differs is how the producer is known. Orca opens exactly one thread per app-server, so any other thread is one Codex spawned. That decides WHETHER a row is a child's from its first frame, announced or not, and the thread id is final at once: it is never re-minted the way a tool-call reference is, so no correction ledger is needed for identity. - agentId: the child thread id, the same id the status side keys a Codex child on. - parentAgentId: the thread whose stream carried the child's `started` activity. Codex emits that item on the spawning agent's own session, so a child that spawned a grandchild is named; the session's own thread is not. Other activity kinds ride whichever agent acted and are not used. - producerKind: 'agent'. - attempt: which run of the child the row's own turn was, counted from the child turns the roster already observes; absent on the first run. Taken from the row's turn rather than the child's latest, so a persistent shell that outlives its turn keeps its run across revisions. - providerParentRef is omitted: a Codex child's frames carry no parent reference of their own beyond the thread id, which is already agentId. One resolver, owned by the roster (which already owns what is known about each child thread), is handed to every writer: items, streams, generic and summary rows, prompts, compactions, goals, and the three settlement batches. The session-end settlement mixes every thread's rows in one batch, so each mutation names its own producer. Turn rows stay unstamped: Codex writes them only for the primary thread. The spawn-group roster row stays unstamped on purpose: a child's frame can trigger its write, but it is the parent's list of its children. The translator's construction moves to a parts module so the translator stays a router under the line cap, and the item streams reuse one append-and-publish helper instead of two copies. Children are never swept at turn end; nothing here changes that.
… every parent reader Two layers, so a stamp that is correct in the store and never read, or read and never persisted, cannot pass. The readers, through the real path: translator, deferred sink, on-disk journal, snapshot. Each is a defect on main: the parent named its child's running command as its own tool, read its child's reasoning as itself thinking, showed its child's compaction as its activity line, and quoted its child's prose as its latest line (checked after closing and reopening the journal, so the stamp is read back from disk). The transcript still renders the child's rows. The writers, through a sink that records the linkage of every plain append, batch mutation and lifecycle transition: start, streamed checkpoint and completion of one command all restate the child; a row that beats the spawn announcement is still the child's; a grandchild names the child that announced it, while an `interacted` activity names no parent; a follow-up turn is the child's second run, and a shell that outlives its turn keeps its own; the exit batch settles each thread's rows under its own producer and the turn row under none; a child's provider frames, approval and goal rows are its own; nothing is stamped while the session thread is still opening; and the spawn-group row stays the parent's.
…nsition path A Codex child's goal row is written through a lifecycle transition, so a sink that forwarded only the fence there would file the child's goal as the session's own.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 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 (5)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change adds subagent lineage and producer-linkage resolution to Codex journal writes. It carries linkage through lifecycle batches, journal parsing, reducer updates, and rendered revisions. Tests cover linked child rows, parent-facing readers, settlement, prompt resolution, and persistence after journal reopen. Merge Risk: ⚪ Minimal · up to No identified attribution or journal-persistence issue prevents merging after normal checks. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description is detailed and covers the change, rationale, testing, visual proof, limitations, and checklist. However, the required Linked Issue section states "None" even though the template requires an issue link.
✨ 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 |
There was a problem hiding this comment.
ℹ️ Minor suggestions only.
Reviewed changes
- Codex producer resolver:
codex-subagent-linkage.tsdecides attribution from the carrying thread — any non-primary thread is a child, withparentAgentIdfrom the spawner thread andattemptfrom the row's own turn ordinal. - One resolver, every writer:
codex-structured-journal-translation-parts.tsbuilds the writers once and threadslinkageForinto items, item streams, generic frames, prompts, compactions, goals, oversized settlement, and turn settlement. Item streams keep a per-stream producer so a parent learned after the first checkpoint reaches later revisions. - Roster bookkeeping:
CodexSubagentExecutionsrecordsspawnerThreadId(fromstartedonly) and capped per-childturnOrdinals; the roster's group row stays deliberately unstamped. - Batch mutations carry a producer:
JournalLifecycleMutationgains per-mutation linkage; the reducer readsjournalBatchMutationProducerwith a batch-row fallback, and the host revision paths (prompt answer, dead-generation and stale-session sweeps) restate the producer so a child's row cannot be re-filed as root. - Compatibility: no schema-version bump; unusable producer ids are dropped per mutation at parse; no new wire field.
Verification in this run: the new linkage and reader tests plus the reducer/schema tests pass (73 total). Forcing linkageFor to {} turns 11 assertions red, confirming the tests pin attribution rather than passing vacuously. The wider src/main/codex, agent-session-journal, and agent-session-wire suites pass except three environment-dependent files (--expose-gc retention tests and the codex app-server teardown integration) that are unrelated to this diff.
I did not find any correctness issue in the producer resolution, the batch/revision restatement, or the turn-row invariant. The one inline note is a stale comment count.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
The reducer took a row's producer linkage from its newest revision, so every writer that revised a row it did not write - a prompt answer, a dead-generation or stale-session settlement, the reopen sweep of stale subagent rosters - had to restate the producer or silently hand a subagent's row to the session's own agent. Three of those writers had been patched to restate it; the next one to forget would reintroduce the bug. Attribution is now fixed by a row's first write. A revision that names no producer keeps the row's existing linkage; one that names any replaces the whole bundle, which is how a provisional stamp is still corrected in place. A row re-created after a tombstone starts with nothing. The reducer runs the same fold on replay, so the kept producer survives a reopen. The three restatements are removed. Per-mutation linkage on lifecycle batches stays: a batch can create a row (a Codex child's prompt, or a child's item settled before any checkpoint landed) and one batch can mix producers.
…eopen A revision naming no producer keeps the row's, on the plain item path and in a batch settling a child's row beside the session's own; one naming any replaces the bundle wholesale; a tombstone clears it; a stale revision cannot touch it; and a reopened journal replays it exactly as it was folded live.
…reachable The stale revision is dropped whole by two independent guards before the inheritance rule runs, so its producer assertion could never fail; the reducer's own stale-revision tests already cover the drop. Also say what the batch sink does forward: each mutation's own producer.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The delta since the last pullfrog review (4 commits) makes producer attribution a property of the write that created a journal row, rather than of its newest revision, and removes the writer-side restatements that assumption made unnecessary.
- Reducer owns inheritance:
upsertItemnow keeps a row's whole producer bundle when a revision names none, and replaces it wholesale when a revision names any member.namesAgentJournalProduceris the presence check (any of the five fields), andjournalRenderItem/journalLifecycleItemMutation/journalBatchMutationProducerroute through it. - Host restatements removed: the prompt answer, dead-generation settlement, and stale-session sweep no longer re-state a producer on rows they revise; each revised row now keeps the producer its creating write named.
- Module rename: the translator's writer factory moved from
codex-structured-journal-translation-parts.tstocodex-structured-journal-translation-writers.ts(createCodexJournalTranslatorWriters). - Coverage: added
journal-producer-inheritance.test.ts(reducer inheritance, wholesale replacement, re-creation, stale revision, and a real on-disk reopen), plus end-to-end tests for the prompt-answer path and the dead-generation settlement, and refreshed the invariant comments inagent-session-journal-producer.ts,journal-reducer.ts,journal-row-builders.ts, andstructured-agent-session-live-turn.ts.
I re-read the full diff and verified the new rule cannot clear attribution it should not: no writer can name root explicitly, so a producer can only ever be added or corrected by a named revision, never dropped by an unstamped one. I had a focused look for any writer that revises an existing row without naming a producer while intending the attribution to change (the one way this refactor could regress) and found none — the Claude provisional-correction and streamed-checkpoint writers always name a producer when they restamp, and the Codex turn-row invariant (never stamped) holds, so the turn rows produced by the sweeps stay root.
The one inline note from the prior review (a stale "five append paths / all four" comment) is fully retired: the comment in structured-agent-session-journal-append-options.ts was rewritten and no longer states a count.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Review status: ready as the attribution layer; the visible part is #22619Head: Review loops (3; the last one found nothing to change)
Readiness checklist: passed at the start (two small items, both fixed) and at the end (nothing at any severity). Compatibility checks:
Live app run. Screenshots and journal evidence are in the description under Visual Proof.
Known limits (in the description): the run number restarts after a re-acquire, as in the Claude lane. A grandchild's spawner is unknown after a re-acquire or in default mode. |
Resolve journal-row-schema.ts: keep both read-time repairs (per-mutation producer linkage and context usage). Move tryAppendLifecycleTransition into the resolved-append module beside the other resolve-then-append operations, keeping the event sink under the line cap.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The delta since the prior pullfrog review is the single merge commit 1ac26c16 that brings origin/main into the branch. git show --remerge-diff confirms only three files differ from the clean auto-merge, and all three are conflict resolution rather than new behavior:
- Conflict resolved in
journal-row-schema.ts: kept both read-time sanitisers — this PR's per-mutationdropUnusableProducerLinkageloop and main'sdropUnusableContextUsage(context-usage feature). Final order is outer sanitise → per-mutation sanitise →dropUnusableContextUsage; a bad field still degrades the row rather than dropping the whole journal. tryAppendLifecycleTransitionrelocated: moved verbatim from the event sink intostructured-agent-session-resolved-append.tsto keep the event sink under the line cap, preserving producer-linkage forwarding throughstructuredAgentSessionJournalAppendOptions. The event sink spreads the resolved-append module as before, soCodexJournalGoalsstill reaches it with its linkage.
Verification on the merged tree: pnpm tc:node clean; 104 tests across journal-row-schema, journal-reducer, journal-producer-inheritance, the event-sink, dead-generation, and stale-turn-verdict suites pass, plus 16 Codex linkage/reader/retention tests.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Conflict: structured-agent-session-dead-generation-settlement.test.ts, where main (#22532) and this branch each added a test at the same spot. Both tests are kept whole, with this branch's import and journal-stub changes.
…wn asks only The session's status is now `attention` only for its own pending prompt, so the clock's fallback to a subagent's ask could no longer be reached, and it read the journal by a different rule than the status it dates. Both now read root prompts. The journal also stamps a Codex subagent's prompt with its thread (#22532), so a Codex child's approval is that child's wait in the Codex lane too. Two tests written for the earlier rule are updated: a subagent's ask leaves a running session `working` on its turn's clock, and a Codex child's answered approval leaves the settled parent's Activity row done with nothing unread.
…wn asks only The session's status is now `attention` only for its own pending prompt, so the clock's fallback to a subagent's ask could no longer be reached, and it read the journal by a different rule than the status it dates. Both now read root prompts. The journal also stamps a Codex subagent's prompt with its thread (#22532), so a Codex child's approval is that child's wait in the Codex lane too. Two tests written for the earlier rule are updated: a subagent's ask leaves a running session `working` on its turn's clock, and a Codex child's answered approval leaves the settled parent's Activity row done with nothing unread.
…wn asks only The session's status is now `attention` only for its own pending prompt, so the clock's fallback to a subagent's ask could no longer be reached, and it read the journal by a different rule than the status it dates. Both now read root prompts. The journal also stamps a Codex subagent's prompt with its thread (#22532), so a Codex child's approval is that child's wait in the Codex lane too. Two tests written for the earlier rule are updated: a subagent's ask leaves a running session `working` on its turn's clock, and a Codex child's answered approval leaves the settled parent's Activity row done with nothing unread.
…wn asks only The session's status is now `attention` only for its own pending prompt, so the clock's fallback to a subagent's ask could no longer be reached, and it read the journal by a different rule than the status it dates. Both now read root prompts. The journal also stamps a Codex subagent's prompt with its thread (#22532), so a Codex child's approval is that child's wait in the Codex lane too. Two tests written for the earlier rule are updated: a subagent's ask leaves a running session `working` on its turn's clock, and a Codex child's answered approval leaves the settled parent's Activity row done with nothing unread.
…wn asks only The session's status is now `attention` only for its own pending prompt, so the clock's fallback to a subagent's ask could no longer be reached, and it read the journal by a different rule than the status it dates. Both now read root prompts. The journal also stamps a Codex subagent's prompt with its thread (#22532), so a Codex child's approval is that child's wait in the Codex lane too. Two tests written for the earlier rule are updated: a subagent's ask leaves a running session `working` on its turn's clock, and a Codex child's answered approval leaves the settled parent's Activity row done with nothing unread.
…wn asks only The session's status is now `attention` only for its own pending prompt, so the clock's fallback to a subagent's ask could no longer be reached, and it read the journal by a different rule than the status it dates. Both now read root prompts. The journal also stamps a Codex subagent's prompt with its thread (#22532), so a Codex child's approval is that child's wait in the Codex lane too. Two tests written for the earlier rule are updated: a subagent's ask leaves a running session `working` on its turn's clock, and a Codex child's answered approval leaves the settled parent's Activity row done with nothing unread.
…eads as waiting (#22634) * feat(native-chat): a Claude subagent waiting on a permission prompt reads as waiting A subagent's permission request reaches the parent session's callback naming the subagent that asked (agent_id) and the tool call it gates (tool_use_id). The pending request is recorded with the asking agent. On every drain the child-work producer re-derives which children a pending request blocks and hands that set to the Claude child decoder, the one owner of each child's live edges: a blocked child reads waiting on every live edge it reports, and a child that starts or stops waiting is a live edge of its own. Answering, denying or cancelling the request returns the child to its prior live state; nothing is stored beyond the pending requests. A live task_updated carrying an error now reaches the record as the child's last message, without an ending or a new state. The replay test drives a scrubbed capture of the real CLI (foreground allow, deny, interrupt, background allow, and the main agent's own request) through the real adapter into the host's child records. * test(native-chat): a subagent's request names it before its tool call is read * docs(agent-status): a subagent asking for approval waits in every lane; the parent row keeps the session's own attention * test(native-chat): hand canUseTool the asking agent without widening the helper's cast * test(native-chat): an interrupted Claude subagent settles cancelled, not failed A captured interrupt shows the spawn call's error result ("The user doesn't want to proceed…") arriving before the subagent's own `task_updated {status: killed}`. The spawn result ends nothing (the child ends only on its own terminal frame), so the child stays live until its `killed` status settles it cancelled. A genuine failure, captured with the subagent on a model that does not exist, sends its `failed` status before the error result and still ends failed. Both captures now replay through the real adapter into the host's records. * fix(native-chat): a Claude subagent's prompt makes the parent row wait, not block A subagent's pending prompt made the whole session `attention`, which reads as the main agent's own `blocked` and outranks the fold's waiting arm, so the parent row read blocked where a CLI Claude parent reads waiting. The main agent's state now reads only its own pending prompts. - A Claude prompt row carries the linkage of the agent that raised it: the one the permission request names, or the owner of the tool call it gates. The same join decides which child reads waiting, so the two cannot disagree. - The status summary projects the session's own status from root prompts only; every other reader (delivery gates, teardown, restart) still asks whether anyone is waiting on a human. - An answer keeps the prompt row's linkage by the journal's own rule: a revision that names no producer keeps the row's existing one. - The child-tool queries gain the prompt's producer, so a prompt row and a child record answer "which agent" from the same join. * test(native-chat): say which ids the permission capture scrubs and which are its own * fix(native-chat): the status clock dates attention by the session's own asks only The session's status is now `attention` only for its own pending prompt, so the clock's fallback to a subagent's ask could no longer be reached, and it read the journal by a different rule than the status it dates. Both now read root prompts. The journal also stamps a Codex subagent's prompt with its thread (#22532), so a Codex child's approval is that child's wait in the Codex lane too. Two tests written for the earlier rule are updated: a subagent's ask leaves a running session `working` on its turn's clock, and a Codex child's answered approval leaves the settled parent's Activity row done with nothing unread. * fix(native-chat): a completion still says the user is asked when a subagent asks The turn-completion feed marked a completion `awaitingUser` from the status summary's `attention`. The status now means the session's own agent is waiting, so a subagent's pending approval stopped reaching the completion. The projection now also says whether anyone is waiting on the user, as the delivery gates, teardown and restart ask it, and the completion reads that. The waiting-subagent replay answers its prompt with the adapter's current response shape. * revert(native-chat): a live Claude task's error stays out of the child's last message No capture shows a live task_updated carrying an error, and it is unrelated to a subagent waiting on a permission request; it leaves this PR. * test(native-chat): settle the Claude session's startup before replaying a subagent's request A startup frame drained child work during the first await, so answering a request freed the child even with the answer's own republish removed. * fix(native-chat): a Claude subagent's prompt row names it as its other rows do The prompt row stamped only the asking agent's id, so a nested subagent's request lost the agent that spawned it, its spawn call and its run. It now takes the linkage the asker's own rows take: the gated tool call's, when that names the same agent, else the one resolved through the agent's spawn call. The provider's agent id stays the asker's id. * fix(native-chat): a subagent's request makes the parent row wait without a child record The parent row learned that a subagent needed the user only from that subagent's child record, so a request no record carried (a Codex child the host never registered, a Claude task past the live cap) left the row working or done while the approval card sat in the chat. "Someone in this session must answer" is now one derived session fact. The projection names two facts instead of a mode flag: the main agent's own status (attention only for its own request) and structuredAgentSessionAwaitsUser (any pending prompt). The status summary publishes the second as an optional awaitsUser, and the shared fold reads it: the main agent's own ask is blocked, otherwise awaitsUser or a waiting child record makes the row wait. Every caller picks the fact it means: the completion edge's awaitingUser and the delivery gate read awaitsUser; the quit snapshot folds the same two inputs the sidebar does. * fix(native-chat): a client that predates awaitsUser still reads a subagent's request as attention A status summary's status is now the main agent's own, so a client built before the split would read a subagent's request as working (or idle) and fold it with code that has no awaitsUser input. Clients advertise agent-session.status-awaits-user.v1; at agentSession.subscribeStatus the host sends any client that does not the pre-split summary: attention whenever awaitsUser is set, without the main agent's own tool line, verdict and clock. The feed and every in-process reader keep the canonical summary. Transitional, like the turn-item downgrade. * test(native-chat): a Codex subagent's approval makes its settled parent's Activity row wait The test pinned the parent row done while a Codex child asked, through a harness that fed no child records, so it proved nothing about the ask. It now drives the ask twice through the real host status store: with no child record (the session's awaitsUser alone) and with the child's own record waiting from thread/status/changed. Both read waiting with needsAttention while the ask is open, then done with nothing unread. * docs(agent-status): a subagent's request reaches the parent row through awaitsUser in every structured lane The store reference said a Codex child's request still read as the main agent's blocked and that only the Codex hook lane fed a waiting child. Both structured lanes stamp the asking child and feed child records, and awaitsUser carries the request when no record does. The liveness comment goes back to main's: a child's blocked is a failed task on an older host's legacy rows. * fix(native-chat): the restart dialog still headlines a subagent's pending approval The quit snapshot now records the main agent's own state, so a subagent asking while the main agent worked recorded `working` and the dialog said "Was mid-reply" where it used to say "Waiting for your approval". The headline now comes from the snapshot's pending prompt, whoever raised it, with the existing copy; `state` stays the main agent's own. * test(orchestration): a subagent's pending approval holds structured mail delivery Scoping the delivery gate to the main agent's own request left every gate test green; a subagent's request now has its own case. * fix(native-chat): a subagent's request is dated by when it was raised, on every client Since the summary's clock became the main agent's own, nothing dated a wait that only a subagent's request held: a pre-split client was sent attention with no clock, where the old host dated it by the subagent's prompt, and a new client's waiting row fell back to the time it first saw it, so after a reload a request the user had already read could read unread again. The session fact is now when someone started being asked: awaitsUserSince, the oldest pending prompt whoever raised it, and its presence is what awaitsUser meant. A row waiting on someone else's request takes that as its clock; the downgrade for a client without the capability dates its attention by it, which is what the old host published. A cross-version test pinned to the last pre-split release runs the same journals through that release's projection and through this one plus the downgrade, and compares the whole summary. The Codex end-to-end test also reads the host's own status row, and keeps a read ask read through a later row and a reload. * test(native-chat): the pre-split parity check compares only the fields the split owns An additive summary field is safe for old clients, so comparing whole summaries against the pinned release would redden on one. The wire comment now says how the downgrade dates attention: the main agent's own oldest ask, else awaitsUserSince. * test(runtime): an aged host-held working summary states that nobody is asked The test built its working summary by overriding the status of a published approval summary, which still carried awaitsUserSince, so the row correctly read waiting. It now drops the request as its scenario says. * fix(native-chat): the chat's subagent block says waiting when the strip does While a Claude subagent's request was open, the sidebar and the composer strip read waiting but the subagent block in the chat history a few pixels above still read "Kicked off 1 subagent working": it shows the journal's roster state, and the journal records no wait. The structured chat now hands its transcript the subagents the strip shows waiting, read from the host's child records through the strip's own row model and matched by the provider id the roster names each one by. A running entry the host says is waiting reads waiting in the group row, its entry and its section head, with the strip's word and the question colour; it reads the journal's state again as soon as the host stops reporting the wait. * fix(native-chat): a collapsed subagent group shows a wait beside a failed sibling A failed sibling took the group row's one alert slot, so a group with a waiting, a working and a failed child read "1 working +1 failed" and hid the wait; it now reads "1 working +1 waiting +1 failed". The waiting set keeps its identity while a child frame changes no wait, so the transcript's subagent rows do not re-render on every frame, and the test of a wait ending now updates one mounted row instead of remounting it. * refactor(claude): one needs-input state on the parent; the asking subagent alone reads waiting Drop the split of the main agent's own status from a session-wide "someone must answer" fact: awaitsUserSince, the agent-session.status-awaits-user.v1 capability and its old-client downgrade, and every reader change that only consumed them (fold, equality, ingest, delivery gate, turn-completion feed, quit snapshot, resume headline, status clock, status bridge, attention dispatch) go back to main. The parent row again reads one needs-input state for a pending request whoever asked, dated as before. Kept: a request's owner recorded once on its prompt row with full producer linkage; the asking subagent's own record reads waiting, re-derived on every update; the chat history's subagent block reads that same state; an answered subagent request stays in its subagent's group. A subagent now waits only on a request the user can still answer (its card open, no answer underway), and the adapter frees it before the host records an answer or dismissal. So a waiting child record always sits beside the pending card, and main's fold never reads the parent as waiting on it: no window after an answer, and no ~3 s wait after a card dismissed by Stop. * fix(claude): a subagent waits only beside its committed card A subagent's wait was pushed to the host as soon as its request arrived, while the request's card row reached the journal at least a microtask later. So every subagent request published the parent row as waiting before blocked (the main agent's own fold reads a waiting child that way), and Activity got an extra unread "waiting" event that main never shows. The card is now the one record of an open request. The translator records the asker on the card once (its row's linkage) and counts the card open only after the sink confirms its rows landed, then publishes the wait; anything that closes the card (an answer underway, a dismissal handed to the host, Claude's own withdrawal, the session's end) frees the subagent first. So every publish that shows a subagent waiting also shows its pending card, and the parent reads one needs-input state, exactly as on main. This retires the registry's view of pending requests (unclaimed(), the asking-child join) and the translator's holdsOpen. The prompt row's linkage takes one rule: the agent the provider names, else the gated call's owner. The parent-row proof now runs through the real deferred sink, durable journal and status feed, publishing as production does, and checks at every publish that waiting subagents have pending cards and that the parent row matches a host fed no waits. * fix(native-chat): a closed sink's dropped writes never read as landed The sink's written() resolved ok when the sink was closed with writes still queued, so a subagent's prompt card could count as open with no row in the journal. written() now reports a close that dropped writes admitted so far as not landed; drained() and lifecycleBarrier() keep reading a closed sink as settled. Tests: a card never opens when its sink closes first; a card Claude withdraws while the sink holds the cancelled row back closes at once; two subagents asking at once, and the main agent asking beside a subagent, keep the parent row as before with each waiting subagent beside its own card; a process that dies mid-request leaves no subagent waiting. * fix(claude): a withdrawn subagent request frees its child before its card closes Main's sink now hands each write to the journal as it is submitted, and an idle journal commits it and runs the publication at once. Claude's own withdrawal of a subagent's request therefore closed the card and published the parent row before the child's wait was freed, so one publish showed the subagent waiting beside no pending card (fg-interrupt replay). The child's wait now also requires the request to still be open in the registry, and a withdrawal republishes child work before the journal takes the close. * refactor(claude): trim subagent request waiting to the common pattern and its essential tests The chat history no longer marks a subagent block as waiting: the approval card itself carries the request, and the asking subagent's row in the sidebar and composer strip reads waiting, as before. NativeChatWaitingSubagentsProvider, native-chat-waiting-subagents.ts and their renderer changes go. A subagent waits while its request is still open and unanswered in the prompt registry and its card has landed in the journal. The registry check also covers a withdrawal under backpressure, so the card list no longer filters pending cancellations itself. Tests: one integration file replays the captured CLI frames through the real adapter, sink, journal and status feed (renamed claude-subagent-permission-request.test.ts), with the asking subagent's state timeline, attribution, nested linkage and a card write that waits for the journal. The producer-harness waiting test, the redundant prompt-card cases, the harness reducer swap and three unused captures (deny, interrupt, main agent, failed subagent) are removed. * test(claude): pin the parent row's dating when a subagent asked first, and narrow the oracle's claim
* fix: preserve registered account credentials after enrollment errors * refactor(orchestration): one function for six agent-to-agent sends (#24901) * refactor(orchestration): send every agent-to-agent message through one sendAgentTurn The structured mail-pointer lane and the structured worker preamble each carried a copy of "send, wait out a pending start, read the verdict", and four dispatch-preamble sites typed into a terminal directly. They now share sendAgentTurn, built from host.send, the host's settlement waiter and sendTerminalAgentPrompt. Every caller passes delivery 'now', so nothing sends differently; a source-scan ratchet keeps new direct sends out. * test(orchestration): the refusal fixture uses a real wire refusal code * fix(orchestration): derive the send fingerprint inside sendAgentTurn and pair target with turn A `queue` send was refused by a real host: callers supplied a fingerprint over the body alone while the host digests body and delivery. sendAgentTurn now builds the envelope with the composer's own builder (extracted to structured-agent-session-send-mutation), so the fingerprint is always over exactly the fields sent; `now` sends keep the identical digest. The pointer lane no longer carries a fingerprint it cannot get right. sendAgentTurn takes one argument, a union on kind that carries its own target and turn, resolved by an exhaustive switch; the terminal turn names its purpose (only the dispatch preamble today) instead of every terminal send inheriting the task lead line. A queued outcome keeps the host's draft receipt, and both structured callers read outcomes exhaustively with unchanged behaviour. The boundary test now also fences direct structured host sends, catches optional, bracket and bound member uses, has a planted-offender self-test, and pins the unmoved terminal mail pointer and agent-teams tmux senders. * fix(orchestration): keep federation.ts under max-lines and satisfy prefer-template in the send ratchet * fix(orchestration): wait on the answered submission's id when a replayed queue turn was already handed off * test(orchestration): pin that a replayed queue turn waits for its hand-off to settle * test(orchestration): fence call-result and cast host sends, raw terminal writes and the launch-prompt helpers * feat(native-chat): a Claude subagent waiting on a permission prompt reads as waiting (#22634) * feat(native-chat): a Claude subagent waiting on a permission prompt reads as waiting A subagent's permission request reaches the parent session's callback naming the subagent that asked (agent_id) and the tool call it gates (tool_use_id). The pending request is recorded with the asking agent. On every drain the child-work producer re-derives which children a pending request blocks and hands that set to the Claude child decoder, the one owner of each child's live edges: a blocked child reads waiting on every live edge it reports, and a child that starts or stops waiting is a live edge of its own. Answering, denying or cancelling the request returns the child to its prior live state; nothing is stored beyond the pending requests. A live task_updated carrying an error now reaches the record as the child's last message, without an ending or a new state. The replay test drives a scrubbed capture of the real CLI (foreground allow, deny, interrupt, background allow, and the main agent's own request) through the real adapter into the host's child records. * test(native-chat): a subagent's request names it before its tool call is read * docs(agent-status): a subagent asking for approval waits in every lane; the parent row keeps the session's own attention * test(native-chat): hand canUseTool the asking agent without widening the helper's cast * test(native-chat): an interrupted Claude subagent settles cancelled, not failed A captured interrupt shows the spawn call's error result ("The user doesn't want to proceed…") arriving before the subagent's own `task_updated {status: killed}`. The spawn result ends nothing (the child ends only on its own terminal frame), so the child stays live until its `killed` status settles it cancelled. A genuine failure, captured with the subagent on a model that does not exist, sends its `failed` status before the error result and still ends failed. Both captures now replay through the real adapter into the host's records. * fix(native-chat): a Claude subagent's prompt makes the parent row wait, not block A subagent's pending prompt made the whole session `attention`, which reads as the main agent's own `blocked` and outranks the fold's waiting arm, so the parent row read blocked where a CLI Claude parent reads waiting. The main agent's state now reads only its own pending prompts. - A Claude prompt row carries the linkage of the agent that raised it: the one the permission request names, or the owner of the tool call it gates. The same join decides which child reads waiting, so the two cannot disagree. - The status summary projects the session's own status from root prompts only; every other reader (delivery gates, teardown, restart) still asks whether anyone is waiting on a human. - An answer keeps the prompt row's linkage by the journal's own rule: a revision that names no producer keeps the row's existing one. - The child-tool queries gain the prompt's producer, so a prompt row and a child record answer "which agent" from the same join. * test(native-chat): say which ids the permission capture scrubs and which are its own * fix(native-chat): the status clock dates attention by the session's own asks only The session's status is now `attention` only for its own pending prompt, so the clock's fallback to a subagent's ask could no longer be reached, and it read the journal by a different rule than the status it dates. Both now read root prompts. The journal also stamps a Codex subagent's prompt with its thread (#22532), so a Codex child's approval is that child's wait in the Codex lane too. Two tests written for the earlier rule are updated: a subagent's ask leaves a running session `working` on its turn's clock, and a Codex child's answered approval leaves the settled parent's Activity row done with nothing unread. * fix(native-chat): a completion still says the user is asked when a subagent asks The turn-completion feed marked a completion `awaitingUser` from the status summary's `attention`. The status now means the session's own agent is waiting, so a subagent's pending approval stopped reaching the completion. The projection now also says whether anyone is waiting on the user, as the delivery gates, teardown and restart ask it, and the completion reads that. The waiting-subagent replay answers its prompt with the adapter's current response shape. * revert(native-chat): a live Claude task's error stays out of the child's last message No capture shows a live task_updated carrying an error, and it is unrelated to a subagent waiting on a permission request; it leaves this PR. * test(native-chat): settle the Claude session's startup before replaying a subagent's request A startup frame drained child work during the first await, so answering a request freed the child even with the answer's own republish removed. * fix(native-chat): a Claude subagent's prompt row names it as its other rows do The prompt row stamped only the asking agent's id, so a nested subagent's request lost the agent that spawned it, its spawn call and its run. It now takes the linkage the asker's own rows take: the gated tool call's, when that names the same agent, else the one resolved through the agent's spawn call. The provider's agent id stays the asker's id. * fix(native-chat): a subagent's request makes the parent row wait without a child record The parent row learned that a subagent needed the user only from that subagent's child record, so a request no record carried (a Codex child the host never registered, a Claude task past the live cap) left the row working or done while the approval card sat in the chat. "Someone in this session must answer" is now one derived session fact. The projection names two facts instead of a mode flag: the main agent's own status (attention only for its own request) and structuredAgentSessionAwaitsUser (any pending prompt). The status summary publishes the second as an optional awaitsUser, and the shared fold reads it: the main agent's own ask is blocked, otherwise awaitsUser or a waiting child record makes the row wait. Every caller picks the fact it means: the completion edge's awaitingUser and the delivery gate read awaitsUser; the quit snapshot folds the same two inputs the sidebar does. * fix(native-chat): a client that predates awaitsUser still reads a subagent's request as attention A status summary's status is now the main agent's own, so a client built before the split would read a subagent's request as working (or idle) and fold it with code that has no awaitsUser input. Clients advertise agent-session.status-awaits-user.v1; at agentSession.subscribeStatus the host sends any client that does not the pre-split summary: attention whenever awaitsUser is set, without the main agent's own tool line, verdict and clock. The feed and every in-process reader keep the canonical summary. Transitional, like the turn-item downgrade. * test(native-chat): a Codex subagent's approval makes its settled parent's Activity row wait The test pinned the parent row done while a Codex child asked, through a harness that fed no child records, so it proved nothing about the ask. It now drives the ask twice through the real host status store: with no child record (the session's awaitsUser alone) and with the child's own record waiting from thread/status/changed. Both read waiting with needsAttention while the ask is open, then done with nothing unread. * docs(agent-status): a subagent's request reaches the parent row through awaitsUser in every structured lane The store reference said a Codex child's request still read as the main agent's blocked and that only the Codex hook lane fed a waiting child. Both structured lanes stamp the asking child and feed child records, and awaitsUser carries the request when no record does. The liveness comment goes back to main's: a child's blocked is a failed task on an older host's legacy rows. * fix(native-chat): the restart dialog still headlines a subagent's pending approval The quit snapshot now records the main agent's own state, so a subagent asking while the main agent worked recorded `working` and the dialog said "Was mid-reply" where it used to say "Waiting for your approval". The headline now comes from the snapshot's pending prompt, whoever raised it, with the existing copy; `state` stays the main agent's own. * test(orchestration): a subagent's pending approval holds structured mail delivery Scoping the delivery gate to the main agent's own request left every gate test green; a subagent's request now has its own case. * fix(native-chat): a subagent's request is dated by when it was raised, on every client Since the summary's clock became the main agent's own, nothing dated a wait that only a subagent's request held: a pre-split client was sent attention with no clock, where the old host dated it by the subagent's prompt, and a new client's waiting row fell back to the time it first saw it, so after a reload a request the user had already read could read unread again. The session fact is now when someone started being asked: awaitsUserSince, the oldest pending prompt whoever raised it, and its presence is what awaitsUser meant. A row waiting on someone else's request takes that as its clock; the downgrade for a client without the capability dates its attention by it, which is what the old host published. A cross-version test pinned to the last pre-split release runs the same journals through that release's projection and through this one plus the downgrade, and compares the whole summary. The Codex end-to-end test also reads the host's own status row, and keeps a read ask read through a later row and a reload. * test(native-chat): the pre-split parity check compares only the fields the split owns An additive summary field is safe for old clients, so comparing whole summaries against the pinned release would redden on one. The wire comment now says how the downgrade dates attention: the main agent's own oldest ask, else awaitsUserSince. * test(runtime): an aged host-held working summary states that nobody is asked The test built its working summary by overriding the status of a published approval summary, which still carried awaitsUserSince, so the row correctly read waiting. It now drops the request as its scenario says. * fix(native-chat): the chat's subagent block says waiting when the strip does While a Claude subagent's request was open, the sidebar and the composer strip read waiting but the subagent block in the chat history a few pixels above still read "Kicked off 1 subagent working": it shows the journal's roster state, and the journal records no wait. The structured chat now hands its transcript the subagents the strip shows waiting, read from the host's child records through the strip's own row model and matched by the provider id the roster names each one by. A running entry the host says is waiting reads waiting in the group row, its entry and its section head, with the strip's word and the question colour; it reads the journal's state again as soon as the host stops reporting the wait. * fix(native-chat): a collapsed subagent group shows a wait beside a failed sibling A failed sibling took the group row's one alert slot, so a group with a waiting, a working and a failed child read "1 working +1 failed" and hid the wait; it now reads "1 working +1 waiting +1 failed". The waiting set keeps its identity while a child frame changes no wait, so the transcript's subagent rows do not re-render on every frame, and the test of a wait ending now updates one mounted row instead of remounting it. * refactor(claude): one needs-input state on the parent; the asking subagent alone reads waiting Drop the split of the main agent's own status from a session-wide "someone must answer" fact: awaitsUserSince, the agent-session.status-awaits-user.v1 capability and its old-client downgrade, and every reader change that only consumed them (fold, equality, ingest, delivery gate, turn-completion feed, quit snapshot, resume headline, status clock, status bridge, attention dispatch) go back to main. The parent row again reads one needs-input state for a pending request whoever asked, dated as before. Kept: a request's owner recorded once on its prompt row with full producer linkage; the asking subagent's own record reads waiting, re-derived on every update; the chat history's subagent block reads that same state; an answered subagent request stays in its subagent's group. A subagent now waits only on a request the user can still answer (its card open, no answer underway), and the adapter frees it before the host records an answer or dismissal. So a waiting child record always sits beside the pending card, and main's fold never reads the parent as waiting on it: no window after an answer, and no ~3 s wait after a card dismissed by Stop. * fix(claude): a subagent waits only beside its committed card A subagent's wait was pushed to the host as soon as its request arrived, while the request's card row reached the journal at least a microtask later. So every subagent request published the parent row as waiting before blocked (the main agent's own fold reads a waiting child that way), and Activity got an extra unread "waiting" event that main never shows. The card is now the one record of an open request. The translator records the asker on the card once (its row's linkage) and counts the card open only after the sink confirms its rows landed, then publishes the wait; anything that closes the card (an answer underway, a dismissal handed to the host, Claude's own withdrawal, the session's end) frees the subagent first. So every publish that shows a subagent waiting also shows its pending card, and the parent reads one needs-input state, exactly as on main. This retires the registry's view of pending requests (unclaimed(), the asking-child join) and the translator's holdsOpen. The prompt row's linkage takes one rule: the agent the provider names, else the gated call's owner. The parent-row proof now runs through the real deferred sink, durable journal and status feed, publishing as production does, and checks at every publish that waiting subagents have pending cards and that the parent row matches a host fed no waits. * fix(native-chat): a closed sink's dropped writes never read as landed The sink's written() resolved ok when the sink was closed with writes still queued, so a subagent's prompt card could count as open with no row in the journal. written() now reports a close that dropped writes admitted so far as not landed; drained() and lifecycleBarrier() keep reading a closed sink as settled. Tests: a card never opens when its sink closes first; a card Claude withdraws while the sink holds the cancelled row back closes at once; two subagents asking at once, and the main agent asking beside a subagent, keep the parent row as before with each waiting subagent beside its own card; a process that dies mid-request leaves no subagent waiting. * fix(claude): a withdrawn subagent request frees its child before its card closes Main's sink now hands each write to the journal as it is submitted, and an idle journal commits it and runs the publication at once. Claude's own withdrawal of a subagent's request therefore closed the card and published the parent row before the child's wait was freed, so one publish showed the subagent waiting beside no pending card (fg-interrupt replay). The child's wait now also requires the request to still be open in the registry, and a withdrawal republishes child work before the journal takes the close. * refactor(claude): trim subagent request waiting to the common pattern and its essential tests The chat history no longer marks a subagent block as waiting: the approval card itself carries the request, and the asking subagent's row in the sidebar and composer strip reads waiting, as before. NativeChatWaitingSubagentsProvider, native-chat-waiting-subagents.ts and their renderer changes go. A subagent waits while its request is still open and unanswered in the prompt registry and its card has landed in the journal. The registry check also covers a withdrawal under backpressure, so the card list no longer filters pending cancellations itself. Tests: one integration file replays the captured CLI frames through the real adapter, sink, journal and status feed (renamed claude-subagent-permission-request.test.ts), with the asking subagent's state timeline, attribution, nested linkage and a card write that waits for the journal. The producer-harness waiting test, the redundant prompt-card cases, the harness reducer swap and three unused captures (deny, interrupt, main agent, failed subagent) are removed. * test(claude): pin the parent row's dating when a subagent asked first, and narrow the oracle's claim * Turn desktop notifications on or off per machine (#24518) * feat(notifications): turn desktop notifications on or off per machine Settings > Notifications lists each machine (this computer, SSH targets, paired Orca servers) with a switch. Muted machines are stored as an opt-out list so a newly added machine still notifies. Both notification senders now name the machine a workspace runs on, and main skips the desktop banner for a muted one; phone push is unchanged. * fix(notifications): preserve phone alerts and honor machine mutes * fix(notifications): bind machine mutes to configured sources * fix(notifications): preserve chat completion subscriptions on owner collisions * fix(notifications): reduce machine settings clutter with a collapsed section * fix(notifications): align machine disclosure with settings rows * fix(notifications): clarify machine switches affect only this computer * fix: distinguish unavailable account metadata from absence * fix(accounts): resolve registered profile UUIDs consistently * Replace agentArgsOverride with unified removeAgentArgs approach (#25091) Consolidate override detection and removal into removeAgentArgs. Previously catalogs used agentArgsOverride to detect conflicts and removeAgentArgs to strip them; now removeAgentArgs handles both by returning stripped tokens. This eliminates redundancy and makes the intent clearer. Enhance removeAgentArgOption with optional value filtering to support selective removal for complex cases like Codex config overrides. * Reuse the ancestor path while building mobile agent rows (#24539) Preserve traversal order and cycle guards using one call-local path Set rather than a copy at every depth. * Release waiting terminal output when a mobile subscription fails to start (#24547) Dispose the failed subscription record’s existing terminal backlog before rethrowing its original start error. * Avoid cloning terminal agent owners twice in relay listings (#24713) Capture the existing host-age expression at its original time, then use one call-local fresh owner clone for the length check and unchanged published owner field. * Reuse prepared statements for internal worker checks (#24573) * Reuse prepared statements across remaining Dispatch reads Use the existing schema-pinned complete Dispatch column list in five remaining read modules, enabling the existing bounded statement cache without caching results. * Reuse prepared statements for internal worker checks Use the existing complete Dispatch projection only for named-field internal consumers; preserve original wildcard reads for every returned failure snapshot. * Prepare the Activity search query once per filtered list (#24701) Lazily reuse a call-local search predicate inside the existing filter, using unchanged byte gates and thread text cache. * Avoid rescanning shared chunks in the plain Node build guard (#24717) Reuse a successful unchanged chunk-code verdict within one synchronous writeBundle invocation, while preserving traversal and current-code reads. * Select the latest stable release tag in one pass (#24786) Replace filter/sort/last selection with one traversal using the unchanged stable-tag regex and numeric comparator; update on equality to preserve the original last spelling. Both actual callers own private plain arrays from Git stdout. * Avoid Resource Manager renders when terminal removal leaves its inventory unchanged (#24806) Reuse the private React state object only when the existing single/bulk removal helper returns its identical inventory; keep every lifecycle revision, tombstone, known-ID write and helper invocation in its original order. * Cancel pending cursor updates when a terminal closes (#24566) Reuse the existing pane frame tracker to cancel owned deferred focus-class updates during existing cleanup, with disposed guards against late or reentrant delivery. * Cancel terminal preview fit frames when the preview closes (#24712) Reuse the existing frame tracker inside the box-fit owner, suppress scheduling after disposal and cancel pending frames at the start of the existing effect cleanup. * Skip new mobile toast work after feedback owner cleanup (#24759) Reuse the existing mobile mounted-ref lifecycle pattern at toast presentation entry, preserving admitted clipboard outcomes and every live animation/sequence/timer operation. * Release terminal side effects after they have been delivered (#24548) Clear consumed queue slots after successful apply or overflow carry; preserve backing identity across reentrant callbacks and report actual retained slots. * Release relay handshake timers when a host connection leaves (#24554) Reuse the existing first-frame finish pattern to remove stage-owned timer/message/close callbacks on receipt, timeout or close; check OPEN after successful async assignment verification. * Avoid restarting error timers on closed mobile relay links (#24567) Check the existing irreversible closed flag before scheduling the existing missing-close fallback timer. * Avoid restarting error timers after mobile relay pairing closes (#24568) Check the existing pairing owner closed flag before allocating its missing-close fallback alarm. * Delete unreturned clipboard cache files after a failed write (#24599) Reuse existing provider-copy best-effort deletion for a newly created clipboard cache file whose write fails before its URI reaches the caller. * Skip new legacy file inventories after mobile search cleanup (#24792) Reuse the existing mobile mounted-ref pattern only at legacy fallback entry after completed passive cleanup; preserve admitted work and all live search/authority/cache paths. Correct only the strict fully-unmounted inventory scenario and its sole golden. * Discard completed AI Vault cancellation IDs in the relay worker (#24820) Use the relay child's existing pending Set to ignore cancellation IDs after completion, matching its desktop sibling; preserve admitted active/queued cancellation and the bundled private sender's complete replies, errors and ownership. * Release completed updater setup timers and callbacks (#24920) Cancel completed deferred updater fallbacks in finally, clear only their exact pending callback, and drop the captured timer before the original fallback guard runs; preserve destroyed admission, successor ownership and updater/quit callbacks. * Check daemon idle state without building discarded terminal inventories (#24749) * Check daemon idle state without building discarded terminal inventories Replace the private idle predicate full public inventory with a host-local full pass that still reads every Session liveness getter in original order. * Remove overwritten daemon test mock assignment * Preserve the registered account ID when selecting UUID variants * fix(updater): keep macOS Orca open when background instances block updates (#24952) * fix(updater): guard macOS installs against running app instances * fix(updater): match native app blockers and preserve quit lifecycle * fix(updater): keep ordinary macOS quit on Squirrel's install-on-exit path Converting every quit with a staged update into quitAndInstall made Cmd+Q relaunch Orca, refused the quit when background instances existed, and hijacked app.relaunch()+app.quit() restart flows (profile switch, admin restart) into an update install racing the relaunched old app. Only Update & Restart runs the running-instance preflight now; the quit-without-install allowance is no longer reachable and is removed. * fix(updater): preserve quit intent through macOS staging * test(native-chat): explicitly model legacy published tab ownership --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> Co-authored-by: m4air <m4air@m4airs-Air.localdomain> --------- Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Co-authored-by: OrcaWin <alpha-eng@stably.ai> Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> Co-authored-by: m4air <m4air@m4airs-Air.localdomain>

ELI5
When a Codex chat starts helper agents (subagents), everything those helpers do is saved into the same chat history as the main agent's work. Nothing on those saved rows said which agent did the work, so Orca treated all of it as the main agent's. The parent-facing status readers (thinking indicator, running-tool line, activity line, latest assistant line, thread goal) therefore read a helper's rows as the main agent's. Each saved row now says which agent wrote it, the same way Claude rows already do, and later edits to a row (settling it, answering it) can no longer lose that.
This PR is the attribution layer: it makes the saved data correct and the shared readers skip helper rows. On its own it does not visibly change the chat in Codex's default multi-agent mode (see Visual Proof). The visible follow-up is #22619, which registers default-mode helpers and labels a helper's commands in the running-commands dock.
What Changed
Before: every row from a Codex child thread (commands, messages, reasoning, approvals, provider notices, compaction notes, goals) had no producer on it. The journal reads that as "the session's own agent wrote this." So the parent-facing readers (thinking indicator, running-tool line, activity line, latest assistant line, thread goal) reported a child's work as the parent's. Separately, for every provider, any later edit of a row that did not repeat its producer silently moved a subagent's row to the parent.
After: every saved row from a Codex child thread names the child, and the shared parent-scoped readers skip it. The transcript still shows every agent's rows. The running-commands dock above the composer is fed separately (by the host's background-command tracker, which deliberately lists a child's commands) and is not changed here.
1. Codex rows name their producer. Every row a Codex child thread produces carries the producer linkage the Claude lane already writes, with the same fields and the same rule that absence means the session's own agent:
agentId: the child's thread id, the same id the status side keys a Codex child on.parentAgentId: set only when another child spawned this one. It comes from the thread whose stream carried the child'sstartedactivity, because Codex emits that item on the spawning agent's own session.producerKind: 'agent'.attempt: which run of the child the row's own turn was (a follow-up turn is run 2). Absent on the first run.Orca opens exactly one thread per Codex app-server, so any other thread on the connection is one Codex spawned. That decides whether a row is a child's from the child's first frame. The thread id is final at once; unlike a tool-call reference it is never re-minted. One resolver, owned by the subagent roster, goes to every Codex writer: items, streamed checkpoints and patches, generic and summary rows, prompts, compactions, goals, and the settlement batches. The spawn-group roster row and turn rows are deliberately left unstamped: the roster row is the parent's list of its children, and a turn is the session's unit of work.
2. The journal keeps a row's producer across edits (all providers). The journal reducer used to take a row's producer from its newest revision. So any writer that revises a row it did not write (answering a prompt, the settlement that runs after an unexpected provider exit, the stale-session settlement on acquire, and the sweep that marks orphaned subagent rosters on reopen) handed a subagent's row back to the parent unless it remembered to repeat the producer. Now:
Replay from disk runs the same fold, so the kept producer survives a reopen. Every path that hands items to a client (live delta batches, history pages, snapshots and resets) reads them from the reduced state, never from the appended row, and clients replace an item wholesale by revision, so the parent's surfaces are right live, not only after a reload. The cost is one constant-time check per accepted revision; there are no extra scans.
Lifecycle batches can also name a producer per mutation, because a batch can create a row. Two examples: a Codex child's approval is first written inside a batch, and a child's streamed item can be settled before any checkpoint of it landed. One batch can also mix producers (Codex's exit settlement covers every thread).
Compatibility. There is no schema version bump. The new keys ride the row base (already shipped) and batch mutations. An older host ignores unknown keys on a mutation and reads it as the session's own, which is what it shows today. Journals written before producer linkage carry no stamp anywhere and render exactly as before. Journals that already hold Claude subagent rows which a settlement or prompt answer later revised: on replay those rows now show as the subagent's, which is the correct attribution and was previously lost. Render items already carry these optional fields over the wire, and older clients ignore them.
Why
The parent-facing readers already ask "is this row NOT mine" and skip anything with an
agentId, so correct producer data fixes all of them at once. Filtering Codex child threads inside each reader would add a second, Codex-only attribution rule next to the journal's own, and would still leave the saved rows wrong.For the edit problem, the first version of this PR made each writer that revises someone else's row repeat the producer (three host paths). That fixes the known writers but not the class: the next writer to forget brings the bug back, and at least one existing writer (the reopen roster sweep) was only safe because roster rows happen to be the parent's. Making "an edit does not change who wrote the row" a rule of the reducer removes the need for every writer to know, so those three restatements are gone. Before relying on it, every journal write site under
src/main(Claude, Codex, and the host) was checked for one that expects an unstamped edit to move a row from a subagent back to the parent. None does: no writer can name "the parent" explicitly, the Claude linkage has no path back to the parent by design, and a Codex thread id never changes. A test-time probe that flagged any such edit fired zero times across the Claude, Codex and native-chat suites, and fired correctly on a deliberate positive control.Splitting settlement into one batch per thread was rejected: it would break the exit settlement's all-or-nothing batch.
Linked Issue
None. This is part of the structured chat status/orchestration program.
Visual Proof
Live run in the Electron app, codex-cli 0.155.0-alpha (default multi-agent mode, which reports helpers through
collabAgentToolCall), GPT-5.5. Prompt: spawn one helper that runssleep 45; echo CHILD_DONEand repliesCHILD_REPLY, while the main agent waits and then repliesPARENT_DONE.What the screen shows is the same before and after. While only the helper runs, the activity line says "Coordinating with another agent" (the main agent's own spawn call) and the running-commands dock says "1 shell command — working" with the helper's command in it, unlabeled. The dock and the default-mode helper registration are #22619.
Before (main), while only the helper runs:
After (this PR), same moment, dock expanded:
What changed is the saved data, read from copies of the session journal:
agentId, including the helper's shell command andCHILD_REPLY.CHILD_REPLYcarryagentId= the helper's thread id andproducerKind: 'agent'. The main agent's turn rows andPARENT_DONEcarry none.agentId.The red "Reconnecting... 2/5" row visible in one after-run is Codex's own retry of its model stream (models were reporting capacity errors at the time), not an Orca reconnect.
Testing
All tests were run with
env -u ORCA_STRUCTURED_SESSION ORCA_BACKGROUND_LAUNCH=1.codex-structured-journal-subagent-readers.test.ts): translator, real deferred sink, real on-disk journal, snapshot, then the shared readers. The parent names its own tool, not the child's running command; the child's reasoning is not the parent "thinking"; the child's compaction is not the parent's activity line; and the parent's own latest line is quoted, read back after closing and reopening the journal. All 4 fail on main's code and show the defect itself.codex-structured-journal-translation-subagent-linkage.test.ts): plain appends, batch mutations and lifecycle transitions, including a row that arrives before the spawn announcement, a grandchild naming its spawner, run numbering, the exit batch settling each thread's rows under its own producer and the turn row under none, child approvals, provider frames and goals, nothing stamped while the session thread is opening, and the group row staying the parent's.journal-producer-inheritance.test.ts, new): an edit naming no producer keeps the whole set, on a plain row and in one batch settling a child's row beside the parent's; an edit naming one replaces it wholesale; a row re-created after removal inherits nothing; and a real on-disk journal replays the kept producer exactly as it was folded live after close and reopen.agentIdcomes back empty): the two reducer inheritance tests, the reopen test, and the prompt-answer, unexpected-exit and stale-session paths;parentAgentIdandattemptsurvive a correction);parentAgentId,attempt, the frame and goal stamps, and the sink's transition forwarding still apply to that unchanged code.src/main/codex,src/main/claude,src/main/native-chat, and the shared producer/live-turn/projection/status-line tests): 4,722 passed and 5 failed. All 5 are real-binary Claude CLI tests (claude-structured-real-cli,claude-tui-resume-real-binary) that fail the same way (provider close unproven) onorigin/main's code on this machine.pnpm tcis clean. The changed-code quality gate and fulloxlinton every changed file (including max-lines) pass.Not verified:
multi_agent_v2was not run live. The v2 frame shapes rely on:agentThreadIdandagentPath);startedactivity, and a child's stream carrying aninteractedactivity about the root;startedon the spawning session.AI Disclosure
Review
Reviewers, please check:
journal-reducer.ts(upsertItem): an edit naming no producer keeps the row's, one naming any replaces the whole set;structured-agent-session-live-turn.tsis updated);Agent skill upstream boundary
Notes
attemptcounts a child's turns seen by the current connection to the Codex app-server. After Orca re-acquires the session, a resumed child's next turn is recorded as run 1 again. The Claude lane counts the same way.parentAgentIdabsent means "the session's own agent spawned it". After a re-acquire, or under Codex's v1 multi-agent mode (the default on current Codex builds, which reports children throughcollabAgentToolCallrather thansubAgentActivity), Orca cannot see who spawned a grandchild, and it is recorded as the session's own child. Whether a row is a child's does not depend on either: it is decided from the thread id alone, so v1 child rows are still stamped withagentIdand kept off the parent's status.startedactivity, those early rows carry noparentAgentIduntil a later revision rewrites them. That is a narrow race, and only with non-default depth.attemptis bounded to the last 64 runs per child; rows of older runs read as the first run.providerParentRef, because its frames have no parent reference beyond the thread id, which is alreadyagentId.codex-structured-journal-translation-writers.tsand the item streams share one append-and-publish helper. Both original files were already at the line cap, and this keeps them under it.Checklist
N/Awith reason (attached; no visible change, by design of this layer)pnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (typecheck and targeted suites run locally; CI will cover the rest)