mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:20:43 +00:00
test(agents): cover compatible empty retries
This commit is contained in:
@@ -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: [],
|
||||
|
||||
@@ -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", () => ({
|
||||
|
||||
Reference in New Issue
Block a user