Skip to content

feat(native-chat): register Codex default-mode helpers as subagents - #22619

Merged
brennanb2025 merged 27 commits into
mainfrom
brennanb2025/c8-codex-default-helpers
Sep 30, 2026
Merged

brennanb2025 merged 27 commits into
mainfrom
brennanb2025/c8-codex-default-helpers

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1178 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1174
Prod 26 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​803 $\color{#cf222e}{\Huge{\mathbf{−}}}$​189 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​614

What this changes for you

Who hits this: anyone using a Codex native chat where the main agent hands work to a helper agent. Codex picks its multi-agent mode per model, and in live runs GPT-5.5 used its default mode, which is the mode this PR fixes. Codex's newer v2 mode already worked.

Before: in that mode, Orca never registered the helper as an agent. Its rows showed in a section headed only Subagent, with no name and no state, and nothing else said a second agent was at work: no subagent row, no agent in the dock, no host record. What did show was wrong: the helper's shell command appeared as the main agent's own work, and the main agent's calls to the helper showed as raw internal rows.

Before After
Can you see the helper? Barely. Its rows sat in a section headed only Subagent (no name, no state, no time or tokens). No subagent row in the transcript and no agent in the status dock above the composer. The host wrote no subagent record either, so the sidebar would also show nothing once #22614 reads those records. Yes. The transcript shows Kicked off 1 subagent · working, then Ran 1 subagent · completed · 46s · 47.6k tokens, with the helper's section named by its task. The section opens by itself while the main agent spawns, waits on or messages the helper. The dock shows 1 agent — working, labelled with the helper's task.
Whose work is it? The helper's shell command showed in the dock as 1 shell command — working, with no helper label, as if the main agent were running it; the host recorded the command as the main session's own. The command is listed under the helper, never under the main agent, and disappears when it exits.
The main agent's calls to the helper Raw rows reading codex · item:collabAgentToolCall. Named rows (spawn_agent, wait_agent, send_input, close_agent), each labelled with the helper and saying what the call did: Spawned, Sent input, Closed, or the helper's reply.
Tool outputs in a folded run Once one call finished with no output, every later output was drawn under the wrong call (the helper's reply under spawn_agent, a shell's output under wait_agent). This also affected Claude folded runs. Each output sits under the call it answers.
Closing a helper mid-command The helper had no state to settle: only its command's record, owned by the main session. The helper ends as stopped (or completed, if its turn had already finished), its killed command leaves the dock, and nothing stays "working".

Screenshots of each state are under Visual Proof below.

Scope.

  • Affected: Codex structured chats (Codex through its app-server) in default multi-agent mode, on desktop and on mobile. Which mode runs is the model's choice: in live runs GPT-5.5 used default mode.
  • Also changed: in Codex's v2 multi-agent mode, its collab calls (for example wait) now render as readable tool rows too. v2 helper registration is unchanged.
  • Also changed, for every structured chat including Claude: a folded tool run now pairs each output with the call it names instead of by position (see "A pairing fix this exposed").
  • Not affected: Codex in a terminal pane, legacy (non-structured) native chat, other agents' status producers.
  • Not a regression fix: default-mode helpers were never registered. The live test that found the gap was on fix(native-chat): record which Codex agent produced each journal row #22532.

State. Up to date with main (including #23783, a helper's turn ends only on its own turn/completed, and #23752, a subagent's rows live in their own section). Checks at the final head 70b75cc4f3b are under Testing.

How it works

One membership model, fed from the calls that name a helper

Codex 0.155+ has two multi-agent modes. v2 announces a helper with subAgentActivity items. Default mode sends none: a helper appears only as the thread ids a parent's collabAgentToolCall item names in receiverThreadIds. spawnAgent starts with receiverThreadIds: [] and names the helper's thread when it ends; wait, sendInput, resumeAgent and closeAgent name their receivers from the start.

Before this PR, the journal roster and the background-task tracker registered children only from subAgentActivity. Both write into one CodexSubagentExecutions, the single owner of Codex child identity, so in default mode nothing registered anywhere.

  • readCodexSubagentAnnouncements (codex-subagent-activity.ts) returns every helper an item names: a subAgentActivity item's child, or every receiver of a collab call, at the call's start or end, except receivers the call reports as notFound. This is the same rule Codex's own client uses to learn its helpers.
  • The roster, the tracker's frame reader, the child-work evidence and history restore all register through it into the same executions. There is no second roster and no second state source. A session that sends both shapes registers one child per thread id.
  • A spawn registers whatever its status once it names a receiver: Codex reports a spawn as failed when the helper it created errored at birth, yet still names the thread, and that thread can run.
  • Execution state still comes only from the helper's own turn frames (as in feat(native-chat): Codex sessions write their subagents into the host status store #22553). agentsStates is the caller's snapshot and is never read as state.
  • Label: default mode carries no nickname or task path on the item, so the label is the spawn prompt's head, one line, at most 80 characters. Only a spawn supplies a label, and the first one stands. A helper known only from another call (its spawn was never seen) uses each surface's existing fallback for an unnamed subagent.
  • Only spawn_agent and send_input put a helper's run under the parent turn that sent it work, like v2's interacted.

Lifecycle: a helper's turn ends on its own frames

A helper's turn ends on its own turn/completed (a fatal error's failed completion follows it within milliseconds), thread/closed, or the session ending. closeAgent is not an ending by itself: its item's status is the helper's reported status, not whether the close worked, so a close that errors on a running helper still reports completed. When a close works, Codex aborts the helper's turn and sends the helper's own turn/completed with status interrupted (mapped to stopped), then kills its processes. Each killed process still reports its exit as item/completed on the helper's thread, which removes its command record through the command tracker, the one owner of command lifecycle. Both were seen live (below).

The roster row now settles with the strip and the record

#22553 settled a child's strip row and host record together when its turn ended without turn/completed (thread/closed), but the transcript's subagent row was rewritten only on a child's turn/started and turn/completed, so it kept reading working after those endings. CodexSubagentExecutions now reports when a child's current execution changes (onExecutionChanged), and the roster rewrites the group row from that, whichever frame caused it. A refused write clears the group's lastSerialized, so the next write retries it. The default-mode roster row now also rewrites on each helper's token-usage update, coalesced per group, the same as v2 on main.

The transcript rows

  • Each collabAgentToolCall becomes a tool-call row (codex-collab-agent-item-translation.ts) named by the tool the model called, with the helper's name in description (the key the row label reads), and the prompt, model, effort and receiver ids for the expanded view.
  • Every finished call carries an output, worded as Codex's own client words the call's end (above); an errored helper under a wait reads Error - <message>. A running call has no output, like every running tool. Every finished call needs one: an older client pairs outputs with calls by position (see Notes).
  • A call keeps naming the helpers its started item named: Codex ends a timed-out wait with an empty receiver list, which used to strip the helper's name from the row.
  • A spawn_agent row is a plain tool call in the run sentence. Codex's spawn call ends as soon as the helper starts, so counting it as running an agent read "Ran 1 agent" above "Kicked off 1 subagent · working"; the roster row alone stands for the helper. (Claude's Task call, which lasts as long as its subagent, keeps the agent wording.)
  • History restore replays each announced helper for its name and membership only. It starts no execution, so a restored helper gets no dock entry, record or roster row until a live turn of its own.
  • A spawn or send_input prompt past the 16 KB journal limit is clipped on its own, with the journal's truncation marker, so the row always keeps the helper's name and thread ids.

