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

推荐订阅源

F
Fortinet All Blogs
MyScale Blog
MyScale Blog
Microsoft Security Blog
Microsoft Security Blog
量子位
B
Blog
aimingoo的专栏
aimingoo的专栏
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
The GitHub Blog
The GitHub Blog
T
The Exploit Database - CXSecurity.com
N
News | PayPal Newsroom
Cloudbric
Cloudbric
A
About on SuperTechFans
AI
AI
Hacker News: Ask HN
Hacker News: Ask HN
S
Schneier on Security
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LINUX DO - 最新话题
T
The Blog of Author Tim Ferriss
Simon Willison's Weblog
Simon Willison's Weblog
有赞技术团队
有赞技术团队
H
Heimdal Security Blog
J
Java Code Geeks
大猫的无限游戏
大猫的无限游戏
D
Docker
Security Archives - TechRepublic
Security Archives - TechRepublic
N
News and Events Feed by Topic
IT之家
IT之家
Know Your Adversary
Know Your Adversary
N
Netflix TechBlog - Medium
T
Tailwind CSS Blog
B
Blog RSS Feed
C
Cybersecurity and Infrastructure Security Agency CISA
C
Cisco Blogs
博客园 - 叶小钗
美团技术团队
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
LangChain Blog
The Hacker News
The Hacker News
Y
Y Combinator Blog
I
Intezer
The Register - Security
The Register - Security
F
Full Disclosure
V
V2EX
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Last Week in AI
Last Week in AI
Martin Fowler
Martin Fowler

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: trim doctor command hotspots · openclaw/openclaw@c66f16a test: isolate agent auth and spawn hotspots · openclaw/openclaw@9285935 test: stabilize MCP startup disposal race · openclaw/openclaw@dd9d2eb test: merge browser contract server suites · openclaw/openclaw@5817a76 test: narrow ollama provider discovery setup · openclaw/openclaw@a0d9598 build: declare qa-lab aimock runtime dependency · openclaw/openclaw@24431e5 test: speed up safe-bins exec harness · openclaw/openclaw@ee856ab test: preserve tool helpers in embedded runner mocks · openclaw/openclaw@acd86a0 refactor: move memory embeddings into provider plugins · openclaw/openclaw@77e6e4c test: reuse system-run temp fixtures · openclaw/openclaw@7e9ff0f test: trim hotspot wait overhead · openclaw/openclaw@12a59b0 Check: avoid duplicate boundary prep · openclaw/openclaw@baf11b8 test: reduce hotspot fixture overhead · openclaw/openclaw@3a59edd feat(ui): overhaul settings and slash command UX (#67819) thanks @Bun… · openclaw/openclaw@2cfb660 QA Matrix: exit cleanly on failure · openclaw/openclaw@42805d2 QA Matrix: isolate scenario coverage · openclaw/openclaw@7e659e1 Matrix: refresh crypto bootstrap state · openclaw/openclaw@94081d8 QA Lab: add provider registry · openclaw/openclaw@bb7e982 Matrix: add plugin changelog · openclaw/openclaw@4acab55 test: trim more hotspot overhead · openclaw/openclaw@f485311 test: trim remaining hotspot tests · openclaw/openclaw@6ba8626 test: narrow hotspot mocks · openclaw/openclaw@dbc8179 test: isolate gemini embedding request helpers · openclaw/openclaw@cd330f5 test: trim memory and mcp hotspots · openclaw/openclaw@fd48dfa test: slim provider registry mocks · openclaw/openclaw@2e08c77 test: harden Parallels update smoke · openclaw/openclaw@1a98090 feat: default Anthropic to Opus 4.7 · openclaw/openclaw@628b454 fix: harden node-host shell payload mutability checks · openclaw/openclaw@75c551e fix: land node-host approval binding for native binaries (#66731) (th… · openclaw/openclaw@29919bb CI: add daily schedule to CodeQL workflow (#67645) · openclaw/openclaw@69d25f5 fix(gateway): capture config hash after plugin auto-enable to prevent… · openclaw/openclaw@8c11210 fix: repair sanitized replay tool results before send (#67620) (thank… · openclaw/openclaw@c3c7a99 fix: restrict HTML timeout short-circuit to transient statuses · openclaw/openclaw@de129a6 fix: keep TUI watchdog bound to active run (#67401) (thanks @xantorres) · openclaw/openclaw@3525273 Gateway/skills: dedupe skills prefix-match + drop dead fallback on log · openclaw/openclaw@d7f489f Extensions/lmstudio: back off inference preload after consecutive fai… · openclaw/openclaw@b555214 TUI/streaming: add watchdog that resets the activity indicator after … · openclaw/openclaw@f44ab20 Agents/tool-loop: enable unknown-tool stream guard by default · openclaw/openclaw@36ed367 Gateway/skills: invalidate session skills snapshot on config write · openclaw/openclaw@b23d59a fix: classify HTML provider error pages correctly (#67642) (thanks @s… · openclaw/openclaw@e588e90 fix(skills): remove unused model-usage import (#67641) · openclaw/openclaw@55f05df docs(changelog): credit codex fix superseded PRs · openclaw/openclaw@e485f24 fix(openai-codex): normalize stale transport metadata in resolution a… · openclaw/openclaw@90801ba CI: pin Docker-related GitHub Actions (#67632) · openclaw/openclaw@f697b01 Android: modernize WebView and discovery API usage (#67627) · openclaw/openclaw@44a6e50 fix(deps): bump hono to 4.12.14 and @hono/node-server to 1.19.14 (GHS… · openclaw/openclaw@fbccc18 fix(deps): bump dompurify to 3.4.0 (#67614) · openclaw/openclaw@2c2dc00 CI: add explicit permissions to all workflow jobs (fixes code-scannin… · openclaw/openclaw@01b7516 fix: register bundled TTS providers and route overrides correctly (#6… · openclaw/openclaw@6ea3cdd fix: align host tilde paths with OS home (#62804) (thanks @stainlu) · openclaw/openclaw@ecfaf64 fix: flush creds queue before reconnect socket open (#67464) (thanks … · openclaw/openclaw@405c63f fix: strip standalone <function> tool call tags from visible text (#6… · openclaw/openclaw@78df859 fix(agents): preserve cli session metadata before transcript persist … · openclaw/openclaw@898fd04 docs(changelog): move cli transcript entry · openclaw/openclaw@c1817c6 fix(agents): normalize cli transcript api field · openclaw/openclaw@3a3fae0 docs(changelog): note cli transcript persistence · openclaw/openclaw@6c343f1 fix(agents): persist cli transcript turns · openclaw/openclaw@b8ef507 fix(msteams): harden security-sensitive flows (#65841) · openclaw/openclaw@c56b56e [Dashboard] Fix exec approval modal overflow for long command content… · openclaw/openclaw@053c5b0 Docs: remove QA changelog entry · openclaw/openclaw@7fd5771 QA: fix private runtime source loading (#67428) · openclaw/openclaw@d5933af docs(gateway): correct protocol.md schema path, hello-ok example, aut… · openclaw/openclaw@489404d CI: pin Node 22 runners to 22.18.0 · openclaw/openclaw@4ffa621 models.authStatus: normalize provider ids + tighten env-backed escape… · openclaw/openclaw@f2fdb9d Update CHANGELOG.md · openclaw/openclaw@7694a92 test(parallels): clean up npm update guard jobs · openclaw/openclaw@045ea7b Plugins: prefer scanDir override paths · openclaw/openclaw@b2974da fix(dreaming): default storage.mode to "separate" so phase blocks sto… · openclaw/openclaw@8c392f0 fix(memory-core): skip dreaming transcript ingestion via session stor… · openclaw/openclaw@a1b01f0 fix: dedupe replayed exec.finished node events (#67281) · openclaw/openclaw@5dcf526
fix: redact persisted tool result details · openclaw/openclaw@277eb16
nimbleenigma · 2026-05-13 · via Recent Commits to openclaw:main

@@ -13,6 +13,8 @@ import { guardSessionManager } from "./session-tool-result-guard-wrapper.js";

13131414

const EMPTY_PLUGIN_SCHEMA = { type: "object", additionalProperties: false, properties: {} };

1515

const originalBundledPluginsDir = process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;

16+

const originalConfigPath = process.env.OPENCLAW_CONFIG_PATH;

17+

let tempDirs: string[] = [];

16181719

function writeTempPlugin(params: { dir: string; id: string; body: string }): string {

1820

const pluginDir = path.join(params.dir, params.id);

@@ -111,6 +113,15 @@ afterEach(() => {

111113

} else {

112114

process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = originalBundledPluginsDir;

113115

}

116+

if (originalConfigPath === undefined) {

117+

delete process.env.OPENCLAW_CONFIG_PATH;

118+

} else {

119+

process.env.OPENCLAW_CONFIG_PATH = originalConfigPath;

120+

}

121+

for (const dir of tempDirs) {

122+

fs.rmSync(dir, { force: true, recursive: true });

123+

}

124+

tempDirs = [];

114125

});

115126116127

describe("tool_result_persist hook", () => {

@@ -128,6 +139,156 @@ describe("tool_result_persist hook", () => {

128139

expect(toolResult.details.originalDetailsBytesAtLeast).toBeGreaterThan(8_192);

129140

});

130141142+

it("redacts small toolResult details before persistence", () => {

143+

const tokenValue = "abcdefghijklmnopqrstuvwx1234567890";

144+

const bearerValue = "bearerdiagnosticvalue1234567890";

145+

const adjacentLongGithubToken = `ghp_${"a".repeat(5_000)}`;

146+

const sm = guardSessionManager(SessionManager.inMemory(), {

147+

agentId: "main",

148+

sessionKey: "main",

149+

});

150+

const appendMessage = sm.appendMessage.bind(sm) as unknown as (message: AgentMessage) => void;

151+

appendMessage({

152+

role: "assistant",

153+

content: [{ type: "toolCall", id: "call_1", name: "exec", arguments: {} }],

154+

} as AgentMessage);

155+

appendMessage({

156+

role: "toolResult",

157+

toolCallId: "call_1",

158+

isError: false,

159+

content: [{ type: "text", text: "visible output stays small" }],

160+

details: {

161+

status: "completed",

162+

token: tokenValue,

163+

GITHUB_TOKEN: tokenValue,

164+

github_token: tokenValue,

165+

openai_api_key: tokenValue,

166+

card_number: 4242424242424242,

167+

cvc: 123,

168+

authToken: [tokenValue],

169+

aggregated: `GITHUB_TOKEN=${tokenValue}`,

170+

adjacentLongGithubToken: `${"x".repeat(1_000)}${adjacentLongGithubToken} z`,

171+

nested: {

172+

apiKey: { value: bearerValue },

173+

stdout: `Authorization: Bearer ${bearerValue}`,

174+

items: [`curl --token ${tokenValue} https://example.test`],

175+

},

176+

},

177+

} as any);

178+179+

const toolResult = requirePersistedToolResult(sm);

180+

const serialized = JSON.stringify(toolResult.details);

181+

expect(toolResult.content[0]?.text).toBe("visible output stays small");

182+

expect(serialized).toContain("GITHUB_TOKEN=");

183+

expect(serialized).toContain("Bearer");

184+

expect(serialized).toContain("…");

185+

expect(serialized).not.toContain(tokenValue);

186+

expect(serialized).not.toContain(bearerValue);

187+

expect(serialized).not.toContain(adjacentLongGithubToken);

188+

expect(serialized).not.toContain("a".repeat(100));

189+

expect(serialized).not.toContain("4242424242424242");

190+

});

191+192+

it("applies in-memory redaction config to persisted details", () => {

193+

const customSecret = "customsecret=abcdef1234567890ghij";

194+

const sm = guardSessionManager(SessionManager.inMemory(), {

195+

agentId: "main",

196+

sessionKey: "main",

197+

config: {

198+

logging: {

199+

redactPatterns: [String.raw`customsecret=([^\s]+)`],

200+

},

201+

},

202+

});

203+

const appendMessage = sm.appendMessage.bind(sm) as unknown as (message: AgentMessage) => void;

204+

appendMessage({

205+

role: "assistant",

206+

content: [{ type: "toolCall", id: "call_1", name: "exec", arguments: {} }],

207+

} as AgentMessage);

208+

appendMessage({

209+

role: "toolResult",

210+

toolCallId: "call_1",

211+

isError: false,

212+

content: [{ type: "text", text: customSecret }],

213+

details: {

214+

diagnostic: customSecret,

215+

},

216+

} as any);

217+218+

const toolResult = requirePersistedToolResult(sm);

219+

const serialized = JSON.stringify(toolResult);

220+

expect(serialized).toContain("customsecret=abcdef…ghij");

221+

expect(serialized).not.toContain(customSecret);

222+

});

223+224+

it("keeps sensitive parent keys when custom value patterns match the key probe", () => {

225+

const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-redact-config-"));

226+

tempDirs.push(tempDir);

227+

process.env.OPENCLAW_CONFIG_PATH = path.join(tempDir, "openclaw.json");

228+

fs.writeFileSync(

229+

process.env.OPENCLAW_CONFIG_PATH,

230+

JSON.stringify({ logging: { redactPatterns: ["/[a-z0-9]{30,}/g"] } }),

231+

"utf-8",

232+

);

233+

const sm = guardSessionManager(SessionManager.inMemory(), {

234+

agentId: "main",

235+

sessionKey: "main",

236+

});

237+

const appendMessage = sm.appendMessage.bind(sm) as unknown as (message: AgentMessage) => void;

238+

appendMessage({

239+

role: "assistant",

240+

content: [{ type: "toolCall", id: "call_1", name: "exec", arguments: {} }],

241+

} as AgentMessage);

242+

appendMessage({

243+

role: "toolResult",

244+

toolCallId: "call_1",

245+

isError: false,

246+

content: [{ type: "text", text: "visible output stays small" }],

247+

details: {

248+

token: { value: "shortsecret" },

249+

},

250+

} as any);

251+252+

const toolResult = requirePersistedToolResult(sm);

253+

const serialized = JSON.stringify(toolResult.details);

254+

expect(serialized).toContain("***");

255+

expect(serialized).not.toContain("shortsecret");

256+

});

257+258+

it("redacts secret-bearing keys and too-deep detail branches before persistence", () => {

259+

const tokenValue = "abcdefghijklmnopqrstuvwx1234567890";

260+

const sm = guardSessionManager(SessionManager.inMemory(), {

261+

agentId: "main",

262+

sessionKey: "main",

263+

});

264+

let deepDetails: Record<string, unknown> = { token: tokenValue };

265+

for (let index = 0; index < 10; index += 1) {

266+

deepDetails = { child: deepDetails };

267+

}

268+

const appendMessage = sm.appendMessage.bind(sm) as unknown as (message: AgentMessage) => void;

269+

appendMessage({

270+

role: "assistant",

271+

content: [{ type: "toolCall", id: "call_1", name: "exec", arguments: {} }],

272+

} as AgentMessage);

273+

appendMessage({

274+

role: "toolResult",

275+

toolCallId: "call_1",

276+

isError: false,

277+

content: [{ type: "text", text: "visible output stays small" }],

278+

details: {

279+

[`https://example.test/callback?token=${tokenValue}`]: "ok",

280+

deepDetails,

281+

},

282+

} as any);

283+284+

const toolResult = requirePersistedToolResult(sm);

285+

const serialized = JSON.stringify(toolResult.details);

286+

expect(serialized).toContain("token=");

287+

expect(serialized).toContain("***");

288+

expect(serialized).toContain("max depth exceeded");

289+

expect(serialized).not.toContain(tokenValue);

290+

});

291+131292

it("caps oversized toolResult details before persistence", () => {

132293

const sm = guardSessionManager(SessionManager.inMemory(), {

133294

agentId: "main",

@@ -165,6 +326,165 @@ describe("tool_result_persist hook", () => {

165326

expectPersistedToolResultDetailsCapped(sm);

166327

});

167328329+

it("redacts summarized oversized toolResult details before persistence", () => {

330+

const tokenValue = "abcdefghijklmnopqrstuvwx1234567890";

331+

const boundaryGhToken = "ghp_1234567890abcdefghij1234567890abcdef";

332+

const leadingTailToken = "a".repeat(5_000);

333+

const omittedTailToken = "b".repeat(5_000);

334+

const sm = guardSessionManager(SessionManager.inMemory(), {

335+

agentId: "main",

336+

sessionKey: "main",

337+

});

338+

const appendMessage = sm.appendMessage.bind(sm) as unknown as (message: AgentMessage) => void;

339+

appendMessage({

340+

role: "assistant",

341+

content: [{ type: "toolCall", id: "call_1", name: "exec", arguments: {} }],

342+

} as AgentMessage);

343+

appendMessage({

344+

role: "toolResult",

345+

toolCallId: "call_1",

346+

isError: false,

347+

content: [{ type: "text", text: "visible output stays small" }],

348+

details: {

349+

status: { state: "completed", token: tokenValue },

350+

sessionId: "exec-1",

351+

[`https://example.test/callback?token=${tokenValue}`]: "ok",

352+

aggregated: "x".repeat(120_000),

353+

tail: `GITHUB_TOKEN=${tokenValue} ${"x".repeat(

354+

1_940,

355+

)} ${boundaryGhToken} GITHUB_TOKEN=${leadingTailToken} {"token":"${omittedTailToken}"}`,

356+

sessions: [

357+

{

358+

sessionId: "proc-1",

359+

status: { state: "completed", token: tokenValue },

360+

command: `${"x".repeat(490)} --token ${tokenValue} ${"y".repeat(6_000)}`,

361+

aggregated: "a".repeat(80_000),

362+

tail: "z".repeat(8_000),

363+

},

364+

],

365+

},

366+

} as any);

367+368+

const toolResult = requirePersistedToolResult(sm);

369+

const serialized = JSON.stringify(toolResult.details);

370+

expect(toolResult.content[0]?.text).toBe("visible output stays small");

371+

expect(toolResult.details.persistedDetailsTruncated).toBe(true);

372+

expect(serialized).toContain("token=***");

373+

expect(serialized).toContain("partial secret span omitted");

374+

expect(serialized).toContain("boundary overlap omitted");

375+

expect(serialized).not.toContain(tokenValue);

376+

expect(serialized).not.toContain(boundaryGhToken.slice(0, 12));

377+

expect(serialized).not.toContain("a".repeat(100));

378+

expect(serialized).not.toContain("b".repeat(100));

379+

});

380+381+

it("redacts retained structured fields in fallback oversized details summaries", () => {

382+

const tokenValue = "fallback-token-abcdefghijklmnopqrstuv";

383+

const sm = guardSessionManager(SessionManager.inMemory(), {

384+

agentId: "main",

385+

sessionKey: "main",

386+

});

387+

const appendMessage = sm.appendMessage.bind(sm) as unknown as (message: AgentMessage) => void;

388+

appendMessage({

389+

role: "assistant",

390+

content: [{ type: "toolCall", id: "call_1", name: "exec", arguments: {} }],

391+

} as AgentMessage);

392+

appendMessage({

393+

role: "toolResult",

394+

toolCallId: "call_1",

395+

isError: false,

396+

content: [{ type: "text", text: "visible output stays small" }],

397+

details: {

398+

status: { state: "completed", token: tokenValue },

399+

sessionId: "exec-1",

400+

cwd: "/tmp/".concat("workspace/".repeat(400)),

401+

name: "oversized fallback command ".repeat(200),

402+

fullOutputPath: "/tmp/".concat("output/".repeat(400)),

403+

aggregated: "x".repeat(120_000),

404+

tail: "tail ".repeat(800),

405+

sessions: Array.from({ length: 10 }, (_, i) => ({

406+

sessionId: `proc-${i}`,

407+

status: "completed",

408+

command: `node script-${i}.js ${"x".repeat(6_000)}`,

409+

})),

410+

},

411+

} as any);

412+413+

const toolResult = requirePersistedToolResult(sm);

414+

const details = toolResult.details;

415+

const serialized = JSON.stringify(details);

416+

expect(details.persistedDetailsTruncated).toBe(true);

417+

expect(details.finalDetailsTruncated).toBe(true);

418+

expect(details.status?.token).toBe("***");

419+

expect(serialized).not.toContain(tokenValue);

420+

});

421+422+

it("does not persist lookahead text after redaction shrinks an oversized detail prefix", () => {

423+

const tokenValue = "abcdefghijklmnopqrstuvwx1234567890";

424+

const postBoundarySecret = "UNREDACTED_AFTER_LIMIT_SECRET";

425+

const shrinkPrefix = `${Array.from({ length: 20 }, () => `GITHUB_TOKEN=${tokenValue}`).join(

426+

" ",

427+

)} `;

428+

const tail = `${shrinkPrefix}${"x".repeat(

429+

2_300 - shrinkPrefix.length,

430+

)}${postBoundarySecret}${"z".repeat(5_000)}`;

431+

const sm = guardSessionManager(SessionManager.inMemory(), {

432+

agentId: "main",

433+

sessionKey: "main",

434+

});

435+

const appendMessage = sm.appendMessage.bind(sm) as unknown as (message: AgentMessage) => void;

436+

appendMessage({

437+

role: "assistant",

438+

content: [{ type: "toolCall", id: "call_1", name: "exec", arguments: {} }],

439+

} as AgentMessage);

440+

appendMessage({

441+

role: "toolResult",

442+

toolCallId: "call_1",

443+

isError: false,

444+

content: [{ type: "text", text: "visible output stays small" }],

445+

details: {

446+

status: "completed",

447+

aggregated: "x".repeat(120_000),

448+

tail,

449+

},

450+

} as any);

451+452+

const toolResult = requirePersistedToolResult(sm);

453+

const serialized = JSON.stringify(toolResult.details);

454+

expect(toolResult.details.persistedDetailsTruncated).toBe(true);

455+

expect(serialized).toContain("partial secret span omitted");

456+

expect(serialized).not.toContain(tokenValue);

457+

expect(serialized).not.toContain(postBoundarySecret);

458+

});

459+460+

it("fails closed for partially scanned oversized structured secret values", () => {

461+

const longSecret = "r".repeat(10_000);

462+

const sm = guardSessionManager(SessionManager.inMemory(), {

463+

agentId: "main",

464+

sessionKey: "main",

465+

});

466+

const appendMessage = sm.appendMessage.bind(sm) as unknown as (message: AgentMessage) => void;

467+

appendMessage({

468+

role: "assistant",

469+

content: [{ type: "toolCall", id: "call_1", name: "exec", arguments: {} }],

470+

} as AgentMessage);

471+

appendMessage({

472+

role: "toolResult",

473+

toolCallId: "call_1",

474+

isError: false,

475+

content: [{ type: "text", text: "visible output stays small" }],

476+

details: {

477+

status: "completed",

478+

tail: `${"x".repeat(1_000)}{"token":"${longSecret}${"z".repeat(1_000)}`,

479+

},

480+

} as any);

481+482+

const toolResult = requirePersistedToolResult(sm);

483+

const serialized = JSON.stringify(toolResult.details);

484+

expect(serialized).toContain("partial secret span omitted");

485+

expect(serialized).not.toContain("r".repeat(100));

486+

});

487+168488

it("caps oversized toolResult details without serializing the original payload", () => {

169489

const sm = guardSessionManager(SessionManager.inMemory(), {

170490

agentId: "main",

@@ -419,6 +739,28 @@ describe("tool_result_persist hook", () => {

419739

appendToolCallAndResult(sm);

420740

expectPersistedToolResultDetailsCapped(sm);

421741

});

742+743+

it("reapplies the details cap after redaction expands hook details", () => {

744+

const deepItems = Array.from({ length: 2_000 }, () => ({}));

745+

const hookDetails = { a: { b: { c: { d: { e: { f: { g: deepItems } } } } } } };

746+

initializeTempPlugin({

747+

tmpPrefix: "openclaw-toolpersist-details-redaction-expand-",

748+

id: "persist-details-redaction-expand",

749+

body: `export default { id: "persist-details-redaction-expand", register(api) {

750+

api.on("tool_result_persist", (event) => {

751+

return { message: { ...event.message, details: ${JSON.stringify(hookDetails)} } };

752+

}, { priority: 10 });

753+

} };`,

754+

});

755+756+

const sm = guardSessionManager(SessionManager.inMemory(), {

757+

agentId: "main",

758+

sessionKey: "main",

759+

});

760+761+

appendToolCallAndResult(sm);

762+

expectPersistedToolResultDetailsCapped(sm);

763+

});

422764

});

423765424766

describe("before_message_write hook", () => {

@@ -479,4 +821,4 @@ describe("before_message_write hook", () => {

479821

appendToolCallAndResult(sm);

480822

expectPersistedToolResultTextCapped(sm);

481823

});

482-

});

824+

});