31 lines
1002 B
TypeScript
31 lines
1002 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { isContextOverflowError } from "./pi-embedded-helpers.js";
|
|
import { DEFAULT_AGENTS_FILENAME } from "./workspace.js";
|
|
|
|
const _makeFile = (overrides: Partial<WorkspaceBootstrapFile>): WorkspaceBootstrapFile => ({
|
|
name: DEFAULT_AGENTS_FILENAME,
|
|
path: "/tmp/AGENTS.md",
|
|
content: "",
|
|
missing: false,
|
|
...overrides,
|
|
});
|
|
describe("isContextOverflowError", () => {
|
|
it("matches known overflow hints", () => {
|
|
const samples = [
|
|
"request_too_large",
|
|
"Request exceeds the maximum size",
|
|
"context length exceeded",
|
|
"Maximum context length",
|
|
"prompt is too long: 208423 tokens > 200000 maximum",
|
|
"Context overflow: Summarization failed",
|
|
"413 Request Entity Too Large",
|
|
];
|
|
for (const sample of samples) {
|
|
expect(isContextOverflowError(sample)).toBe(true);
|
|
}
|
|
});
|
|
it("ignores unrelated errors", () => {
|
|
expect(isContextOverflowError("rate limit exceeded")).toBe(false);
|
|
});
|
|
});
|