Skip to content

Commit 88fd4f3

Browse files
committed
fix(server): carry child approvals through side chat ancestors
1 parent 463ad6b commit 88fd4f3

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

‎apps/server/src/relay/AgentAwarenessRelay.test.ts‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,13 +340,30 @@ const makeTestRelay = Effect.fnUntraced(function* (
340340
});
341341

342342
describe("AgentAwarenessRelay", () => {
343-
it.effect("publishes an approval already waiting at startup", () =>
343+
it.effect.each([false, true])("publishes a startup approval through side chat: %s", (sideChat) =>
344344
Effect.gen(function* () {
345345
const parent = shell({ status: "idle" });
346-
const child = waitingChild();
346+
const intermediate = shell({
347+
id: SECOND_THREAD_ID,
348+
lineage: {
349+
rootThreadId: THREAD_ID,
350+
parentThreadId: THREAD_ID,
351+
relationshipToParent: null,
352+
sideChat: true,
353+
},
354+
});
355+
const child = waitingChild({
356+
lineage: {
357+
rootThreadId: THREAD_ID,
358+
parentThreadId: sideChat ? intermediate.id : parent.id,
359+
relationshipToParent: "subagent",
360+
},
361+
});
362+
const startupThreads = [parent, intermediate, child];
347363
const { relay, publications } = yield* makeTestRelay({
348-
startupThreads: [parent, child],
349-
readShell: (id) => Effect.succeed(id === child.id ? child : parent),
364+
startupThreads,
365+
readShell: (id) =>
366+
Effect.succeed(startupThreads.find((thread) => thread.id === id) ?? null),
350367
});
351368
yield* relay.start();
352369
yield* TestClock.adjust("1 second");

‎apps/server/src/relay/AgentAwarenessRelay.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,10 @@ export const make = Effect.gen(function* () {
730730
const findTopLevelThreadId = Effect.fnUntraced(function* (child: OrchestrationV2ThreadShell) {
731731
const seen = new Set<ThreadId>([child.id]);
732732
let current: OrchestrationV2ThreadShell | null = child;
733-
while (current?.lineage.relationshipToParent === "subagent") {
733+
while (
734+
current?.lineage.relationshipToParent === "subagent" ||
735+
current?.lineage.sideChat === true
736+
) {
734737
const parentId: ThreadId | null = current.lineage.parentThreadId;
735738
if (parentId === null || seen.has(parentId)) return null;
736739
seen.add(parentId);

0 commit comments

Comments
 (0)