Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): subagent threads settle with their parent instead of sweeping on their own #19665

Mergedmikeohuo(GitHub profile, opens in a new tab)merged 9 commits intomain fromrefs/pull/19665/headmerged by juliusmarminge View on GitHub

Showing 5 changed files with 69 additions and 1 deletion (loading 2).

x
0 of 5 viewed, 5 left
42 additions and 0 deletionsapps/server/src/orchestration-v2/ProjectionSettlement.test.tsModified
View file
@@ -478,3 +478,45 @@
assert.equal(all.threads.length, 4);
}).pipe(Effect.provide(layerSql)),
+​
+it.effect("sql: a subagent thread becomes a candidate once its parent is done", () =>
+ Effect.gen(function* () {
+ const store = yield* ProjectionStore.ProjectionStoreV2;
+ const parent = yield* createThread("subagent-parent");
+ const child = yield* createThread("subagent-child", {
+ lineage: { parentThreadId: parent, relationshipToParent: "subagent", rootThreadId: parent },
+ });
+ const ids = () =>
+ store.getSettlementCandidates().pipe(Effect.map((rows) => rows.map((row) => row.id)));
+ assert.deepEqual(yield* ids(), [parent]);
+​
+ const parentThread = yield* store.getThread(parent);
+ for (const [type, overrides] of [
+ ["thread.settled", { settledOverride: "settled", settledAt: now }],
+ ["thread.archived", { archivedAt: now }],
+ ["thread.deleted", { deletedAt: now }],
+ ] satisfies ReadonlyArray<
+ readonly [
+ "thread.settled" | "thread.archived" | "thread.deleted",
+ Partial<OrchestrationV2AppThread>,
+ ]
+ >) {
+ yield* store.apply({
+ id: EventId.make(`event:settlement:subagent-parent:${type}`),
+ type,