fix: queue model switches behind busy runs
parent
6776306387
commit
622b91d04e
@ -0,0 +1,62 @@
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { clearFollowupQueue, getFollowupQueue, refreshQueuedFollowupSession } from "./state.js";
|
||||
import type { FollowupRun } from "./types.js";
|
||||
|
||||
const QUEUE_KEY = "agent:main:dm:test";
|
||||
|
||||
afterEach(() => {
|
||||
clearFollowupQueue(QUEUE_KEY);
|
||||
});
|
||||
|
||||
function makeRun(): FollowupRun["run"] {
|
||||
return {
|
||||
agentId: "main",
|
||||
agentDir: "/tmp/agent",
|
||||
sessionId: "session-1",
|
||||
sessionKey: QUEUE_KEY,
|
||||
sessionFile: "/tmp/session-1.jsonl",
|
||||
workspaceDir: "/tmp/workspace",
|
||||
config: {} as FollowupRun["run"]["config"],
|
||||
provider: "anthropic",
|
||||
model: "claude-opus-4-5",
|
||||
authProfileId: "profile-a",
|
||||
authProfileIdSource: "user",
|
||||
timeoutMs: 30_000,
|
||||
blockReplyBreak: "message_end",
|
||||
};
|
||||
}
|
||||
|
||||
describe("refreshQueuedFollowupSession", () => {
|
||||
it("retargets queued runs to the persisted selection", () => {
|
||||
const queue = getFollowupQueue(QUEUE_KEY, { mode: "queue" });
|
||||
const lastRun = makeRun();
|
||||
const queuedRun: FollowupRun = {
|
||||
prompt: "queued message",
|
||||
enqueuedAt: Date.now(),
|
||||
run: makeRun(),
|
||||
};
|
||||
queue.lastRun = lastRun;
|
||||
queue.items.push(queuedRun);
|
||||
|
||||
refreshQueuedFollowupSession({
|
||||
key: QUEUE_KEY,
|
||||
nextProvider: "openai",
|
||||
nextModel: "gpt-4o",
|
||||
nextAuthProfileId: undefined,
|
||||
nextAuthProfileIdSource: undefined,
|
||||
});
|
||||
|
||||
expect(queue.lastRun).toMatchObject({
|
||||
provider: "openai",
|
||||
model: "gpt-4o",
|
||||
authProfileId: undefined,
|
||||
authProfileIdSource: undefined,
|
||||
});
|
||||
expect(queue.items[0]?.run).toMatchObject({
|
||||
provider: "openai",
|
||||
model: "gpt-4o",
|
||||
authProfileId: undefined,
|
||||
authProfileIdSource: undefined,
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue