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

推荐订阅源

L
LangChain Blog
有赞技术团队
有赞技术团队
博客园_首页
IT之家
IT之家
爱范儿
爱范儿
量子位
小众软件
小众软件
Jina AI
Jina AI
WordPress大学
WordPress大学
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 聂微东
The Cloudflare Blog
博客园 - 司徒正美
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
大猫的无限游戏
大猫的无限游戏
月光博客
月光博客
雷峰网
雷峰网
V
Visual Studio Blog
博客园 - Franky
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
美团技术团队
Last Week in AI
Last Week in AI
S
SegmentFault 最新的问题

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: avoid default workspace metadata for agent models · ...
shakkernerd · 2026-04-28 · via Recent Commits to openclaw:main

@@ -1,6 +1,8 @@

11

import fs from "node:fs/promises";

22

import path from "node:path";

33

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

4+

import { resolveInstalledPluginIndexPolicyHash } from "../plugins/installed-plugin-index-policy.js";

5+

import type { PluginMetadataSnapshot } from "../plugins/plugin-metadata-snapshot.js";

46

import {

57

CUSTOM_PROXY_MODELS_CONFIG,

68

installModelsConfigTestHooks,

@@ -13,15 +15,63 @@ const planOpenClawModelsJsonMock = vi.fn();

1315

installModelsConfigTestHooks();

14161517

let ensureOpenClawModelsJson: typeof import("./models-config.js").ensureOpenClawModelsJson;

18+

let clearCurrentPluginMetadataSnapshot: typeof import("../plugins/current-plugin-metadata-snapshot.js").clearCurrentPluginMetadataSnapshot;

19+

let setCurrentPluginMetadataSnapshot: typeof import("../plugins/current-plugin-metadata-snapshot.js").setCurrentPluginMetadataSnapshot;

20+21+

function createPluginMetadataSnapshot(workspaceDir: string): PluginMetadataSnapshot {

22+

const policyHash = resolveInstalledPluginIndexPolicyHash({});

23+

return {

24+

policyHash,

25+

workspaceDir,

26+

index: {

27+

version: 1,

28+

hostContractVersion: "test",

29+

compatRegistryVersion: "test",

30+

migrationVersion: 1,

31+

policyHash,

32+

generatedAtMs: 1,

33+

installRecords: {},

34+

plugins: [],

35+

diagnostics: [],

36+

},

37+

registryDiagnostics: [],

38+

manifestRegistry: { plugins: [], diagnostics: [] },

39+

plugins: [],

40+

diagnostics: [],

41+

byPluginId: new Map(),

42+

normalizePluginId: (pluginId) => pluginId,

43+

owners: {

44+

channels: new Map(),

45+

channelConfigs: new Map(),

46+

providers: new Map(),

47+

modelCatalogProviders: new Map(),

48+

cliBackends: new Map(),

49+

setupProviders: new Map(),

50+

commandAliases: new Map(),

51+

contracts: new Map(),

52+

},

53+

metrics: {

54+

registrySnapshotMs: 0,

55+

manifestRegistryMs: 0,

56+

ownerMapsMs: 0,

57+

totalMs: 0,

58+

indexPluginCount: 0,

59+

manifestPluginCount: 0,

60+

},

61+

};

62+

}

16631764

beforeAll(async () => {

1865

vi.doMock("./models-config.plan.js", () => ({

1966

planOpenClawModelsJson: (...args: unknown[]) => planOpenClawModelsJsonMock(...args),

2067

}));

2168

({ ensureOpenClawModelsJson } = await import("./models-config.js"));

69+

({ clearCurrentPluginMetadataSnapshot, setCurrentPluginMetadataSnapshot } =

70+

await import("../plugins/current-plugin-metadata-snapshot.js"));

2271

});

23722473

beforeEach(() => {

74+

clearCurrentPluginMetadataSnapshot();

2575

planOpenClawModelsJsonMock

2676

.mockReset()

2777

.mockImplementation(async (params: { cfg?: typeof CUSTOM_PROXY_MODELS_CONFIG }) => ({

@@ -31,6 +81,38 @@ beforeEach(() => {

3181

});

32823383

describe("models-config write serialization", () => {

84+

it("does not reuse default workspace plugin metadata for explicit agent dirs without workspace", async () => {

85+

await withModelsTempHome(async (home) => {

86+

const snapshot = createPluginMetadataSnapshot(path.join(home, "default-workspace"));

87+

setCurrentPluginMetadataSnapshot(snapshot, { config: {} });

88+

const agentDir = path.join(home, "agent-non-default");

89+90+

await ensureOpenClawModelsJson({}, agentDir);

91+92+

expect(planOpenClawModelsJsonMock).toHaveBeenCalledWith(

93+

expect.not.objectContaining({ pluginMetadataSnapshot: snapshot }),

94+

);

95+

});

96+

});

97+98+

it("reuses current plugin metadata for explicit agent dirs with matching workspace", async () => {

99+

await withModelsTempHome(async (home) => {

100+

const workspaceDir = path.join(home, "agent-workspace");

101+

const snapshot = createPluginMetadataSnapshot(workspaceDir);

102+

setCurrentPluginMetadataSnapshot(snapshot, { config: {} });

103+

const agentDir = path.join(home, "agent-non-default");

104+105+

await ensureOpenClawModelsJson({}, agentDir, { workspaceDir });

106+107+

expect(planOpenClawModelsJsonMock).toHaveBeenCalledWith(

108+

expect.objectContaining({

109+

workspaceDir,

110+

pluginMetadataSnapshot: snapshot,

111+

}),

112+

);

113+

});

114+

});

115+34116

it("serializes concurrent models.json writes to avoid overlap", async () => {

35117

await withModelsTempHome(async () => {

36118

const first = structuredClone(CUSTOM_PROXY_MODELS_CONFIG);