























@@ -2,6 +2,13 @@ import { describe, expect, it } from "vitest";
22import type { OpenClawConfig } from "../config/config.js";
33import { resolveSimpleCompletionSelectionForAgent } from "./simple-completion-runtime.js";
445+function requireSelection(selection: ReturnType<typeof resolveSimpleCompletionSelectionForAgent>) {
6+if (!selection) {
7+throw new Error("expected simple completion selection");
8+}
9+return selection;
10+}
11+512describe("resolveSimpleCompletionSelectionForAgent", () => {
613it("preserves multi-segment model ids (openrouter provider models)", () => {
714const cfg = {
@@ -10,13 +17,11 @@ describe("resolveSimpleCompletionSelectionForAgent", () => {
1017},
1118} as OpenClawConfig;
121913-const selection = resolveSimpleCompletionSelectionForAgent({ cfg, agentId: "main" });
14-expect(selection).toEqual(
15-expect.objectContaining({
16-provider: "openrouter",
17-modelId: "anthropic/claude-sonnet-4-6",
18-}),
20+const selection = requireSelection(
21+resolveSimpleCompletionSelectionForAgent({ cfg, agentId: "main" }),
1922);
23+expect(selection.provider).toBe("openrouter");
24+expect(selection.modelId).toBe("anthropic/claude-sonnet-4-6");
2025});
21262227it("uses the routed agent model override when present", () => {
@@ -27,13 +32,11 @@ describe("resolveSimpleCompletionSelectionForAgent", () => {
2732},
2833} as OpenClawConfig;
293430-const selection = resolveSimpleCompletionSelectionForAgent({ cfg, agentId: "ops" });
31-expect(selection).toEqual(
32-expect.objectContaining({
33-provider: "openrouter",
34-modelId: "openrouter/aurora-alpha",
35-}),
35+const selection = requireSelection(
36+resolveSimpleCompletionSelectionForAgent({ cfg, agentId: "ops" }),
3637);
38+expect(selection.provider).toBe("openrouter");
39+expect(selection.modelId).toBe("openrouter/aurora-alpha");
3740});
38413942it("keeps trailing auth profile for credential lookup", () => {
@@ -43,14 +46,12 @@ describe("resolveSimpleCompletionSelectionForAgent", () => {
4346},
4447} as OpenClawConfig;
454846-const selection = resolveSimpleCompletionSelectionForAgent({ cfg, agentId: "main" });
47-expect(selection).toEqual(
48-expect.objectContaining({
49-provider: "anthropic",
50-modelId: "claude-opus-4-6",
51-profileId: "work",
52-}),
49+const selection = requireSelection(
50+resolveSimpleCompletionSelectionForAgent({ cfg, agentId: "main" }),
5351);
52+expect(selection.provider).toBe("anthropic");
53+expect(selection.modelId).toBe("claude-opus-4-6");
54+expect(selection.profileId).toBe("work");
5455});
55565657it("resolves alias refs before parsing provider/model", () => {
@@ -65,26 +66,22 @@ describe("resolveSimpleCompletionSelectionForAgent", () => {
6566},
6667} as OpenClawConfig;
676868-const selection = resolveSimpleCompletionSelectionForAgent({ cfg, agentId: "main" });
69-expect(selection).toEqual(
70-expect.objectContaining({
71-provider: "openrouter",
72-modelId: "anthropic/claude-sonnet-4-6",
73-profileId: "work",
74-}),
69+const selection = requireSelection(
70+resolveSimpleCompletionSelectionForAgent({ cfg, agentId: "main" }),
7571);
72+expect(selection.provider).toBe("openrouter");
73+expect(selection.modelId).toBe("anthropic/claude-sonnet-4-6");
74+expect(selection.profileId).toBe("work");
7675});
77767877it("falls back to runtime default model when no explicit model is configured", () => {
7978const cfg = {} as OpenClawConfig;
807981-const selection = resolveSimpleCompletionSelectionForAgent({ cfg, agentId: "main" });
82-expect(selection).toEqual(
83-expect.objectContaining({
84-provider: "openai",
85-modelId: "gpt-5.5",
86-}),
80+const selection = requireSelection(
81+resolveSimpleCompletionSelectionForAgent({ cfg, agentId: "main" }),
8782);
83+expect(selection.provider).toBe("openai");
84+expect(selection.modelId).toBe("gpt-5.5");
8885});
89869087it("uses configured provider fallback when default provider is unavailable", () => {
@@ -114,12 +111,10 @@ describe("resolveSimpleCompletionSelectionForAgent", () => {
114111},
115112} as OpenClawConfig;
116113117-const selection = resolveSimpleCompletionSelectionForAgent({ cfg, agentId: "main" });
118-expect(selection).toEqual(
119-expect.objectContaining({
120-provider: "openai",
121-modelId: "gpt-5.5",
122-}),
114+const selection = requireSelection(
115+resolveSimpleCompletionSelectionForAgent({ cfg, agentId: "main" }),
123116);
117+expect(selection.provider).toBe("openai");
118+expect(selection.modelId).toBe("gpt-5.5");
124119});
125120});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。