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

推荐订阅源

S
SegmentFault 最新的问题
G
Google Developers Blog
H
Help Net Security
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Proofpoint News Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog RSS Feed
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 三生石上(FineUI控件)
大猫的无限游戏
大猫的无限游戏
人人都是产品经理
人人都是产品经理
GbyAI
GbyAI
D
Docker
Hugging Face - Blog
Hugging Face - Blog
I
InfoQ
博客园 - 司徒正美
Last Week in AI
Last Week in AI
Microsoft Security Blog
Microsoft Security Blog
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
M
MIT News - Artificial intelligence

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
refactor(agents): remove unused runner utility wrappers ·...
vincentkoc · 2026-06-18 · via Recent Commits to openclaw:main

File tree

  • src/agents/embedded-agent-runner

Original file line numberDiff line numberDiff line change

@@ -4,7 +4,6 @@ import {

44

applyEmbeddedAttemptToolsAllow,

55

mergeForcedEmbeddedAttemptToolsAllow,

66

resolveEmbeddedAttemptToolConstructionPlan,

7-

shouldBuildCoreCodingToolsForAllowlist,

87

shouldCreateBundleLspRuntimeForAttempt,

98

shouldCreateBundleMcpRuntimeForAttempt,

109

} from "./attempt-tool-construction-plan.js";

@@ -100,7 +99,8 @@ describe("applyEmbeddedAttemptToolsAllow", () => {

10099

it("keeps plugin-only allowlists on the shared tool policy path", () => {

101100

const tools = [{ name: "memory_search" }, { name: "plugin_extra" }];

102101
103-

expect(shouldBuildCoreCodingToolsForAllowlist(["memory_search"])).toBe(false);

102+

expect(resolveEmbeddedAttemptToolConstructionPlan({ toolsAllow: ["memory_search"] }))

103+

.toHaveProperty("includeCoreTools", false);

104104

expect(

105105

applyEmbeddedAttemptToolsAllow(tools, ["memory_search"]).map((tool) => tool.name),

106106

).toEqual(["memory_search"]);

@@ -173,7 +173,10 @@ describe("applyEmbeddedAttemptToolsAllow", () => {

173173

const tools = [{ name: "exec" }, { name: "read" }, { name: "message" }];

174174
175175

expect(applyEmbeddedAttemptToolsAllow(tools, []).map((tool) => tool.name)).toStrictEqual([]);

176-

expect(shouldBuildCoreCodingToolsForAllowlist([])).toBe(false);

176+

expect(resolveEmbeddedAttemptToolConstructionPlan({ toolsAllow: [] })).toHaveProperty(

177+

"includeCoreTools",

178+

false,

179+

);

177180

});

178181

});

179182
Original file line numberDiff line numberDiff line change

@@ -229,11 +229,6 @@ export function resolveEmbeddedAttemptToolConstructionPlan(params: {

229229

};

230230

}

231231
232-

/** Returns whether the allowlist requires any built-in coding/OpenClaw tools. */

233-

export function shouldBuildCoreCodingToolsForAllowlist(toolsAllow?: string[]): boolean {

234-

return resolveEmbeddedAttemptToolConstructionPlan({ toolsAllow }).includeCoreTools;

235-

}

236-
237232

/**

238233

* Decides whether the bundled MCP runtime is needed for this attempt. Bundle

239234

* runtime creation follows explicit bundle/plugin allowlist names rather than

Original file line numberDiff line numberDiff line change

@@ -4,7 +4,6 @@ import { describe, expect, it } from "vitest";

44

import {

55

createUsageAccumulator,

66

mergeUsageIntoAccumulator,

7-

resolveLastCallUsage,

87

toLastCallUsage,

98

toNormalizedUsage,

109

} from "./usage-accumulator.js";

@@ -164,88 +163,4 @@ describe("usage-accumulator", () => {

164163

});

165164

});

166165
167-

describe("resolveLastCallUsage", () => {

168-

it("prefers raw assistant usage when present", () => {

169-

// Raw assistant usage is the provider's final-call truth; the accumulator

170-

// is only a fallback when that snapshot is absent or unusable.

171-

const acc = createUsageAccumulator();

172-

mergeUsageIntoAccumulator(acc, {

173-

input: 150,

174-

output: 40,

175-

cacheRead: 84_000,

176-

cacheWrite: 0,

177-

total: 84_190,

178-

});

179-
180-

expect(

181-

resolveLastCallUsage(

182-

{

183-

inputTokens: 99,

184-

outputTokens: 12,

185-

completion_tokens_details: { reasoning_tokens: 8 },

186-

cache_read_input_tokens: 456,

187-

cache_creation_input_tokens: 3,

188-

totalTokens: 570,

189-

},

190-

acc,

191-

),

192-

).toEqual({

193-

input: 99,

194-

output: 12,

195-

reasoningTokens: 8,

196-

cacheRead: 456,

197-

cacheWrite: 3,

198-

total: 570,

199-

});

200-

});

201-
202-

it("falls back to the accumulator when assistant usage is missing", () => {

203-

const acc = createAccumulatorWithUsage(FINAL_USAGE);

204-
205-

expect(resolveLastCallUsage(undefined, acc)).toEqual({

206-

input: 150,

207-

output: 40,

208-

reasoningTokens: 7,

209-

cacheRead: 84_000,

210-

cacheWrite: undefined,

211-

total: 84_190,

212-

});

213-

});

214-
215-

it("falls back when assistant usage exists but is unusable", () => {

216-

const acc = createAccumulatorWithUsage(FINAL_USAGE);

217-
218-

expect(resolveLastCallUsage({ responseId: "abc" } as never, acc)).toEqual({

219-

input: 150,

220-

output: 40,

221-

reasoningTokens: 7,

222-

cacheRead: 84_000,

223-

cacheWrite: undefined,

224-

total: 84_190,

225-

});

226-

});

227-
228-

it("keeps an explicit zero-usage raw snapshot instead of falling back", () => {

229-

const acc = createAccumulatorWithUsage(FINAL_USAGE);

230-
231-

expect(

232-

resolveLastCallUsage(

233-

{

234-

input: 0,

235-

output: 0,

236-

cacheRead: 0,

237-

cacheWrite: 0,

238-

total: 0,

239-

},

240-

acc,

241-

),

242-

).toEqual({

243-

input: 0,

244-

output: 0,

245-

cacheRead: 0,

246-

cacheWrite: 0,

247-

total: 0,

248-

});

249-

});

250-

});

251166

});

Original file line numberDiff line numberDiff line change

@@ -1,7 +1,7 @@

11

/**

22

* Accumulates and normalizes per-call token usage across embedded runs.

33

*/

4-

import { normalizeUsage, type NormalizedUsage, type UsageLike } from "../usage.js";

4+

import type { NormalizedUsage } from "../usage.js";

55
66

export type UsageAccumulator = {

77

input: number;

@@ -112,8 +112,3 @@ export const toLastCallUsage = (usage: UsageAccumulator): NormalizedUsage | unde

112112

total: usage.lastTotal || undefined,

113113

};

114114

};

115-
116-

export const resolveLastCallUsage = (

117-

rawUsage: UsageLike | null | undefined,

118-

usageAccumulator: UsageAccumulator,

119-

): NormalizedUsage | undefined => normalizeUsage(rawUsage) ?? toLastCallUsage(usageAccumulator);