test(agents): cover compatible empty retries

This commit is contained in:
Peter Steinberger
2026-04-27 11:43:31 +01:00
parent fd9d32f022
commit 769994eb04
2 changed files with 42 additions and 13 deletions

View File

@@ -7,6 +7,7 @@ import {
mockedGlobalHookRunner,
mockedLog,
mockedRunEmbeddedAttempt,
mockedResolveModelAsync,
overflowBaseRunParams,
resetRunOverflowCompactionHarnessMocks,
} from "./run.overflow-compaction.harness.js";
@@ -644,6 +645,19 @@ describe("runEmbeddedPiAgent incomplete-turn safety", () => {
it("retries empty openai-compatible stop turns even when the backend reports output tokens", async () => {
mockedClassifyFailoverReason.mockReturnValue(null);
mockedResolveModelAsync.mockResolvedValue({
model: {
id: "qwen3.6-27b",
provider: "llamacpp",
contextWindow: 200000,
api: "openai-completions",
},
error: null,
authStorage: {
setRuntimeApiKey: () => undefined,
},
modelRegistry: {},
});
mockedRunEmbeddedAttempt.mockResolvedValueOnce(
makeAttemptResult({
assistantTexts: [],

View File

@@ -79,6 +79,19 @@ export const mockedResolveContextEngine = vi.fn(async () => mockedContextEngine)
export const mockedBuildAgentRuntimePlan = vi.fn(() => ({}));
export const mockedRunPostCompactionSideEffects = vi.fn(async () => {});
export const mockedEnsureRuntimePluginsLoaded = vi.fn<(params?: unknown) => void>();
export const mockedResolveModelAsync = vi.fn(async () => ({
model: {
id: "test-model",
provider: "anthropic",
contextWindow: 200000,
api: "messages",
},
error: null,
authStorage: {
setRuntimeApiKey: vi.fn(),
},
modelRegistry: {},
}));
export const mockedPrepareProviderRuntimeAuth = vi.fn(async () => undefined);
export const mockedRunEmbeddedAttempt =
vi.fn<(params: unknown) => Promise<EmbeddedRunAttemptResult>>();
@@ -245,6 +258,20 @@ export function resetRunOverflowCompactionHarnessMocks(): void {
});
mockedEnsureRuntimePluginsLoaded.mockReset();
mockedResolveModelAsync.mockReset();
mockedResolveModelAsync.mockResolvedValue({
model: {
id: "test-model",
provider: "anthropic",
contextWindow: 200000,
api: "messages",
},
error: null,
authStorage: {
setRuntimeApiKey: vi.fn(),
},
modelRegistry: {},
});
mockedPrepareProviderRuntimeAuth.mockReset();
mockedPrepareProviderRuntimeAuth.mockResolvedValue(undefined);
mockedRunEmbeddedAttempt.mockReset();
@@ -463,19 +490,7 @@ export async function loadRunOverflowCompactionHarness(): Promise<{
}));
vi.doMock("./model.js", () => ({
resolveModelAsync: vi.fn(async () => ({
model: {
id: "test-model",
provider: "anthropic",
contextWindow: 200000,
api: "messages",
},
error: null,
authStorage: {
setRuntimeApiKey: vi.fn(),
},
modelRegistry: {},
})),
resolveModelAsync: mockedResolveModelAsync,
}));
vi.doMock("../model-auth.js", () => ({