fix: harden routing/session isolation for followups and heartbeat

This commit is contained in:
Peter Steinberger
2026-02-24 23:13:51 +00:00
parent 7655c0cb3a
commit ccbeb332e0
15 changed files with 209 additions and 15 deletions

View File

@@ -1046,6 +1046,51 @@ describe("followup queue collect routing", () => {
expect(calls[0]?.prompt).toContain("[Queue overflow] Dropped 1 message due to cap.");
expect(calls[0]?.prompt).toContain("- first");
});
it("preserves routing metadata on overflow summary followups", async () => {
const key = `test-overflow-summary-routing-${Date.now()}`;
const calls: FollowupRun[] = [];
const done = createDeferred<void>();
const runFollowup = async (run: FollowupRun) => {
calls.push(run);
done.resolve();
};
const settings: QueueSettings = {
mode: "followup",
debounceMs: 0,
cap: 1,
dropPolicy: "summarize",
};
enqueueFollowupRun(
key,
createRun({
prompt: "first",
originatingChannel: "discord",
originatingTo: "channel:C1",
originatingThreadId: "1739142736.000100",
}),
settings,
);
enqueueFollowupRun(
key,
createRun({
prompt: "second",
originatingChannel: "discord",
originatingTo: "channel:C1",
originatingThreadId: "1739142736.000100",
}),
settings,
);
scheduleFollowupDrain(key, runFollowup);
await done.promise;
expect(calls[0]?.originatingChannel).toBe("discord");
expect(calls[0]?.originatingTo).toBe("channel:C1");
expect(calls[0]?.originatingThreadId).toBe("1739142736.000100");
expect(calls[0]?.prompt).toContain("[Queue overflow] Dropped 1 message due to cap.");
});
});
const emptyCfg = {} as OpenClawConfig;