Skip to content

Commit e58a28d

Browse files
committed
test: prove deferred system event drain
1 parent 053f835 commit e58a28d

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

‎src/auto-reply/reply/get-reply-run.media-only.test.ts‎

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2527,12 +2527,16 @@ describe("runPreparedReply media-only handling", () => {
25272527

25282528
nextRun.complete();
25292529
});
2530-
it("re-drains system events after waiting behind an active run", async () => {
2530+
it("drains system events only after waiting behind an active run", async () => {
2531+
const actualSystemEvents = await vi.importActual<typeof import("./session-system-events.js")>(
2532+
"./session-system-events.js",
2533+
);
2534+
vi.mocked(drainFormattedSystemEvents).mockImplementation(
2535+
actualSystemEvents.drainFormattedSystemEvents,
2536+
);
25312537
const queueSettings = await import("./queue/settings-runtime.js");
25322538
vi.mocked(queueSettings.resolveQueueSettings).mockReturnValueOnce({ mode: "interrupt" });
2533-
vi.mocked(drainFormattedSystemEvents)
2534-
.mockResolvedValueOnce("System: [t] Initial event.")
2535-
.mockResolvedValueOnce("System: [t] Post-compaction context.");
2539+
enqueueSystemEvent("System event after active run", { sessionKey: "session-key" });
25362540

25372541
const previousRun = createReplyOperation({
25382542
sessionId: "session-events-after-wait",
@@ -2544,19 +2548,24 @@ describe("runPreparedReply media-only handling", () => {
25442548
const runPromise = runPrepared({
25452549
isNewSession: false,
25462550
sessionId: "session-events-after-wait",
2551+
provider: "",
2552+
model: "",
2553+
resolvedThinkLevel: "off",
25472554
});
25482555

25492556
await Promise.resolve();
2557+
expect(peekSystemEventEntries("session-key").map((event) => event.text)).toEqual([
2558+
"System event after active run",
2559+
]);
25502560
previousRun.complete();
25512561

25522562
await expect(runPromise).resolves.toEqual({ text: "ok" });
25532563
const call = requireLastRunReplyAgentCall();
2554-
expect(call?.commandBody).toContain("System: [t] Initial event.");
2555-
expect(call?.commandBody).not.toContain("System: [t] Post-compaction context.");
2556-
expect(call?.transcriptCommandBody).not.toContain("System: [t] Initial event.");
2557-
expect(call?.followupRun.prompt).toContain("System: [t] Initial event.");
2558-
expect(call?.followupRun.prompt).not.toContain("System: [t] Post-compaction context.");
2559-
expect(call?.followupRun.transcriptPrompt).not.toContain("System: [t] Initial event.");
2564+
expect(call?.commandBody).toContain("System event after active run");
2565+
expect(call?.transcriptCommandBody).not.toContain("System event after active run");
2566+
expect(call?.followupRun.prompt).toContain("System event after active run");
2567+
expect(call?.followupRun.transcriptPrompt).not.toContain("System event after active run");
2568+
expect(peekSystemEventEntries("session-key")).toStrictEqual([]);
25602569
});
25612570

25622571
it("threads inbound context as current-turn context without changing transcript text", async () => {

0 commit comments

Comments
 (0)