惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
云风的 BLOG
云风的 BLOG
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Engineering at Meta
Engineering at Meta
Vercel News
Vercel News
Y
Y Combinator Blog
B
Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Check Point Blog
M
MIT News - Artificial intelligence
Jina AI
Jina AI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
罗磊的独立博客
Stack Overflow Blog
Stack Overflow Blog
F
Fortinet All Blogs
博客园 - 司徒正美
I
InfoQ
Google DeepMind News
Google DeepMind News
GbyAI
GbyAI
U
Unit 42

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(models): resolve set aliases from runtime config [AI-...
IWhatsskill · 2026-05-22 · via Recent Commits to openclaw:main

@@ -0,0 +1,134 @@

1+

import { beforeEach, describe, expect, it, vi } from "vitest";

2+

import type { OpenClawConfig } from "../../config/config.js";

3+

import type { RuntimeEnv } from "../../runtime.js";

4+5+

const mocks = vi.hoisted(() => ({

6+

logConfigUpdated: vi.fn(),

7+

readConfigFileSnapshot: vi.fn(),

8+

repairCodexRuntimePluginInstallForModelSelection: vi.fn(),

9+

replaceConfigFile: vi.fn(),

10+

}));

11+12+

vi.mock("../../config/config.js", () => ({

13+

readConfigFileSnapshot: (...args: unknown[]) => mocks.readConfigFileSnapshot(...args),

14+

replaceConfigFile: (...args: unknown[]) => mocks.replaceConfigFile(...args),

15+

}));

16+17+

vi.mock("../../config/logging.js", () => ({

18+

logConfigUpdated: (...args: unknown[]) => mocks.logConfigUpdated(...args),

19+

}));

20+21+

vi.mock("../codex-runtime-plugin-install.js", () => ({

22+

repairCodexRuntimePluginInstallForModelSelection: (...args: unknown[]) =>

23+

mocks.repairCodexRuntimePluginInstallForModelSelection(...args),

24+

}));

25+26+

import { modelsSetCommand } from "./set.js";

27+28+

function makeRuntime(): RuntimeEnv {

29+

return {

30+

log: vi.fn(),

31+

error: vi.fn(),

32+

exit: vi.fn(),

33+

} as unknown as RuntimeEnv;

34+

}

35+36+

describe("modelsSetCommand", () => {

37+

beforeEach(() => {

38+

vi.clearAllMocks();

39+

mocks.replaceConfigFile.mockResolvedValue(undefined);

40+

mocks.repairCodexRuntimePluginInstallForModelSelection.mockResolvedValue({ warnings: [] });

41+

});

42+43+

it("resolves aliases from runtime config while writing only source config", async () => {

44+

const sourceConfig = {

45+

agents: {

46+

defaults: {

47+

models: {

48+

"anthropic/claude-sonnet-4-6": {},

49+

},

50+

},

51+

},

52+

} as unknown as OpenClawConfig;

53+

const runtimeConfig = {

54+

agents: {

55+

defaults: {

56+

models: {

57+

"anthropic/claude-sonnet-4-6": { alias: "sonnet" },

58+

},

59+

},

60+

},

61+

} as unknown as OpenClawConfig;

62+

mocks.readConfigFileSnapshot.mockResolvedValue({

63+

valid: true,

64+

hash: "config-hash",

65+

sourceConfig,

66+

runtimeConfig,

67+

config: runtimeConfig,

68+

});

69+

const runtime = makeRuntime();

70+71+

await modelsSetCommand("sonnet", runtime);

72+73+

expect(mocks.replaceConfigFile).toHaveBeenCalledOnce();

74+

const [replaceParams] = mocks.replaceConfigFile.mock.calls[0] ?? [];

75+

expect(replaceParams?.nextConfig.agents?.defaults?.model).toEqual({

76+

primary: "anthropic/claude-sonnet-4-6",

77+

});

78+

expect(replaceParams?.nextConfig.agents?.defaults?.models).toEqual({

79+

"anthropic/claude-sonnet-4-6": {},

80+

});

81+

expect(replaceParams?.nextConfig.agents?.defaults?.models).not.toHaveProperty("openai/sonnet");

82+

expect(mocks.repairCodexRuntimePluginInstallForModelSelection).toHaveBeenCalledWith({

83+

cfg: replaceParams?.nextConfig,

84+

model: "anthropic/claude-sonnet-4-6",

85+

});

86+

expect(runtime.log).toHaveBeenCalledWith("Default model: anthropic/claude-sonnet-4-6");

87+

});

88+89+

it("keeps authored aliases ahead of runtime-only aliases", async () => {

90+

const sourceConfig = {

91+

agents: {

92+

defaults: {

93+

models: {

94+

"openai/gpt-5.5": { alias: "sonnet" },

95+

},

96+

},

97+

},

98+

} as unknown as OpenClawConfig;

99+

const runtimeConfig = {

100+

agents: {

101+

defaults: {

102+

models: {

103+

"openai/gpt-5.5": { alias: "sonnet" },

104+

"anthropic/claude-sonnet-4-6": { alias: "sonnet" },

105+

},

106+

},

107+

},

108+

} as unknown as OpenClawConfig;

109+

mocks.readConfigFileSnapshot.mockResolvedValue({

110+

valid: true,

111+

hash: "config-hash",

112+

sourceConfig,

113+

runtimeConfig,

114+

config: runtimeConfig,

115+

});

116+

const runtime = makeRuntime();

117+118+

await modelsSetCommand("sonnet", runtime);

119+120+

expect(mocks.replaceConfigFile).toHaveBeenCalledOnce();

121+

const [replaceParams] = mocks.replaceConfigFile.mock.calls[0] ?? [];

122+

expect(replaceParams?.nextConfig.agents?.defaults?.model).toEqual({

123+

primary: "openai/gpt-5.5",

124+

});

125+

expect(replaceParams?.nextConfig.agents?.defaults?.models).toEqual({

126+

"openai/gpt-5.5": { alias: "sonnet" },

127+

});

128+

expect(mocks.repairCodexRuntimePluginInstallForModelSelection).toHaveBeenCalledWith({

129+

cfg: replaceParams?.nextConfig,

130+

model: "openai/gpt-5.5",

131+

});

132+

expect(runtime.log).toHaveBeenCalledWith("Default model: openai/gpt-5.5");

133+

});

134+

});