The helper's section opens while the main agent works with it

A running chat holds a subagent's section open while the main agent's newest row is a call on that subagent, as it does for a Claude spawn. The reader that decides this (native-chat-subagent-delegation.ts) only knew the old raw collab row, so a default-mode helper's section stayed shut for its whole run. It now also reads the collab tool rows: a spawn, wait, message or close names the helper it delegates to (the first, if it names several); one naming none is ordinary output. The tool names and the helper-id key come from one module, src/shared/codex-collab-agent-tools.ts, which the host writes the rows from. Raw rows in journals written before this PR still work.

A pairing fix this exposed

Every reader of a folded tool run paired results to calls by position, so one call that finished with no output shifted every later output onto the call before it. This was visible live. A structured row carries its call and its output together, so the projected result now names its call (NativeChatToolResultBlock.callId, optional) and every reader pairs through one loop, pairToolBlocks: the desktop run, mobile's tool run, the edit cards, the task lists and the ask row. A result that names a call answers only that call (or none, if that call is not waiting); a result that names none is still paired by position. callId is produced wherever the journal is projected (renderer, mobile, host worker transcripts and released-worker archives). The same misattribution existed for Claude folded runs, which already carry call ids, and for any Codex call that finished with no output.

Why this approach

  • Register at the executions, from what Codex announces. One owner for child identity fixes the dock, the host records and the transcript roster together, and it is the mechanism Codex's own client uses (learn helpers from collab receivers, skip notFound).
  • Rejected: a separate roster for collab-announced helpers. Two membership models for one child, and a v2 session would produce two children.
  • Rejected: agentsStates as the helper's state. It is the caller's last-known snapshot, refreshed only when the caller makes a call. The helper's own frames already give its state.
  • Rejected: ending a helper on closeAgent. An earlier revision did this. It could mark a still-running helper cancelled forever (the item's status is the helper's, not the close's), and Codex already reports the helper's own interrupted turn.
  • Rejected: treating every non-primary thread as a helper from its first frame. Complete in principle, but it departs from how Codex's own client learns helpers, and the one case it would add (Stop pressed inside a ~1 ms window of a spawn) did not reproduce live in 4 targeted attempts. Listed as a follow-up.
  • Rejected: suppressing the collab rows as status chrome. In default mode these calls are the only transcript trace of the fan-out.

Visual Proof

Real Codex codex-cli 0.159.0, GPT-5.5 in default multi-agent mode, a background dev build (ORCA_BACKGROUND_LAUNCH=1) of 4706d3df677 with current main merged, CDP screenshots of the hidden window. The last commit, 70b75cc4f3b, only clips very long prompts and is covered by unit tests.

BEFORE (current main), while the helper sleeps: two raw codex item:collabAgentToolCall rows, the helper's rows under a section headed only Subagent (no name, no state), no roster row, and the dock reads 1 shell command — working with no helper label, naming the helper's command as the session's own.

before: current main while the helper runs

AFTER, while the helper runs sleep 40; echo CHILD_DONE and the main agent waits on it: Kicked off 1 subagent · working, the helper's section named by its task and opened by itself with its running command inside, wait_agent naming the helper, and the dock reads 1 agent — working.

after: helper running, section open

AFTER, dock expanded: one agent row, labelled with the helper's prompt.

after: dock expanded

AFTER, settled turn with rows expanded: spawn_agent reads Spawned and carries the helper's id, the roster row reads Ran 1 subagent · completed · 46s · 47.6k tokens, and the helper's shell (exit 0) sits in the helper's section.

after: settled

AFTER, a helper closed while a command it started (sleep 150) was still running: wait_agent reads the helper's reply STARTED, close_agent reads Closed, the killed shell reads exit -1, and nothing stays working. The roster row reads completed here because the helper's own turn had finished before the close; a close during its turn reads stopped.

after: helper closed mid-command

AFTER, quit and relaunch: the restored rows name the helper by its task, not a thread id, and the roster row reads completed with no dock entry.

after: restored after relaunch

Testing

  • At the final head 70b75cc4f3b: tc:node passes; pnpm run check:code-quality:changed reports 0 findings across 34 files (React Doctor and casting included); full oxlint and the anti-slop audit pass. tc:web passed at 4706d3df677; the commits after it change only src/main files and merge main.
  • Suites, with env -u ORCA_STRUCTURED_SESSION -u ORCA_AGENT_SESSION_ID: after merging current main, all src/main/codex, src/main/native-chat, renderer native-chat, src/shared/native-chat-* and src/shared/structured-agent-session-* tests: 7,522 passed, 2 failed, both timeouts under machine load in tests this PR does not touch, which pass when run alone. At 4706d3df677, src/main/codex and renderer native-chat: 4,678 passed, 0 failed. At the final head, src/main/codex plus the delegation, subagent-section and tool-icon tests: 2,462 passed, 1 failed, the same untouched load-timeout test, which passes alone.
  • New tests:
    • codex-default-mode-subagents.test.ts (21), through the real CodexStructuredSessionAdapter, with spawn and wait items taken verbatim from a live default-mode journal. Registration in the strip, the records and the roster row; either arrival order; one child for a session announcing both ways; a failed spawn that created its thread, and one that created none; a closed helper ended only by its own interrupted turn, and a failed close leaving it running; a closed helper's command kept until its process reports the exit; the roster row staying working through a helper's fatal error and settling on the failed turn/completed that follows it, and settling when its thread closes; a helper whose spawn was never seen, registered from any call naming it (several receivers, notFound skipped, parent-turn rule); restore naming a replayed row, claiming no running helper, and knowing a helper whose spawn compacted away.
    • codex-collab-call-rows-on-positional-clients.test.ts (3): replays what the host publishes through the old positional pairing rule (call ids stripped) with both the desktop and mobile readers, over the conversation and the helper's own section, and checks each output lands under its own call through spawn, shell, wait and close, including a timed-out wait.
    • codex-collab-call-delegation.test.ts (6): the real adapter's rows, through the transcript projection, to the reader that opens a helper's section: a finished spawn, a running wait and a close delegate to the helper; a spawn still starting and the main agent's next call do not; a spawn with a prompt past the journal limit still names its helper.
    • Pairing by call id in every reader, and a named result never given to another call (native-chat-tool-pairing, native-chat-tool-pair-limit); the projected result carrying its call id; no Codex helper call counted as running an agent; per-thread token totals.
  • Each fix was checked red with its production change reverted. At the original head, 14 of the first 17 Codex and glyph tests failed with the production files reverted to feat(native-chat): Codex sessions write their subagents into the host status store #22553's head. Later ablations: restoring spawn-only registration reddens 4 tests; removing the notFound skip, the send_input parent-turn rule, or multi-helper handling in the records or the roster reddens 1 each; not passing the started item reddens 2 of the positional-client tests; showing the helper's message for every tool reddens 2; restoring the earlier status-snapshot wording reddens all 3; removing the collab-row branch from the section reader reddens 3 of the delegation tests; bounding the prompt together with the helper's name and ids reddens the long-prompt test.

Live QA

Real Codex codex-cli 0.157.0 on macOS, GPT-5.5 in default multi-agent mode, background dev builds (ORCA_BACKGROUND_LAUNCH=1) driven over CDP with an isolated profile and agent-status hooks off.

Each scenario ran in a fresh chat on a folder workspace, with host child-work records captured per mutation and Codex's raw frames recorded. Rounds ran at 63ddd92787, 5c4eb54932a, 0222b9929e3 and 8fe518e5d86 on codex-cli 0.157.0, and the latest at 4706d3df677 with current main merged, on codex-cli 0.159.0; the screenshots above are from the latest.

Scenario Result
Spawn a helper that runs a shell command, wait for it Pass. Helper record live with operation Bash: …, its command record owned by the helper and removed 1–12 ms after the process exited, helper settled succeeded. Dock never said "shell command". No raw collab rows. Codex sent no subAgentActivity, so this was default mode.
Close a helper after its turn, while its command still runs Pass (3 runs). The killed command reported its exit (failed, exit -1) 16–32 ms after the close started; the record was removed 1–4 ms later; ps confirmed the process was gone.
Close a helper during its own turn Pass (3 runs). Frame order: the helper's turn/completed interrupted (~47 ms after the close started), then the killed command's exit, then the close item. Helper settled cancelled; command record removed after the exit.
A wait_agent that times out Pass. The row keeps naming the helper and reads Finished waiting.
The helper's section while the main agent waits on it (latest round) Pass. It opened by itself, with no click, while wait_agent ran, and was closed once the turn settled.
A helper's command that outlives the helper's turn and the main agent's turn (latest round) Pass. It stays a live record under the helper, and the dock reads 1 shell command — working with the row named by the helper's task, until the process exits (record removed 9 ms after the exit).
Stop pressed while spawn_agent is running Not reproduced as a gap (4 timed attempts). Stop before the spawn completes cancels the helper before it exists (no helper thread, no process); Stop after it completes leaves a helper Orca shows correctly throughout.
Quit and relaunch, reopen the chat Pass. Restored rows name the helper, not a thread id; no dock entry, no "working" row.
Plain "Reply with just OK" Pass. 0 child records, no roster row, no dock entry.
Errors None in the renderer console; nothing about child work, agent status, Codex, subagents or collab calls in the main log.

What I did not verify, and known limits

  • Stop inside a spawn. If Stop lands after Codex created the helper's thread but before the spawn item completes, no item ever names the helper, so it stays unlisted and its shell reads as the session's own. From Codex's source that window is about 1 ms; 4 targeted live attempts never hit it (Stop earlier cancels the helper cleanly; later, the spawn names it and Orca shows it correctly).
  • Stop does not stop a running helper. That is Codex's behaviour: after Stop the helper runs to its end, and Orca truthfully shows it working until then. When it ends the session reads done, not stopped. Not changed here.
  • A close_agent or send_input that Codex reports as failed still reads Closed / Sent input, as in Codex's own client; the row itself is drawn in its failed state.
  • The per-call outputs (Spawned, Closed, Finished waiting, …) are English text in the journal, like the journal's existing host-written notices ("Cancellation requested.", "Conversation compacted."). They exist so older clients pair outputs correctly and show only when a row is expanded.
  • A helper known only from non-spawn calls reads subagent in the roster row, as an unlabelled agent in the dock, and by its thread id on its call rows (each surface's existing fallback). Codex's nickname for it is only reachable through an extra thread/read request per helper, which Orca does not make.
  • A timed-out wait replayed from Codex's own history (thread/resume) names no helper: Codex stores only the completed item.
  • Not run live: a v2 session on this branch, the Codex history-replay restore path, a failed spawn that created its thread, and a prompt past the 16 KB journal limit (the last commit). They are unit-tested. The persisted-journal restore was run live. The section opening by itself was seen live but not compared against a build without that change.
  • A refused roster write while following the executions is retried on the group's next write or by the session-end sweep, and is reported to nobody until then.
  • Platforms: macOS only. The logic is platform-neutral and runs in the execution host's process (the same path as feat(native-chat): Codex sessions write their subagents into the host status store #22553), so SSH, WSL and folder workspaces take the same path; mobile's own suites were not run (the shared pairing and projection code it uses were).

Notes

  • Wire. No new RPC field or opcode. What the host publishes for a Codex session changes: raw collab status rows become tool-call rows with outputs, and a default-mode roster row appears. Both are body kinds older clients already render. Because every finished collab row carries an output, an older client that pairs by position still draws each output under its own call. NativeChatToolResultBlock.callId crosses the worker-read RPC and is persisted in released-worker archives; it is optional, and readers without it fall back to positional pairing.
  • Tool names are the names the model calls, from the generated app-server schema: spawnAgent, sendInput, resumeAgent, wait, closeAgent, sendMessage, followupTask, interruptAgent, listAgents.
  • For the next PR (feat(native-chat): the chat strip and the sidebar read the host's child records #22614): in default mode a helper's description is its prompt head, not a task name.
  • Follow-ups (not in this PR): one membership rule (any non-primary thread with frames is a helper, collab calls only label it) would close the Stop-inside-a-spawn gap; register helpers in one place instead of both the roster and the tracker; optionally read each helper's nickname with thread/read.

Merge order

#22532, #22520, #22521, #22536, #22553 and #22565 are merged. Codex default-mode helpers appear in the sidebar only once #22614 is in too: #22614 reads the host records, and this PR is what writes them for default mode.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

One gap worth addressing before merge: a helper the caller closes updates the strip and the host record, but the durable subagent roster row keeps reporting working.

Reviewed changes

  • Default-mode helper membership — readCodexSubagentAnnouncement now treats a finished spawnAgent call as a second way to announce a child, and both the roster and the background-task tracker register through it into one shared CodexSubagentExecutions.
  • Collab tool rows — a new codex-collab-agent-item-translation renders each collabAgentToolCall as a named tool-call row (spawn_agent, wait_agent, …) instead of a raw codex · item:collabAgentToolCall status row, and forwards the roster's label so an interrupted turn keeps its helper names.
  • Close lifecycle — a finished closeAgent becomes a turn-ended/stopped frame; CodexChildWorkEvidence now keys on the frame's child thread rather than the event's.
  • Output pairing — the projection attaches its journal row's callId to the tool-result block, and pairNativeChatToolResults resolves a named result to its call before falling back to positional pairing.
  • Run vocabulary — spawn_agent counts as running an agent and takes the bot glyph.

ℹ️ Nitpicks

  • The roster row appends a collision ordinal when two helpers share a label (claimLabel), but the new tool row and the strip both name a helper by the raw executions.label. Two default-mode helpers whose prompt heads coincide will therefore read X/X 2 on the roster but X/X on their spawn_agent/wait_agent rows, so the "two rows read as the same child" invariant in codex-collab-agent-item-translation.ts does not hold for colliding labels. The agents array still disambiguates them.
  • The diff branch of itemBlocks still emits an unnamed tool-result, so an edit patch can still paint under an earlier output-less call (for example a spawn_agent). AgentJournalDiffItem carries no callId, so closing this is a schema addition rather than a projection tweak — worth a follow-up, not this PR.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes — delta since the prior pullfrog review (80b2032040 → d09c8b2286)

  • The roster row now follows the executions — CodexSubagentExecutions fires a new onExecutionChanged listener from observeTurn and settleSession, and CodexSubagentRoster subscribes in its constructor and rewrites the group row from the changed execution. A fatal error, a thread/closed and a closeAgent therefore settle the durable subagent row, not only the strip and the host record. handleTurn still returns the write's admission via an idempotent re-derive, and dispose() unsubscribes.
  • Three tests added — the roster row settles with the strip and the record on a fatal error (failed), on thread/closed (unverifiable), and on closeAgent (stopped), each asserting the last subagent-group revision.

This closes the closeAgent gap flagged in the prior review. The listener propagation reads correct: it fires only when an execution is actually assigned, duplicate writes collapse on lastSerialized, and it cannot touch the primary thread because that thread is never registered as a child.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes — delta since the prior pullfrog review (d09c8b2286 → 6214d76206)

  • Restored call rows name their helper — replayed-item handling moved into restoreCodexHistoryItem, which registers each announced helper in CodexSubagentExecutions (register starts no execution, so no strip entry, record or roster row claims it runs). A restored wait_agent/close_agent/send_input row now names its helper instead of the raw thread id.
  • Roster exposes its executions — CodexSubagentRoster.executions is now public and helperLabel is gone; the collab row's name callback reads subagents.executions.label directly.
  • Render contract named — handleItem's claim flag is renamed renderedByRoster, documenting that a subAgentActivity renders as the roster row alone while a spawn call keeps its own row.
  • Comment clarification — the collab tool-name map notes it maps the wire's camelCase to the model-facing snake_case, not a spelling fix.
  • Tests — a restored thread (2) through the real translator; the naming test reddens without the registration (verified by ablation).

The registration runs after primaryThreadId is set (codex-structured-session-acquire.ts:197), so it cannot register the primary thread as a child; register's idempotence and the MAX_CHILDREN cap bound a restored thread's historical helpers. Both existing tests and the new file pass at this head.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes — delta since the prior pullfrog review (bd540b299f → c915a9cf3e)

  • A failed spawn now registers its helper — codexCollabSpawnedThread (codex-collab-agent-tool-call.ts:65) drops the status === 'completed' gate, so a spawnAgent call that ended failed but named a receiver registers that helper in the one shared CodexSubagentExecutions. Codex reports failed for a helper that errored at birth while still naming the thread it created, and that thread can run a turn.
  • Three tests — a failed spawn with a receiver registers the helper (strip, records and roster row); a failed spawn with no receiver registers nothing; a failed closeAgent leaves the helper running (the close gate is preserved). Each reads the real adapter path.

The removal is safe against the shapes it must not touch. An in-progress spawnAgent names no receiver, and the first test still asserts that the inProgress/empty-receiver call registers nothing. Registration is idempotent and starts no execution, so a failed spawn whose thread never runs a turn yields no strip entry, record or roster row — the child stays registered only for its name, bounded by MAX_CHILDREN. The closeAgent gate is unchanged and now guarded by its own test.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025
brennanb2025 force-pushed the brennanb2025/c4-codex-producer branch from 8e22ed0 to 08ca92b Compare September 24, 2026 21:09
@brennanb2025
brennanb2025 force-pushed the brennanb2025/c8-codex-default-helpers branch from c915a9c to d0d1de8 Compare September 24, 2026 21:24

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes — delta since the prior pullfrog review (c915a9c → d0d1de8)

  • Token totals moved to their own module — the roster's per-thread token map became CodexThreadTokenTotals in codex-thread-token-totals.ts, which owns the newest-report-replaces rule and the recency-ordered LRU cap (MAX_CODEX_TOKEN_USAGE_THREADS). The roster now calls record/get/clear and still selects its children's totals at write time, so behavior is unchanged.
  • Test — codex-thread-token-totals.test.ts covers newest-report-replaces and that a thread which keeps reporting outlives quieter ones under eviction.

Verified at d0d1de85: pnpm tc:node, pnpm exec oxlint on the changed files, and pnpm run check:max-lines-ratchet all exit 0; codex-thread-token-totals.test.ts and codex-subagent-roster.test.ts pass (37). The branch was also rebased onto c4-codex-producer 08ca92b2; reading the full diff against that base confirms the producer-linkage plumbing is content-preserving for this PR.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025
brennanb2025 force-pushed the brennanb2025/c4-codex-producer branch from 08ca92b to 358d1a9 Compare September 24, 2026 23:36
@brennanb2025
brennanb2025 force-pushed the brennanb2025/c8-codex-default-helpers branch from d0d1de8 to c77bad1 Compare September 24, 2026 23:48
brennanb2025 added a commit that referenced this pull request Sep 25, 2026
…wn module

The readers of a session's newest own prompt and own assistant prose move from
the status projection into structured-agent-session-latest-messages.ts, and are
re-exported so their consumers keep one import site. With the status clock the
projection now carries, scoping its status to the session's own asks put it past
the size limit. The module is byte-identical to the one #22619 extracts for the
same reason, so the two branches carry one change.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/c4-codex-producer branch from 358d1a9 to 1db34d1 Compare September 25, 2026 04:57
@brennanb2025
brennanb2025 force-pushed the brennanb2025/c8-codex-default-helpers branch from c77bad1 to de9ea37 Compare September 25, 2026 05:02
@brennanb2025
brennanb2025 force-pushed the brennanb2025/c4-codex-producer branch from 1db34d1 to 36242df Compare September 25, 2026 05:53
@brennanb2025
brennanb2025 force-pushed the brennanb2025/c8-codex-default-helpers branch from de9ea37 to 748ef6e Compare September 25, 2026 05:56
brennanb2025 added a commit that referenced this pull request Sep 25, 2026
…wn module

The readers of a session's newest own prompt and own assistant prose move from
the status projection into structured-agent-session-latest-messages.ts, and are
re-exported so their consumers keep one import site. With the status clock the
projection now carries, scoping its status to the session's own asks put it past
the size limit. The module is byte-identical to the one #22619 extracts for the
same reason, so the two branches carry one change.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/c4-codex-producer branch from 36242df to bc928a2 Compare September 25, 2026 10:47
@brennanb2025
brennanb2025 force-pushed the brennanb2025/c8-codex-default-helpers branch from 748ef6e to 39223ce Compare September 25, 2026 10:51
brennanb2025 added a commit that referenced this pull request Sep 25, 2026
…wn module

The readers of a session's newest own prompt and own assistant prose move from
the status projection into structured-agent-session-latest-messages.ts, and are
re-exported so their consumers keep one import site. With the status clock the
projection now carries, scoping its status to the session's own asks put it past
the size limit. The module is byte-identical to the one #22619 extracts for the
same reason, so the two branches carry one change.
… created its thread

Codex reports a spawn as failed when the helper it created errored at birth,
yet the call still names the thread it created, and that thread can run. The
spawn was registered only when the call completed, so such a helper existed
nowhere and its shell read as the session's own bare command: the original
default-mode bug. A spawn now registers whenever it names a receiver; one in
progress, or one that created nothing, names none. A failed closeAgent still
ends nothing, because the helper was not closed.
…s own home

Every thread's running total, member or not, with the rule that the newest
frame replaces the last and the recency-ordered cap, moves out of the roster
into codex-thread-token-totals.ts. The roster still selects its children's
totals at write time. With the producer linkage the roster now builds, it
was past the size limit.
…wn module

The readers of a session's newest own prompt and own assistant prose move from
the status projection into structured-agent-session-latest-messages.ts, and
are re-exported so their consumers keep one import site. With the status
clock the projection now carries, a tool result naming its call put it past
the size limit.
…s process reports its exit

A helper's in-turn shell is a live command record owned by the helper and is also its open
Bash operation; its exit removes the record. A caller's closeAgent kills the helper's
processes, and each still reports its exit on the helper's thread, so the close leaves the
command to that exit rather than ending it itself.
…call it names

The folded desktop run now pairs a result with the call it names, but mobile's tool run, the desktop edit cards and the task lists still paired by position through `pairToolBlocks`. In a Codex default-mode session the new `spawn_agent` row finishes with no output, so on mobile the helper's reply drew under `spawn_agent` and `wait_agent` showed none, and a desktop edit card could take the next command's output as its own.

`pairToolBlocks` now follows the same rule as `pairNativeChatToolResults`: a result that names its call answers that call, and one that names none answers the oldest unanswered call as before.
…n its caller's closeAgent

A finished `closeAgent` call ended the helper's running turn as `stopped`. But the call's status is not the close's outcome: Codex sets it from the helper's own agent status, so a close that errors on a running helper still reports `completed`. Orca then marked a helper that was still running as cancelled in the strip, the host record and the roster row, and because the first ending a turn gets stands, its real ending could never correct it.

A close that works does not need the edge either. Codex's shutdown of the helper aborts its running turn, and the app-server reports that as the helper's own `turn/completed` with status `interrupted`, which Orca already maps to `stopped`. So a helper's turn now ends only on its own frames (its `turn/completed`, a fatal `error`, `thread/closed`) or the session ending, and the close is only its call row.

This also drops the child-work evidence re-keying that existed only for the close: every remaining frame names the thread that sent it.
… different call

A result that named a call id with no unanswered match fell back to the oldest unanswered call. On mobile, a run shows at most six calls, so a command past that window whose output named its own call gave that output to an earlier call that finished with none, such as `spawn_agent`.

A result that names its call now answers only that call and otherwise stays unpaired. A result that names no call still answers the oldest unanswered one. Both pairing readers share the one rule through `answeredToolCallIndex`.
…, not only its spawn

A helper whose spawn Orca never saw (history replay after compaction dropped the spawn, or a resume or message to a helper from earlier) stayed unregistered, so its shell read as the session's own command: the bug this PR fixes, in another shape.

Every collab call now announces each helper it names, skipping a receiver the finished call reports notFound. The spawn's prompt still labels a helper when it was seen; otherwise the helper has no label and reads as any unnamed subagent does. A send_input, like the spawn, names the parent turn the helper's next run belongs to.

The session's own thread is excluded once, in the reader, instead of at each of its three callers.
…he call reports

A client that predates result call ids (an older mobile app, or an older desktop reading a newer host) projects the journal itself and pairs each tool result with the oldest unanswered call. This PR publishes collab calls as tool rows, and a finished spawn_agent, send_input, close_agent or resume_agent on a running helper had no output, so such a client drew each later output in the run under the call before its own (the parent's shell output under spawn_agent, the helper's reply under the shell).

Every finished call now has an output taken from the item: a wait's reply from each helper that finished (an errored helper's error), and for every other call the helper's reported status in Codex's own words (Pending init, Running, Completed, ...). A close or resume no longer shows the helper's last reply as if the call returned it. A wait whose end names no helper (it timed out, or v2) reads Finished waiting; any other call with no state reads its own status.

A call also keeps naming the helpers its started item named: Codex ends a timed-out wait with no receivers, so its row lost the helper's name when it finished.
…irToolBlocks

Desktop runs and every other reader (mobile, edit cards, task lists, the ask row) each had their own pairing loop sharing one index rule. The desktop's pairNativeChatToolResults now reads the pairs pairToolBlocks makes, so a run is paired by one loop and a new reader cannot add a third. No behaviour change.
… did, in Codex's own words

A close_agent row read `Running` and a spawn_agent row `Pending init`: each showed the helper's status snapshot from before the call took effect, so a close that stopped its helper read as though it had not worked.

Each finished call's output now follows Codex's own client: spawn reads `Spawned` (or `Agent spawn failed` when no helper was created), send_input `Sent input`, close `Closed`, and resume the helper's status summary. A wait keeps each finished helper's reply, with other statuses in Codex's summary wording (`Error - <message>`). The row label already names the helper, so the output does not repeat it.
…elper's snapshot as output

Since spawn, send_input and close rows say what the call did, the reader's header was wrong to claim every call row shows the reported snapshot as its output: only a wait or resume does.
Codex's spawn_agent call ends as soon as the helper starts, so counting it as running an agent drew "Ran 1 agent" directly above "Kicked off 1 subagent · working" while the helper was still working, and "Ran 1 agent · 1 failed" when Stop cancelled a spawn before any helper existed. Claude's Task call lasts as long as its subagent, so it keeps the agent category; the Codex spawn row is now a plain tool call and the roster row alone stands for the helper.
…ion that follows a fatal error

Codex follows every turn-ending `error` with the turn's failed `turn/completed`,
on a helper's thread as on the primary, and only that completion ends the turn.
The roster test now sends both and checks the row, strip and record stay
working through the error and settle on the completion.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/c8-codex-default-helpers branch from 72deef0 to 2654d95 Compare September 29, 2026 07:34

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

The rewritten roster-ending test fails at head: it expects a helper to stay working through a turn-ending error, but readCodexChildTurnEnding still settles that turn as failed — base behavior from #23808 — and codex-child-work-evidence.test.ts:181 asserts exactly that.

Reviewed changes — delta since the prior pullfrog review (6c0581d → 2654d95)

  • A Codex spawn_agent row is no longer agent activity — spawn_agent was removed from CATEGORY_BY_ROW_WORD, so the call no longer takes the subAgentActivity run sentence or the bot glyph; Claude's task keeps both. Tests updated.
  • The roster-ending test and roster comment were rewritten — the test now expects the row to stay working through a fatal error and settle only on the failed turn/completed, and the comment drops "a fatal error" from the list of child-turn endings. This is the change that fails.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

brennanb2025 added a commit that referenced this pull request Sep 29, 2026
…wn module

The readers of a session's newest own prompt and own assistant prose move from
the status projection into structured-agent-session-latest-messages.ts, and are
re-exported so their consumers keep one import site. With the status clock the
projection now carries, scoping its status to the session's own asks put it past
the size limit. The module is byte-identical to the one #22619 extracts for the
same reason, so the two branches carry one change.
…-default-helpers

# Conflicts:
#	src/main/codex/codex-background-task-tracker.ts

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No new issues in this delta — the merge of main resolves the prior blocking finding. One earlier minor thread (closeAgent failed wording) remains open, which is why this is not an approval.

Reviewed changes — delta since the prior pullfrog review (2654d957 → a16f2f4, two merge commits of origin/main; no PR-owned feature change).

  • The Codex child-turn error ending was dropped by main — codex-background-task-frames.ts now exposes only subagents/turn/thread-closed frames (readCodexChildThreadClosed replaced readCodexChildTurnEnding, readCodexErrorWillRetry is gone), so CodexSubagentRoster follows executions through this.executions.closeThread. A helper's row now stays working through a fatal error and settles on the failed turn/completed that follows.
  • PR-owned files adapted to main refactors — codex-child-work-evidence.ts uses projectNativeChatTranscript, the journal writers consume attributionFor (was linkageFor), and structured-agent-session-latest-messages.ts folded back into structured-agent-session-projection.

This resolves the prior blocking review: codex-default-mode-subagents.test.ts passes 21/21 (it previously failed at 2654d957ef). I also ran the delta-adjacent suites at head — codex-child-work-evidence (26), codex-background-task-tracker (26), codex-subagent-roster (35), codex-collab-call-rows-on-positional-clients (3), native-chat-tool-pairing (7), native-chat-tool-pair-limit (6), 103 tests, all passing — and pnpm tc:node exits 0. The thread on the failing test was replied to and resolved.

The still-open minor thread (codex-collab-agent-item-translation.ts:82: a closeAgent with status: 'failed' renders state:failed but output Closed) is unchanged by the merge and was not re-raised.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

…wns, waits on or messages it

A running chat holds a subagent's section open while the parent's newest row delegates to that subagent. For Codex that rule only knew the raw collab status row; this PR writes each collab call as a tool row (spawn_agent, wait_agent, send_input, close_agent, ...) naming its helpers in `input.agents`, so a default-mode helper's section stayed shut for its whole run while Claude's opened.

The delegation reader now reads a Codex collab tool row as a delegation to the first helper it names, the same rule the raw row keeps for journals written before this change; a call naming no helper stays ordinary output. The row names and the `agents` key live in one shared module the host writes from and the reader reads, instead of a second list.

The new test drives the real adapter's rows through the transcript projection to the delegation; the collab frame harness moves to a fixture shared with the positional-clients test.
Comment thread src/shared/codex-collab-agent-tools.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No new issues in this delta. One earlier minor thread stays open, so this is not an approval.

Reviewed changes — delta since the prior pullfrog review (a16f2f4 → 4706d3d).

  • A Codex collab tool row now reads as a subagent delegation — nativeChatSubagentDelegation gained a branch that treats a row whose newest call is a Codex collab tool (spawn_agent, wait_agent, send_input, close_agent, …) as delegating to the first helper its input.agents names. Before this, the live frontier only recognised the raw item:collabAgentToolCall status row, so a default-mode helper's section stayed shut for its whole run while Claude's opened.
  • Row names and the agents key get one shared owner — src/shared/codex-collab-agent-tools.ts now holds the camelCase→snake_case map, the row-name predicate and codexCollabRowAgentIds; the host writes agents through the same constant the reader reads, so the two cannot drift. The persisted key is still agents, so there is no wire change.
  • Tests and fixture — codex-collab-call-delegation.test.ts drives the real adapter's published rows through the transcript projection to the delegation (finished spawn, running wait, close, an unstarted spawn, and a superseding parent call); the collab frame builders move to codex-collab-call-frames-fixture.ts, shared with the positional-clients test.

Verified at 4706d3d: codex-collab-call-delegation (5), native-chat-subagent-delegation (3) and codex-collab-call-rows-on-positional-clients (3) pass; pnpm tc:node and pnpm tc:web exit 0; oxlint on the eight changed files reports 0 findings. The wider src/main/codex run reddens only the app-server teardown/posix-supervisor integration tests, which spawn and reap real processes and are unrelated to this change (neither file is in the PR).

The one still-open minor thread (codex-collab-agent-item-translation.ts:83: a closeAgent with status: 'failed' renders state: failed but output Closed) is untouched by this commit and was not re-raised.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

…its helper

A collab call row bounded its whole input as one value, so a spawn or send_input whose prompt passed the 16 KB journal limit was stored as a clipped wrapper: the row lost the helper's name and thread ids, and with them the label and the delegation that opens the helper's section.

The prompt is now clipped on its own with the journal's inline-text bound, marker included; the helper's name, ids, model and effort are bounded as before and always survive.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No new issues in this delta. One earlier minor thread stays open, so this is not an approval.

Reviewed changes — delta since the prior pullfrog review (e904eec238 → 70b75cc4f3).

  • A long prompt no longer strips a collab call row of its helper — collabRowInput now clips the prompt on its own with the journal's inline-text bound, instead of bounding description, prompt, model and effort as one JSON value. A spawnAgent/sendInput prompt past the 16 KB journal limit used to turn the whole input into a truncated wrapper, which swallowed description (the helper's name) and agents (its receiver ids) and with them the label and the delegation that opens the helper's section. The non-prompt fields are still bounded as before and now always survive.
  • Test — codex-collab-call-delegation.test.ts adds a spawn whose prompt is 20,000 characters and asserts the published row keeps description/agents and still reads as a delegation to the helper.

Verified at 70b75cc4f3: codex-collab-call-delegation (6), codex-default-mode-subagents (21) and codex-collab-call-rows-on-positional-clients (3) pass; pnpm tc:node exits 0.

The still-open minor thread (codex-collab-agent-item-translation.ts:83: a closeAgent with status: 'failed' renders state: failed but output Closed) is untouched by this commit and was not re-raised.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status at 70b75cc4f3b: ready from review, not merged

The problem. In a Codex chat using Codex's default multi-agent mode (the mode GPT-5.5 picks), Orca never registered a helper agent as an agent. On current main, the helper's rows sit in a section headed only "Subagent", with no name or state. There is no subagent row, and the dock shows the helper's command as "1 shell command — working", with no helper label. The main agent's calls to the helper render as raw codex item:collabAgentToolCall rows.

What changes for you.

  • The helper now appears the way a Codex v2 or Claude subagent does: "Kicked off 1 subagent · working", then "Ran 1 subagent · completed · time · tokens".
  • The dock shows "1 agent — working", labelled with the helper's task.
  • The helper's section opens by itself while the main agent spawns it, waits on it or messages it.
  • The main agent's calls to the helper read as named rows (spawn_agent Spawned, wait_agent with the helper's reply, close_agent Closed).
  • In a folded tool run, each output sits under the call it answers. This also applies to Claude chats.

