Skip to content

Fix Codex subagent relinking after session resume - #2539

Open
peterfotinis wants to merge 3 commits into
get-bb:mainfrom
peterfotinis:fix/codex-resumed-subagent-parent-link
Open

Fix Codex subagent relinking after session resume#2539
peterfotinis wants to merge 3 commits into
get-bb:mainfrom
peterfotinis:fix/codex-resumed-subagent-parent-link

Conversation

@peterfotinis

@peterfotinis peterfotinis commented Aug 27, 2026

Copy link
Copy Markdown

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.
  • Bump HOST_DAEMON_PROTOCOL_VERSION from 171 to 172 because daemon-visible turn-parent semantics changed.

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 two 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.

Fixes #2538

AGENT GENERATED

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)

2 participants