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

推荐订阅源

J
Java Code Geeks
博客园 - 司徒正美
博客园 - 【当耐特】
爱范儿
爱范儿
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
人人都是产品经理
人人都是产品经理
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
大猫的无限游戏
大猫的无限游戏
月光博客
月光博客
宝玉的分享
宝玉的分享
V
V2EX
S
SegmentFault 最新的问题
V
Visual Studio Blog
阮一峰的网络日志
阮一峰的网络日志
Martin Fowler
Martin Fowler
Jina AI
Jina AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园_首页
L
LangChain Blog
D
Docker
腾讯CDC

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
test: dedupe tools effective mock calls · openclaw/opencl...
steipete · 2026-05-12 · via Recent Commits to openclaw:main

@@ -90,7 +90,11 @@ function resolveEffectiveToolInventoryArg(callIndex = 0): Record<string, unknown

9090

const calls = runtimeMocks.resolveEffectiveToolInventory.mock.calls as unknown as Array<

9191

[Record<string, unknown>]

9292

>;

93-

return calls[callIndex]?.[0];

93+

return calls.at(callIndex)?.[0];

94+

}

95+96+

function firstRespondCall(respond: ReturnType<typeof vi.fn>): RespondCall | undefined {

97+

return respond.mock.calls.at(0) as RespondCall | undefined;

9498

}

959996100

