fix(server): preserve native Codex subagent lifecycle in v2 #11996
Closedlnieuwenhuis(GitHub profile, opens in a new tab)wants to merge 3 commits into
t3code/codex-turn-mapping fromrefs/pull/11996/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XXL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts line 2627OutdatedResolvedby lnieuwenhuis(GitHub profile, opens in a new tab)@@ -2650,13 +2670,11 @@26502670 if (subagent === undefined) {26512671 continue;26522672 }2653- const nativeStatus = String(state.status);2654- const status: OrchestrationV2Subagent["status"] =2655- nativeStatus === "completed"2656- ? "completed"2657- : nativeStatus === "failed" || nativeStatus === "errored"2658- ? "failed"2659- : nativeStatus === "cancelled" || nativeStatus === "closed"2660- ? "cancelled"2661- : "running";2673+ const status = codexSubagentStatus(state.status);2674+ // A child turn can start before its spawn snapshot arrives.2675+ const alreadyStarted =2676+ status === "pending" &&2677+ Array.from((yield* Ref.get(activeTurns)).values()).some(2678+ (context) => context.subagent === subagent,2679+ );26622680 yield* emitSubagentTaskUpdate({
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge requested changes
@@ -5440,3 +5440,14 @@54405440 ),54415441 );544254425443+ for (const [nativeStatus, expectedStatus, terminal] of [5444+ ["pendingInit", "pending", false],5445+ ["running", "running", false],5446+ ["interrupted", "interrupted", true],5447+ ["completed", "completed", true],5448+ ["errored", "failed", true],5449+ ["shutdown", "cancelled", true],5450+ ["notFound", "failed", true],5451+ ] as const) {5452+ for (const nativeTurnStarted of [false, true]) {5453+ it.effect(@@ -5442,0 +5559,21 @@5559+ const projectedItems = harness.events5560+ .filter(5561+ (5562+ event,5563+ ): event is Extract<ProviderAdapterV2Event, { type: "turn_item.updated" }> =>5564+ event.type === "turn_item.updated" && event.turnItem.type === "subagent",5565+ )5566+ .slice(-2);5567+ assert.lengthOf(projectedItems, 2);5568+ for (const event of projectedItems) {5569+ assert.equal(event.turnItem.status, taskStatus);5570+ assert.deepEqual(event.turnItem.completedAt, terminal ? now : null);5571+ }5572+ }).pipe(Effect.provide(Layer.merge(idAllocatorLayer, NodeServices.layer))),5573+ ),5574+ );5575+ }5576+ }5577+5578+ for (const childStartsFirst of [false, true]) {5579+ it.effect(juliusmarminge closed this
Sign in to join this conversation.
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.