41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import "./run.overflow-compaction.mocks.shared.js";
|
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { compactEmbeddedPiSessionDirect } from "./compact.js";
|
|
import { runEmbeddedPiAgent } from "./run.js";
|
|
import { mockOverflowRetrySuccess } from "./run.overflow-compaction.fixture.js";
|
|
import { runEmbeddedAttempt } from "./run/attempt.js";
|
|
|
|
const mockedRunEmbeddedAttempt = vi.mocked(runEmbeddedAttempt);
|
|
const mockedCompactDirect = vi.mocked(compactEmbeddedPiSessionDirect);
|
|
|
|
describe("runEmbeddedPiAgent overflow compaction trigger routing", () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("passes trigger=overflow when retrying compaction after context overflow", async () => {
|
|
mockOverflowRetrySuccess({
|
|
runEmbeddedAttempt: mockedRunEmbeddedAttempt,
|
|
compactDirect: mockedCompactDirect,
|
|
});
|
|
|
|
await runEmbeddedPiAgent({
|
|
sessionId: "test-session",
|
|
sessionKey: "test-key",
|
|
sessionFile: "/tmp/session.json",
|
|
workspaceDir: "/tmp/workspace",
|
|
prompt: "hello",
|
|
timeoutMs: 30000,
|
|
runId: "run-1",
|
|
});
|
|
|
|
expect(mockedCompactDirect).toHaveBeenCalledTimes(1);
|
|
expect(mockedCompactDirect).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
trigger: "overflow",
|
|
authProfileId: "test-profile",
|
|
}),
|
|
);
|
|
});
|
|
});
|