GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): Codex session release ends the work its dead process lef… · pingdotgg/t3code@69cb6b5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src/orchestration-v2
    • Adapters
      • CodexAdapterV2.ts
    • RunExecutionService.test.ts
    • RunExecutionService.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7850,6 +7850,8 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
78507850
providerSessionId: input.providerSessionId,
78517851
providerSession: session,
78527852
events: Stream.fromEffectRepeat(Queue.take(events)),
7853+
// The app-server is this session's child process; its commands and subagents die with it.
7854+
backgroundTasksEndWithProcess: true,
78537855
canReuseContextUsage: canReuseCodexContextUsage,
78547856
normalizeThreadLoadModelSelection: normalizeCodexThreadLoadModelSelection,
78557857
// Idle release can beat delayed subagent resumes: Codex reports them completed between turns with no resume-expected signal.
Collapse file

‎apps/server/src/orchestration-v2/RunExecutionService.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/RunExecutionService.test.ts
-56Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3566,62 +3566,6 @@ it.effect("ends a running root command when the provider stream fails mid-turn",
35663566
}),
35673567
);
35683568

3569-
it.effect("ends a subagent that outlived its root when the provider stream fails", () =>
3570-
Effect.gen(function* () {
3571-
const providerInstanceId = ProviderInstanceId.make("codex");
3572-
const { finalEvents } = yield* captureRootRunTermination({
3573-
key: "stream-error-outlived-subagent",
3574-
shouldFinalizeRun: () => Effect.succeed(true),
3575-
events: (ids) =>
3576-
Stream.make(
3577-
{
3578-
type: "subagent.updated" as const,
3579-
driver,
3580-
subagent: makeRunOwnedSubagentFixture({
3581-
ids,
3582-
providerInstanceId,
3583-
childThreadId: ids.childThreadId,
3584-
driver,
3585-
status: "running",
3586-
}),
3587-
},
3588-
{
3589-
type: "turn_item.updated" as const,
3590-
driver,
3591-
turnItem: makeRunOwnedSubagentTurnItemFixture({
3592-
ids,
3593-
providerInstanceId,
3594-
childThreadId: ids.childThreadId,
3595-
driver,
3596-
status: "running",
3597-
}),
3598-
},
3599-
rootTerminalEvent(ids, "completed"),
3600-
).pipe(
3601-
Stream.concat(
3602-
Stream.fail(
3603-
new ProviderAdapter.ProviderAdapterEventStreamError({
3604-
driver,
3605-
providerSessionId: ProviderSessionId.make("session:stream-error-outlived-subagent"),
3606-
cause: "provider process exited",
3607-
}),
3608-
),
3609-
),
3610-
),
3611-
});
3612-
assert.deepEqual(
3613-
finalEvents.flatMap((event) =>
3614-
event.type === "run.updated" ||
3615-
event.type === "subagent.updated" ||
3616-
event.type === "turn-item.updated"
3617-
? [`${event.type}:${event.payload.status}`]
3618-
: [],
3619-
),
3620-
["run.updated:waiting", "subagent.updated:failed", "turn-item.updated:failed"],
3621-
);
3622-
}),
3623-
);
3624-
36253569
it.effect("does not interrupt a provider when ingestion fails before the root turn is known", () =>
36263570
Effect.gen(function* () {
36273571
const interrupts = yield* Ref.make(0);
Collapse file

‎apps/server/src/orchestration-v2/RunExecutionService.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/RunExecutionService.ts
+9-43Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ export const layer: Layer.Layer<
11921192
ReadonlySet<OrchestrationV2TurnItem["id"]>
11931193
>(new Set(inheritedBackgroundTurnItemsById.keys()));
11941194
const openRunOwnedSubagents = yield* Ref.make(emptyOpenRunOwnedSubagentProjection());
1195-
// Open root-thread commands and tools of this run; only an ingestion failure ends them.
1195+
// Open root-thread commands and tools of this run; an ingestion failure that stops the provider ends them.
11961196
const openRootTurnItems = new Map<TurnItemId, OrchestrationV2TurnItem>();
11971197
// The last stored root snapshot's pendingBackgroundWork; adapters that omit it leave it false.
11981198
let rootSnapshotPendingWork = false;
@@ -1884,46 +1884,7 @@ export const layer: Layer.Layer<
18841884
runId: input.run.id,
18851885
cause,
18861886
});
1887-
if (yield* Ref.get(rootRunFinalized)) {
1888-
// The root settled earlier, but work that outlived it has no stream to end it.
1889-
const allocateEventId = () =>
1890-
idAllocator.allocate.event({ threadId: input.run.threadId });
1891-
const open = yield* Ref.getAndSet(
1892-
openRunOwnedSubagents,
1893-
emptyOpenRunOwnedSubagentProjection(),
1894-
);
1895-
const abandoned = [...openRootTurnItems.values()];
1896-
openRootTurnItems.clear();
1897-
const events = [
1898-
...(yield* cascadeTerminalizeRunOwnedSubagents({
1899-
run: input.run,
1900-
open,
1901-
status: "failed",
1902-
completedAt,
1903-
allocateEventId,
1904-
})),
1905-
...(yield* endAbandonedTurnItems({
1906-
run: input.run,
1907-
items: abandoned,
1908-
status: "failed",
1909-
completedAt,
1910-
allocateEventId,
1911-
})),
1912-
];
1913-
if (events.length === 0) return;
1914-
yield* eventSink.writeWithEffects({ effects: [], events }).pipe(
1915-
Effect.andThen(refreshAfterTurn),
1916-
Effect.catchCauseIf(
1917-
(writeCause) => !Cause.hasInterruptsOnly(writeCause),
1918-
(writeCause) =>
1919-
Effect.logWarning(
1920-
"orchestration V2 failed to end work that outlived its run",
1921-
{ runId: input.run.id, cause: writeCause },
1922-
),
1923-
),
1924-
);
1925-
return;
1926-
}
1887+
if (yield* Ref.get(rootRunFinalized)) return;
19271888
const providerThread = yield* Ref.get(latestProviderThread);
19281889
// Stop background work too; the failed consumer cannot persist terminal events.
19291890
const abandonedProviderTurn =
@@ -1974,8 +1935,13 @@ export const layer: Layer.Layer<
19741935
expectedStatus: "running",
19751936
},
19761937
openRunOwnedSubagents: openSubagents,
1977-
abandonedTurnItems: [...openRootTurnItems.values()],
1978-
...(abandonedProviderTurn === null ? {} : { abandonedProviderTurn }),
1938+
...(abandonedProviderTurn === null
1939+
? {}
1940+
: {
1941+
abandonedProviderTurn,
1942+
// The interrupt restarted the runtime, so these items cannot end.
1943+
abandonedTurnItems: [...openRootTurnItems.values()],
1944+
}),
19791945
completedAt,
19801946
terminal: makeFailedTerminalEvent(
19811947
makeProviderFailure({

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.