Fixed in this review.

Deferred.

  • (P2, not caused by this PR) A Codex file-edit row carries no call id, so it is still paired by position. With a command still running earlier in the same run, the patch can show under that command.
  • Nits: the new branch that reads a collab tool row as a delegation has no provider check (no other agent uses these names); a spawn that has not yet named its helper closes a sibling section for a few milliseconds, as main's raw rule already does; there is no end-to-end test of a section opening; and the clipped prompt's marker says "output truncated".

Verified.

  • Review:
    • Three independent reviewers covered how the PR fits main's recent changes, how the host registers helpers and how each one ends, and the rows, output pairing and old clients.
    • Each fix was then re-checked on its own.
    • The readiness checklist passed with nothing at P0 or P1.
  • Checks: CI is all green at 70b75cc4f3b. The desktop and main-process typechecks and lint pass.
  • Live QA:
    • Ran with a real Codex 0.159 (GPT-5.5, default mode) against a background build of 4706d3df677.
    • All of these passed:
      • A helper that runs and finishes. Its section opened without a click, and its command's record was removed 4 ms after the command exited.
      • Closing a helper mid-command. The command was killed, and its record was removed 1 ms after it exited.
      • A command that outlives the helper's turn.
      • A plain chat, which shows no helper.
      • Quit and relaunch.
      • A check of the app logs, which showed no related errors.
    • The real ~/.codex files were unchanged throughout.

Not verified.

  • The long-prompt fix (70b75cc4f3b) was not in the QA build; only unit tests cover it.
  • The section opening was seen live, but never compared against a build without the fix.
  • Mobile tests were not run locally (this PR changes no mobile files).

One behaviour to know about: Codex can leave a command running after the helper's turn has ended. Until that command exits, the dock reads "1 shell command — working" under "Ran 1 subagent · completed". The row names the helper's task. This follows the rule from #22553 that a command stays live until its process exits.

@brennanb2025
brennanb2025 merged commit cb36344 into main Sep 30, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant