tests / continuation.test.ts
import { describe, expect, test } from "vitest";
import { CONTINUATION_PREFIX, continuationNote, lastUserRequest, resumedRequestNote } from "../src/continuation";
describe("continuation notes", () => {
test("quote the user's last request without text other plugins added", () => {
const msgs = [
{ role: "user" as const, text: "Research vLLM." },
{ role: "assistant" as const, text: "Done." },
{ role: "user" as const, text: "Now SGLang, the same way.\n\n[throughLine: quarry]\nGoal: compare\n[end throughLine]" },
{ role: "assistant" as const, text: "" },
{ role: "tool" as const, text: "results" },
];
expect(lastUserRequest(msgs)).toBe("Now SGLang, the same way.");
const note = continuationNote(lastUserRequest(msgs));
expect(note.startsWith(CONTINUATION_PREFIX)).toBe(true);
expect(note).toContain('"Now SGLang, the same way."');
expect(note).toContain("give the answer and stop");
expect(note).not.toMatch(/summarize the final result/i);
});
test("skip earlier continuation notes and long requests are cut at a word", () => {
const long = "word ".repeat(200).trim();
const msgs = [
{ role: "user" as const, text: long },
{ role: "user" as const, text: continuationNote("x") },
];
const q = lastUserRequest(msgs);
expect(q.length).toBeLessThanOrEqual(400);
expect(q.endsWith("…")).toBe(true);
});
test("fall back to a generic note when no request is found", () => {
expect(continuationNote("")).toContain("Continue answering the user's last message.");
expect(resumedRequestNote("")).toContain("summarized above");
});
});
tests / continuation.test.ts
import { describe, expect, test } from "vitest";
import { CONTINUATION_PREFIX, continuationNote, lastUserRequest, resumedRequestNote } from "../src/continuation";
describe("continuation notes", () => {
test("quote the user's last request without text other plugins added", () => {
const msgs = [
{ role: "user" as const, text: "Research vLLM." },
{ role: "assistant" as const, text: "Done." },
{ role: "user" as const, text: "Now SGLang, the same way.\n\n[throughLine: quarry]\nGoal: compare\n[end throughLine]" },
{ role: "assistant" as const, text: "" },
{ role: "tool" as const, text: "results" },
];
expect(lastUserRequest(msgs)).toBe("Now SGLang, the same way.");
const note = continuationNote(lastUserRequest(msgs));
expect(note.startsWith(CONTINUATION_PREFIX)).toBe(true);
expect(note).toContain('"Now SGLang, the same way."');
expect(note).toContain("give the answer and stop");
expect(note).not.toMatch(/summarize the final result/i);
});
test("skip earlier continuation notes and long requests are cut at a word", () => {
const long = "word ".repeat(200).trim();
const msgs = [
{ role: "user" as const, text: long },
{ role: "user" as const, text: continuationNote("x") },
];
const q = lastUserRequest(msgs);
expect(q.length).toBeLessThanOrEqual(400);
expect(q.endsWith("…")).toBe(true);
});
test("fall back to a generic note when no request is found", () => {
expect(continuationNote("")).toContain("Continue answering the user's last message.");
expect(resumedRequestNote("")).toContain("summarized above");
});
});