Skip to content

fix(server): preserve native Codex subagent lifecycle in v2 - #11996

Closed
lnieuwenhuis wants to merge 3 commits into
pingdotgg:t3code/codex-turn-mappingfrom
lnieuwenhuis:fix/v2-codex-subagent-statuses
Closed

lnieuwenhuis wants to merge 3 commits into
pingdotgg:t3code/codex-turn-mappingfrom
lnieuwenhuis:fix/v2-codex-subagent-statuses

Conversation

@lnieuwenhuis

@lnieuwenhuis lnieuwenhuis commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex collaboration events use native statuses that the V2 adapter was treating as running, leaving interrupted, shut-down, and missing children active and initializing children incorrectly marked as executing.

Map all seven native statuses explicitly. Keep initializing children protected from idle release and promote them on their first native turn, including when the child start arrives before its spawn snapshot. Settle both registration execution nodes for children that terminate before their first native turn; native-turn events retain ownership once execution starts.

Targets t3code/codex-turn-mapping for #2829. Refs #11164. #11608 addresses the separate client-runtime path on main; this fixes the V2 provider adapter.

Validation: 91 adapter replay tests pass, including regressions observed failing before the fix; scoped server typecheck and targeted lint/format pass. Independent adversarial reviews found lifecycle gaps that were fixed with regression coverage. A subsequent Macroscope finding about children terminating before their first native turn was reproduced and fixed; a fresh adversarial review of that fix reported no findings. Changed files pass the secrets scan. No live-provider verification.

The repository scanner config retains default rules and exempts only the exact synthetic idempotencyKey fixture in packages/effect-codex-app-server/src/protocol.test.ts, which otherwise flags twice in the inherited V2 history. Negative controls confirm other values, keys, paths, and credential rules remain detected.

Implemented with GPT-6 Astra via Codex.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XXL 1,000+ changed lines (additions + deletions). labels Sep 16, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Macroscope has since reviewed this pull request. An earlier review was skipped by a cost limit; a review has now completed, so that notice no longer applies.

@macroscopeapp

macroscopeapp Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 7630e9e

Macroscope's review found this PR approvable — This is a contained Codex adapter bug fix that corrects native subagent status and lifecycle projection, including idle-retention behavior. The changes add no schema or deployment surface and include broad replay coverage for status and event-order cases.

You can add or adjust custom eligibility rules. Learn more.

@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:XXL 1,000+ changed lines (additions + deletions). labels Sep 16, 2026
Comment thread apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
@juliusmarminge
juliusmarminge force-pushed the t3code/codex-turn-mapping branch 3 times, most recently from f63b335 to 08a1b86 Compare September 16, 2026 07:02
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Sep 16, 2026

@macroscopeapp macroscopeapp 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.

All clear

Posted via Macroscope — Effect Service Conventions

@juliusmarminge
juliusmarminge force-pushed the t3code/codex-turn-mapping branch 6 times, most recently from a1f8051 to 0337dd6 Compare September 21, 2026 05:40
@juliusmarminge
juliusmarminge force-pushed the fix/v2-codex-subagent-statuses branch from 6603dbc to 7630e9e Compare September 21, 2026 20:25
@juliusmarminge

Copy link
Copy Markdown
Member

Rebased this PR onto the current t3code/codex-turn-mapping at 4a4c22b29c.

What changed on the branch

  • The two "reconcile" merge commits (e194c16dca, 6603dbc876) were dropped. They carried a stale copy of the v2 branch and would have reverted recent v2 work (plus a .gitleaks.toml change that does not belong here). Only your three content commits remain, cherry-picked in order: map native statuses, retain initializing subagents, settle nodes before native turns. All three applied cleanly against the current CodexAdapterV2.ts; no manual conflict resolution was needed.
  • No code edits of my own. I checked that "pending" is still a valid OrchestrationV2Subagent["status"] in packages/contracts/src/orchestrationV2.ts, and that v2's "Map nested Codex subagent threads correctly" change does not overlap with your agentsStates mapping (it only changed node parent ids), so each native status is mapped exactly once via codexSubagentStatus.

Verified

  • vp test run src/orchestration-v2/Adapters/CodexAdapterV2.test.ts in apps/server: 108 passed.
  • vpr typecheck in apps/server: clean (only pre-existing Effect suggestions).

Left for you / a maintainer

  • If you need to pick up future v2 changes, please rebase rather than merging the base branch in; the merge-based reconcile is what caused the revert risk.

Rebased and touched up by a maintainer's agent; a human will re-review.

Comment on lines +5443 to +5453
for (const [nativeStatus, expectedStatus, terminal] of [
["pendingInit", "pending", false],
["running", "running", false],
["interrupted", "interrupted", true],
["completed", "completed", true],
["errored", "failed", true],
["shutdown", "cancelled", true],
["notFound", "failed", true],
] as const) {
for (const nativeTurnStarted of [false, true]) {
it.effect(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it.effect.each

Comment on lines +5578 to +5579
for (const childStartsFirst of [false, true]) {
it.effect(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it.effect.each

@juliusmarminge

Copy link
Copy Markdown
Member

Superseded by merged PR #12974, which includes the Codex V2 native subagent-status lifecycle fixes and broader settlement/reopen handling. Closing this older implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants