Skip to content

Commit ea1e68b

Browse files
shivamhwpclaude
andcommitted
fix(server): a relink republishes a parent whose child still waits
A catch-up re-read an unchanged waiting child and returned before enqueueing its parent, so a completed parent never reached the new relay. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent ff19c7c commit ea1e68b

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,32 @@ describe("AgentAwarenessRelay", () => {
375375
}),
376376
);
377377

378+
it.effect("republishes a completed parent for its waiting child after a relink", () =>
379+
Effect.gen(function* () {
380+
const parent = shell({ status: "completed" });
381+
const child = waitingChild();
382+
const { relay, secrets, publications } = yield* makeTestRelay({
383+
catchUpThreads: [parent, child],
384+
readShell: (id) => Effect.succeed(id === child.id ? child : parent),
385+
});
386+
yield* relay.start();
387+
yield* TestClock.adjust("1 second");
388+
yield* relay.drain;
389+
assert.equal(publications.length, 1);
390+
assert.equal(publications[0]?.state?.phase, "waiting_for_approval");
391+
392+
yield* secrets.set(
393+
RELAY_ENVIRONMENT_CREDENTIAL_SECRET,
394+
new TextEncoder().encode("credential-2"),
395+
);
396+
yield* relay.requestCatchUp();
397+
yield* TestClock.adjust("1 second");
398+
yield* relay.drain;
399+
assert.equal(publications.length, 2);
400+
assert.equal(publications[1]?.state?.phase, "waiting_for_approval");
401+
}).pipe(Effect.scoped),
402+
);
403+
378404
it.effect("keeps a child's alert time when the parent's own request comes and goes", () =>
379405
Effect.gen(function* () {
380406
const shells = yield* Ref.make(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ export const make = Effect.gen(function* () {
729729
) {
730730
const requestId = waitingApprovalId(threadShell);
731731
const previous = subagentRequests.get(threadId);
732-
if (previous?.requestId === requestId) return;
732+
// An unchanged wait still republishes its parent: a relink catch-up reaches it only here.
733733
if (threadShell === null || requestId === undefined) {
734734
if (previous === undefined) return;
735735
subagentRequests.delete(threadId);

0 commit comments

Comments
 (0)