Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): restart recovery keeps a finished delegated child's background tasks #28994

ClosedNotAnNvidiaFan(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/28994/headopened View on GitHub

Showing 2 changed files with 111 additions and 0 deletions.

x
0 of 2 viewed, 2 left
108 additions and 0 deletionsapps/server/src/orchestration-v2/ProjectionRecovery.test.tsModified
View file
@@ -1082,6 +1082,114 @@
}).pipe(Effect.provide(layerRecoveryTest)),
+it.effect("leaves a finished delegated child's background roster to the child", () =>
+ Effect.gen(function* () {
+ const projections = yield* ProjectionStore.ProjectionStoreV2;
+ const recovery = yield* ProviderRuntimeRecovery.ProviderRuntimeRecoveryService;
+ const sql = yield* SqlClient.SqlClient;
+ const now = yield* DateTime.now;
+ // The parent sorts first, so it is reconciled before the child.
+ const parent = yield* createThread("delegation");
+ yield* createRun(parent, "completed");
+ const child = yield* createThread("delegation:child", {
+ lineage: { parentThreadId: parent, relationshipToParent: "subagent", rootThreadId: parent },
+ });
+ const childProviderThreadId = ProviderThreadId.make(`provider-thread:${child}`);
+ const childSessionId = ProviderSessionId.make(`session:${child}`);
+ yield* projections.apply({
+ id: EventId.make(`event:${child}:session`),
+ type: "provider-session.attached",
+ threadId: child,
+ driver,
+ providerInstanceId,
+ occurredAt: now,
+ payload: {
+ id: childSessionId,
+ driver,
+ providerInstanceId,
+ status: "ready",