test: refresh agent model expectation fixtures

This commit is contained in:
Peter Steinberger 2026-04-05 08:30:17 +01:00
parent 31d8b022eb
commit acd8966ff0
No known key found for this signature in database
3 changed files with 21 additions and 17 deletions

View File

@ -3,6 +3,7 @@ import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, describe, expect, it, vi } from "vitest";
import type { ModelDefinitionConfig } from "../config/types.models.js";
import { withFetchPreconnect } from "../test-utils/fetch-mock.js";
import { resolveImplicitProvidersForTest } from "./models-config.e2e-harness.js";
afterEach(() => {
@ -135,7 +136,7 @@ describe("Ollama provider", () => {
}
return notFoundJsonResponse();
});
vi.stubGlobal("fetch", fetchMock);
vi.stubGlobal("fetch", withFetchPreconnect(fetchMock));
const providers = await resolveProvidersWithOllamaKey(agentDir);
const models = providers?.ollama?.models ?? [];
@ -162,7 +163,7 @@ describe("Ollama provider", () => {
}
return notFoundJsonResponse();
});
vi.stubGlobal("fetch", fetchMock);
vi.stubGlobal("fetch", withFetchPreconnect(fetchMock));
const providers = await resolveProvidersWithOllamaKey(agentDir);
const model = providers?.ollama?.models?.find((entry) => entry.id === "qwen3:32b");
@ -192,7 +193,7 @@ describe("Ollama provider", () => {
json: async () => ({ model_info: { "llama.context_length": 65536 } }),
};
});
vi.stubGlobal("fetch", fetchMock);
vi.stubGlobal("fetch", withFetchPreconnect(fetchMock));
const providers = await resolveProvidersWithOllamaKey(agentDir);
const models = providers?.ollama?.models ?? [];
@ -221,7 +222,7 @@ describe("Ollama provider", () => {
const agentDir = createAgentDir();
enableDiscoveryEnv();
const fetchMock = vi.fn();
vi.stubGlobal("fetch", fetchMock);
vi.stubGlobal("fetch", withFetchPreconnect(fetchMock));
const explicitModels: ModelDefinitionConfig[] = [
{
id: "gpt-oss:20b",

View File

@ -21,8 +21,9 @@ export const OPENAI_CODEX_TEMPLATE_MODEL = {
baseUrl: "https://chatgpt.com/backend-api",
reasoning: true,
input: ["text", "image"] as const,
cost: { input: 1.75, output: 14, cacheRead: 0.175, cacheWrite: 0 },
contextWindow: 272000,
cost: { input: 2.5, output: 15, cacheRead: 0.25, cacheWrite: 0 },
contextWindow: 1_050_000,
contextTokens: 272_000,
maxTokens: 128000,
};
@ -69,11 +70,12 @@ export function buildOpenAICodexForwardCompatExpectation(
cost: isSpark
? { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }
: isGpt54
? { input: 1.75, output: 14, cacheRead: 0.175, cacheWrite: 0 }
? { input: 2.5, output: 15, cacheRead: 0.25, cacheWrite: 0 }
: isGpt54Mini
? { input: 0.75, output: 4.5, cacheRead: 0.075, cacheWrite: 0 }
: OPENAI_CODEX_TEMPLATE_MODEL.cost,
contextWindow: isGpt54 ? 272_000 : isSpark ? 128_000 : 272000,
contextWindow: isGpt54 ? 1_050_000 : isSpark ? 128_000 : 272000,
...(isGpt54 ? { contextTokens: 272_000 } : {}),
maxTokens: 128000,
};
}

View File

@ -65,10 +65,14 @@ const imageProviderHarness = vi.hoisted(() => {
};
});
vi.mock("../bash-tools.js", () => ({
createExecTool: vi.fn(() => piToolsHarness.createStubTool("exec")),
createProcessTool: vi.fn(() => piToolsHarness.createStubTool("process")),
}));
vi.mock("../bash-tools.js", async () => {
const actual = await vi.importActual<typeof import("../bash-tools.js")>("../bash-tools.js");
return {
...actual,
createExecTool: vi.fn(() => piToolsHarness.createStubTool("exec")),
createProcessTool: vi.fn(() => piToolsHarness.createStubTool("process")),
};
});
vi.mock("../channel-tools.js", () => ({
copyChannelAgentToolMeta: vi.fn((_from, to) => to),
@ -572,6 +576,7 @@ describe("image tool implicit imageModel config", () => {
it("pairs minimax primary with MiniMax-VL-01 (and fallbacks) when auth exists", async () => {
await withTempAgentDir(async (agentDir) => {
vi.stubEnv("MINIMAX_API_KEY", "minimax-test");
vi.stubEnv("MINIMAX_OAUTH_TOKEN", "minimax-oauth-test");
vi.stubEnv("OPENAI_API_KEY", "openai-test");
vi.stubEnv("ANTHROPIC_API_KEY", "anthropic-test");
const cfg: OpenClawConfig = {
@ -579,11 +584,7 @@ describe("image tool implicit imageModel config", () => {
};
expect(resolveImageModelConfigForTool({ cfg, agentDir })).toEqual({
...createDefaultImageFallbackExpectation("minimax/MiniMax-VL-01"),
fallbacks: [
"openai/gpt-5.4-mini",
"anthropic/claude-opus-4-6",
"minimax-portal/MiniMax-VL-01",
],
fallbacks: ["openai/gpt-5.4-mini", "anthropic/claude-opus-4-6"],
});
expect(createImageTool({ config: cfg, agentDir })).not.toBeNull();
});