Skip to content

Commit 7f2ff41

Browse files
agentic-jarmojamomaria-rcks
authored
fix: prevent subagents inheriting parent settlement protections (pingdotgg#26035)
Co-authored-by: Jarmo Isotalo <[email protected]> Co-authored-by: maria-rcks <[email protected]>
1 parent 076aacc commit 7f2ff41

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,17 @@ it("keeps a subagent child awake when its parent thread is snoozed", () => {
120120
});
121121
});
122122

123-
it.effect.each([
124-
["sql", ProjectionStore.layer.pipe(Layer.provideMerge(SqlitePersistence.layerMemory))],
125-
] as const)(
126-
"%s: a pinned parent's subagent child is born unpinned and settles once idle",
127-
([, testLayer]) =>
123+
it.effect.each(["provider", "mcp"] as const)(
124+
"a %s child does not inherit parent settlement protections and settles once idle",
125+
(creationSource) =>
128126
Effect.gen(function* () {
129127
const store = yield* ProjectionStore.ProjectionStoreV2;
130-
const parentThread = { ...makeParentThread(), pinnedAt: parentCreatedAt, pinOrderKey: "a0" };
128+
const parentThread = {
129+
...makeParentThread(),
130+
pinnedAt: parentCreatedAt,
131+
pinOrderKey: "a0",
132+
autoSettleDisabledAt: parentCreatedAt,
133+
};
131134
const childThread = makeSubagentChildThread({
132135
parentThread,
133136
childThreadId,
@@ -138,13 +141,14 @@ it.effect.each([
138141
title: "Child",
139142
now: childCreatedAt,
140143
createdBy: "agent",
141-
creationSource: "provider",
144+
creationSource,
142145
});
143146

144147
assert.equal(parentThread.pinnedAt, parentCreatedAt);
145148
assert.equal(parentThread.pinOrderKey, "a0");
146149
assert.isNull(childThread.pinnedAt);
147150
assert.isNull(childThread.pinOrderKey);
151+
assert.isNull(childThread.autoSettleDisabledAt);
148152

149153
for (const thread of [parentThread, childThread]) {
150154
yield* store.apply({
@@ -158,6 +162,7 @@ it.effect.each([
158162
const savedParent = yield* store.getThread(parentThreadId);
159163
assert.deepEqual(savedParent.pinnedAt, parentCreatedAt);
160164
assert.equal(savedParent.pinOrderKey, "a0");
165+
assert.deepEqual(savedParent.autoSettleDisabledAt, parentCreatedAt);
161166
const candidates = yield* store.getSettlementCandidates();
162167
assert.deepEqual(
163168
candidates.map((candidate) => candidate.id),
@@ -171,7 +176,9 @@ it.effect.each([
171176
autoSettleOnMerge: false,
172177
});
173178
assert.equal(settledAt && DateTime.formatIso(settledAt), DateTime.formatIso(childCreatedAt));
174-
}).pipe(Effect.provide(testLayer)),
179+
}).pipe(
180+
Effect.provide(ProjectionStore.layer.pipe(Layer.provideMerge(SqlitePersistence.layerMemory))),
181+
),
175182
);
176183

177184
function taskFixture() {

‎packages/provider-core/src/server/subagentProjection.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export function makeSubagentChildThread(input: {
8484
snoozedAt: null,
8585
pinnedAt: null,
8686
pinOrderKey: null,
87+
autoSettleDisabledAt: null,
8788
// A guest link belongs to the thread it was made for.
8889
guestShare: null,
8990
lastVisitedAt: null,

0 commit comments

Comments
 (0)