describe("tools.effective handler", () => {

@@ -105,7 +109,7 @@ describe("tools.effective handler", () => {

105109

it("rejects invalid params", async () => {

106110

const { respond, invoke } = createInvokeParams({ includePlugins: false });

107111

await invoke();

108-

const call = respond.mock.calls[0] as RespondCall | undefined;

112+

const call = firstRespondCall(respond);

109113

expect(call?.[0]).toBe(false);

110114

expect(call?.[2]?.code).toBe(ErrorCodes.INVALID_REQUEST);

111115

expect(call?.[2]?.message).toContain("invalid tools.effective params");

@@ -114,7 +118,7 @@ describe("tools.effective handler", () => {

114118

it("rejects missing sessionKey", async () => {

115119

const { respond, invoke } = createInvokeParams({});

116120

await invoke();

117-

const call = respond.mock.calls[0] as RespondCall | undefined;

121+

const call = firstRespondCall(respond);

118122

expect(call?.[0]).toBe(false);

119123

expect(call?.[2]?.code).toBe(ErrorCodes.INVALID_REQUEST);

120124

expect(call?.[2]?.message).toContain("invalid tools.effective params");

@@ -123,7 +127,7 @@ describe("tools.effective handler", () => {

123127

it("rejects caller-supplied auth context params", async () => {

124128

const { respond, invoke } = createInvokeParams({ senderIsOwner: true });

125129

await invoke();

126-

const call = respond.mock.calls[0] as RespondCall | undefined;

130+

const call = firstRespondCall(respond);

127131

expect(call?.[0]).toBe(false);

128132

expect(call?.[2]?.code).toBe(ErrorCodes.INVALID_REQUEST);

129133

expect(call?.[2]?.message).toContain("invalid tools.effective params");

@@ -135,7 +139,7 @@ describe("tools.effective handler", () => {

135139

agentId: "unknown-agent",

136140

});

137141

await invoke();

138-

const call = respond.mock.calls[0] as RespondCall | undefined;

142+

const call = firstRespondCall(respond);

139143

expect(call?.[0]).toBe(false);

140144

expect(call?.[2]?.code).toBe(ErrorCodes.INVALID_REQUEST);

141145

expect(call?.[2]?.message).toContain("unknown agent id");

@@ -151,7 +155,7 @@ describe("tools.effective handler", () => {

151155

} as never);

152156

const { respond, invoke } = createInvokeParams({ sessionKey: "missing-session" });

153157

await invoke();

154-

const call = respond.mock.calls[0] as RespondCall | undefined;

158+

const call = firstRespondCall(respond);

155159

expect(call?.[0]).toBe(false);

156160

expect(call?.[2]?.code).toBe(ErrorCodes.INVALID_REQUEST);

157161

expect(call?.[2]?.message).toContain('unknown session key "missing-session"');

@@ -160,7 +164,7 @@ describe("tools.effective handler", () => {

160164

it("returns the effective runtime inventory", async () => {

161165

const { respond, invoke } = createInvokeParams({ sessionKey: "main:abc" });

162166

await invoke();

163-

const call = respond.mock.calls[0] as RespondCall | undefined;

167+

const call = firstRespondCall(respond);

164168

expect(call?.[0]).toBe(true);

165169

const payload = call?.[1] as ToolsEffectivePayload | undefined;

166170

expect(payload?.agentId).toBe("main");

@@ -190,8 +194,8 @@ describe("tools.effective handler", () => {

190194

await second.invoke();

191195192196

expect(runtimeMocks.resolveEffectiveToolInventory).toHaveBeenCalledTimes(1);

193-

expect((first.respond.mock.calls[0] as RespondCall | undefined)?.[0]).toBe(true);

194-

expect((second.respond.mock.calls[0] as RespondCall | undefined)?.[0]).toBe(true);

197+

expect(firstRespondCall(first.respond)?.[0]).toBe(true);

198+

expect(firstRespondCall(second.respond)?.[0]).toBe(true);

195199

});

196200197201

it("invalidates the cache when only the channel registry version changes", async () => {

@@ -203,7 +207,7 @@ describe("tools.effective handler", () => {

203207

await second.invoke();

204208205209

expect(runtimeMocks.resolveEffectiveToolInventory).toHaveBeenCalledTimes(2);

206-

expect((second.respond.mock.calls[0] as RespondCall | undefined)?.[0]).toBe(true);

210+

expect(firstRespondCall(second.respond)?.[0]).toBe(true);

207211

});

208212209213

it("coalesces identical cache misses while inventory resolution is pending", async () => {

@@ -213,8 +217,8 @@ describe("tools.effective handler", () => {

213217

await Promise.all([first.invoke(), second.invoke()]);

214218215219

expect(runtimeMocks.resolveEffectiveToolInventory).toHaveBeenCalledTimes(1);

216-

expect((first.respond.mock.calls[0] as RespondCall | undefined)?.[0]).toBe(true);

217-

expect((second.respond.mock.calls[0] as RespondCall | undefined)?.[0]).toBe(true);

220+

expect(firstRespondCall(first.respond)?.[0]).toBe(true);

221+

expect(firstRespondCall(second.respond)?.[0]).toBe(true);

218222

});

219223220224

it("returns stale cached inventory immediately while refreshing in the background", async () => {

@@ -271,15 +275,15 @@ describe("tools.effective handler", () => {

271275

const stale = createInvokeParams({ sessionKey: "main:abc" });

272276

await stale.invoke();

273277274-

expect((stale.respond.mock.calls[0] as RespondCall | undefined)?.[1]).toBe(stalePayload);

278+

expect(firstRespondCall(stale.respond)?.[1]).toBe(stalePayload);

275279

expect(runtimeMocks.resolveEffectiveToolInventory).toHaveBeenCalledTimes(1);

276280277281

await new Promise<void>((resolve) => setImmediate(resolve));

278282

expect(runtimeMocks.resolveEffectiveToolInventory).toHaveBeenCalledTimes(2);

279283280284

const fresh = createInvokeParams({ sessionKey: "main:abc" });

281285

await fresh.invoke();

282-

expect((fresh.respond.mock.calls[0] as RespondCall | undefined)?.[1]).toBe(refreshedPayload);

286+

expect(firstRespondCall(fresh.respond)?.[1]).toBe(refreshedPayload);

283287

});

284288285289

it("falls back to origin.threadId when delivery context omits thread metadata", async () => {

@@ -316,7 +320,7 @@ describe("tools.effective handler", () => {

316320

await invoke();

317321318322

expect(resolveEffectiveToolInventoryArg()?.currentThreadTs).toBe("42");

319-

expect((respond.mock.calls[0] as RespondCall | undefined)?.[0]).toBe(true);

323+

expect(firstRespondCall(respond)?.[0]).toBe(true);

320324

});

321325322326

it("passes senderIsOwner=true for admin-scoped callers", async () => {

@@ -348,7 +352,7 @@ describe("tools.effective handler", () => {

348352

},

349353

} as never);

350354

await invoke();

351-

const call = respond.mock.calls[0] as RespondCall | undefined;

355+

const call = firstRespondCall(respond);

352356

expect(call?.[0]).toBe(false);

353357

expect(call?.[2]?.code).toBe(ErrorCodes.INVALID_REQUEST);

354358

expect(call?.[2]?.message).toContain('unknown agent id "other"');