Skip to content

Fix Codex subagent relinking after session resume - #2539

Merged
SawyerHood merged 5 commits into
get-bb:mainfrom
peterfotinis:fix/codex-resumed-subagent-parent-link
Aug 28, 2026
Merged

Fix Codex subagent relinking after session resume#2539
SawyerHood merged 5 commits into
get-bb:mainfrom
peterfotinis:fix/codex-resumed-subagent-parent-link

Conversation

@peterfotinis

@peterfotinis peterfotinis commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

A recreated Codex translator loses its in-memory parent mapping for durable historical subagents. When the root later calls followup_task, Codex emits an interacted activity for the child, but current app-server does not forward the raw collaboration call. BB therefore discarded the only surviving activity because the fresh translator did not know the child. The following child turn had no parentToolCallId and was projected as foreground/root work, violating the runtime invariant that delegated child work must remain attached to its parent tool call. A later user prompt to the root could then be rejected as a competing turn.

Issue #2538 documents this restart/resume gap left after the in-session correlation added in #1361; the earlier investigation in #807 describes the same failure class.

What changed

  • Preserve raw followup_task versus send_message intent when Codex supplies it, but do not require that notification.
  • Hold an unknown interacted activity until a non-user-initiated child turn/started proves it was turn-producing, then reconstruct the delegation and attach that child turn.
  • Discard an unclassified interaction when its parent turn completes without starting a child, so send_message cannot steal a later human or subagent turn.
  • Prefer queued native user turns and known delegation links before rawless inference.
  • Add restart/resume, message-only, native-turn, queued-followup, and concurrent-subagent regression coverage.
  • Keep HOST_DAEMON_PROTOCOL_VERSION at 171 because this restores the existing parentToolCallId contract without a wire schema change.

How you verified

  • Reproduced the failure in an isolated desktop build on Codex CLI 0.149.0: after a full BB restart, a resumed child was stored as a root turn and the next user prompt was rejected as a competing turn.
  • Repeated the same workflow on the fixed build: the rawless resumed child received parentToolCallId, its delegation row had no self-parent, and a root prompt submitted while the child was running was accepted instead of rejected.
  • Codex provider: 242/242 tests passed.
  • Runtime turn-state: 9/9 tests passed.
  • Repository lint and all 80 typecheck tasks passed; the changed files pass formatting and git diff --check.
  • Built and launched the isolated Electron desktop app from this branch for the end-to-end checks above.
  • After removal of the protocol bump, the focused Codex translator tests passed 41/41 and the host contract tests passed 37/37 on Node 22.

Fixes #2538

AGENT GENERATED

@SawyerHood
SawyerHood force-pushed the fix/codex-resumed-subagent-parent-link branch from 74af01c to 37397cc Compare August 27, 2026 23:24
@SawyerHood

Copy link
Copy Markdown
Collaborator

Updated this branch onto current main. The current head restores the correct portable gzip expectations and adds rawless child-isolation coverage. Local validation passed 51 host-daemon contract tests, 249 Codex provider tests, and both typechecks. GitHub CI passed all 11 checks.

@SawyerHood
SawyerHood merged commit cffeb56 into get-bb:main Aug 28, 2026
13 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.

Bug - Refusing to start a competing turn for thread "<threadid>" while another turn is active or starting (Codex)

3 participants