TypeScript
fix: prevent subagents inheriting parent settlement protections (#26035)
agentic-jarmo7f2ff41bc839
diff --git a/apps/server/src/orchestration-v2/SubagentProjection.test.ts b/apps/server/src/orchestration-v2/SubagentProjection.test.tsindex 95abcbaf5c1..c410d6682da 100644--- a/apps/server/src/orchestration-v2/SubagentProjection.test.ts+++ b/apps/server/src/orchestration-v2/SubagentProjection.test.ts@@ -120,14 +120,17 @@ it("keeps a subagent child awake when its parent thread is snoozed", () => {});});-it.effect.each([- ["sql", ProjectionStore.layer.pipe(Layer.provideMerge(SqlitePersistence.layerMemory))],-] as const)(- "%s: a pinned parent's subagent child is born unpinned and settles once idle",- ([, testLayer]) =>+it.effect.each(["provider", "mcp"] as const)(+ "a %s child does not inherit parent settlement protections and settles once idle",+ (creationSource) =>Effect.gen(function* () {const store = yield* ProjectionStore.ProjectionStoreV2;- const parentThread = { ...makeParentThread(), pinnedAt: parentCreatedAt, pinOrderKey: "a0" };+ const parentThread = {+ ...makeParentThread(),+ pinnedAt: parentCreatedAt,+ pinOrderKey: "a0",+ autoSettleDisabledAt: parentCreatedAt,+ };const childThread = makeSubagentChildThread({parentThread,childThreadId,@@ -138,13 +141,14 @@ it.effect.each([title: "Child",now: childCreatedAt,createdBy: "agent",- creationSource: "provider",+ creationSource,});assert.equal(parentThread.pinnedAt, parentCreatedAt);assert.equal(parentThread.pinOrderKey, "a0");assert.isNull(childThread.pinnedAt);assert.isNull(childThread.pinOrderKey);+ assert.isNull(childThread.autoSettleDisabledAt);for (const thread of [parentThread, childThread]) {yield* store.apply({@@ -158,6 +162,7 @@ it.effect.each([const savedParent = yield* store.getThread(parentThreadId);assert.deepEqual(savedParent.pinnedAt, parentCreatedAt);assert.equal(savedParent.pinOrderKey, "a0");+ assert.deepEqual(savedParent.autoSettleDisabledAt, parentCreatedAt);const candidates = yield* store.getSettlementCandidates();assert.deepEqual(candidates.map((candidate) => candidate.id),@@ -171,7 +176,9 @@ it.effect.each([autoSettleOnMerge: false,});assert.equal(settledAt && DateTime.formatIso(settledAt), DateTime.formatIso(childCreatedAt));- }).pipe(Effect.provide(testLayer)),+ }).pipe(+ Effect.provide(ProjectionStore.layer.pipe(Layer.provideMerge(SqlitePersistence.layerMemory))),+ ),);function taskFixture() {diff --git a/packages/provider-core/src/server/subagentProjection.ts b/packages/provider-core/src/server/subagentProjection.tsindex be8c4bf98aa..e18687414f9 100644--- a/packages/provider-core/src/server/subagentProjection.ts+++ b/packages/provider-core/src/server/subagentProjection.ts@@ -84,6 +84,7 @@ export function makeSubagentChildThread(input: {snoozedAt: null,pinnedAt: null,pinOrderKey: null,+ autoSettleDisabledAt: null,// A guest link belongs to the thread it was made for.guestShare: null,lastVisitedAt: null,