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

推荐订阅源

GbyAI
GbyAI
Martin Fowler
Martin Fowler
云风的 BLOG
云风的 BLOG
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
The Blog of Author Tim Ferriss
大猫的无限游戏
大猫的无限游戏
A
About on SuperTechFans
小众软件
小众软件
博客园_首页
博客园 - 聂微东
罗磊的独立博客
Recent Announcements
Recent Announcements
U
Unit 42
N
Netflix TechBlog - Medium
Blog — PlanetScale
Blog — PlanetScale
阮一峰的网络日志
阮一峰的网络日志
博客园 - 叶小钗
V
V2EX
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
Stack Overflow Blog
Stack Overflow Blog
博客园 - Franky
D
DataBreaches.Net
Last Week in AI
Last Week in AI

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(agents/harness): pass tool results through tool-resul...
solomonneas · 2026-05-13 · via Recent Commits to openclaw:main

@@ -106,6 +106,108 @@ describe("createAgentToolResultMiddlewareRunner", () => {

106106

expect(result.details).toEqual({ status: "error", middlewareError: true });

107107

});

108108109+

it("delivers tool result unchanged when no middleware is registered", async () => {

110+

// Without a middleware handler, the harness has no validator contract to

111+

// satisfy and must not penalize tool emitters that legitimately produce

112+

// dependency payloads (functions, cycles) on `details`.

113+

const client: Record<string, unknown> = { type: "fake-channel-client" };

114+

const cyclicDetails: Record<string, unknown> = {

115+

ok: true,

116+

messageId: "abc",

117+

delete: () => Promise.resolve(),

118+

client,

119+

};

120+

client.message = cyclicDetails;

121+

const original = {

122+

content: [{ type: "text" as const, text: "delivered" }],

123+

details: cyclicDetails,

124+

};

125+

const runner = createAgentToolResultMiddlewareRunner({ runtime: "pi" }, []);

126+127+

const result = await runner.applyToolResultMiddleware({

128+

toolCallId: "call-1",

129+

toolName: "message",

130+

args: {},

131+

result: original,

132+

});

133+134+

expect(result).toBe(original);

135+

});

136+137+

it("sanitizes incoming cyclic details so a no-op middleware does not fail closed", async () => {

138+

// The bug class behind silent Discord delivery in 2026.5.5: any plugin

139+

// that registers a tool-result middleware (e.g. bundled tokenjuice)

140+

// causes the harness to validate `event.result` against shape rules,

141+

// and tool emitters' raw channel-send payloads fail those rules.

142+

const client: Record<string, unknown> = { type: "fake-channel-client" };

143+

const payload: Record<string, unknown> = {

144+

ok: true,

145+

messageId: "1501757759073419394",

146+

delete: () => Promise.resolve(),

147+

client,

148+

};

149+

client.message = payload;

150+

const runner = createAgentToolResultMiddlewareRunner({ runtime: "pi" }, [() => undefined]);

151+152+

const result = await runner.applyToolResultMiddleware({

153+

toolCallId: "call-1",

154+

toolName: "message",

155+

args: {},

156+

result: {

157+

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

158+

details: payload,

159+

},

160+

});

161+162+

expect((result.details as { middlewareError?: boolean }).middlewareError).toBeUndefined();

163+

expect(result.details).toEqual({

164+

ok: true,

165+

messageId: "1501757759073419394",

166+

client: { type: "fake-channel-client" },

167+

});

168+

});

169+170+

it("sanitizes incoming function/symbol/bigint values in details", async () => {

171+

const runner = createAgentToolResultMiddlewareRunner({ runtime: "codex" }, [() => undefined]);

172+173+

const result = await runner.applyToolResultMiddleware({

174+

toolCallId: "call-1",

175+

toolName: "exec",

176+

args: {},

177+

result: {

178+

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

179+

details: {

180+

ok: true,

181+

exitCode: 0,

182+

callback: () => 1,

183+

tag: Symbol("x"),

184+

missing: undefined,

185+

id: 10n,

186+

},

187+

},

188+

});

189+190+

expect(result.details).toEqual({ ok: true, exitCode: 0, id: "10" });

191+

});

192+193+

it("collapses oversized incoming details to a truncation marker", async () => {

194+

const runner = createAgentToolResultMiddlewareRunner({ runtime: "pi" }, [() => undefined]);

195+196+

const result = await runner.applyToolResultMiddleware({

197+

toolCallId: "call-1",

198+

toolName: "exec",

199+

args: {},

200+

result: {

201+

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

202+

details: { blob: "x".repeat(200_000) },

203+

},

204+

});

205+206+

const sanitized = result.details as { truncated?: boolean; originalSizeBytes?: number };

207+

expect(sanitized.truncated).toBe(true);

208+

expect(sanitized.originalSizeBytes ?? 0).toBeGreaterThan(100_000);

209+

});

210+109211

it("accepts well-formed middleware results", async () => {

110212

const runner = createAgentToolResultMiddlewareRunner({ runtime: "codex" }, [

111213

(_event, ctx) => ({