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

推荐订阅源

V
V2EX
博客园 - 叶小钗
Last Week in AI
Last Week in AI
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Microsoft Security Blog
Microsoft Security Blog
腾讯CDC
P
Proofpoint News Feed
大猫的无限游戏
大猫的无限游戏
The Cloudflare Blog
aimingoo的专栏
aimingoo的专栏
月光博客
月光博客
量子位
A
About on SuperTechFans
Engineering at Meta
Engineering at Meta
Apple Machine Learning Research
Apple Machine Learning Research
Jina AI
Jina AI
博客园 - Franky
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
D
DataBreaches.Net
博客园_首页
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog

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): thread post-compaction guard observer ·...
steipete · 2026-05-05 · via Recent Commits to openclaw:main

@@ -4,7 +4,10 @@ import type {

44

getDiagnosticSessionState as GetDiagnosticSessionStateType,

55

SessionState,

66

} from "../../logging/diagnostic-session-state.js";

7-

import type { wrapToolWithBeforeToolCallHook as WrapToolWithBeforeToolCallHookType } from "../pi-tools.before-tool-call.js";

7+

import type {

8+

ToolOutcomeObserver,

9+

wrapToolWithBeforeToolCallHook as WrapToolWithBeforeToolCallHookType,

10+

} from "../pi-tools.before-tool-call.js";

811

import type {

912

recordToolCall as RecordToolCallType,

1013

recordToolCallOutcome as RecordToolCallOutcomeType,

@@ -72,6 +75,7 @@ async function executeWrappedToolOutcome(

7275

toolName: string,

7376

toolParams: unknown,

7477

result: unknown,

78+

onToolOutcome?: ToolOutcomeObserver,

7579

runId = baseParams.runId,

7680

): Promise<unknown> {

7781

const tool = wrapToolWithBeforeToolCallHook(

@@ -84,6 +88,7 @@ async function executeWrappedToolOutcome(

8488

sessionKey: baseParams.sessionKey,

8589

sessionId: baseParams.sessionId,

8690

runId,

91+

onToolOutcome,

8792

},

8893

);

8994

liveToolCallSeq += 1;

@@ -159,12 +164,15 @@ describe("post-compaction loop guard wired into runEmbeddedPiAgent", () => {

159164

// Attempt 2: post-compaction. The live wrapped-tool path records each

160165

// outcome while the prompt is still running; the third identical result

161166

// aborts before the attempt can return.

162-

mockedRunEmbeddedAttempt.mockImplementationOnce(async () => {

167+

mockedRunEmbeddedAttempt.mockImplementationOnce(async (attemptParams: unknown) => {

168+

const onToolOutcome = (attemptParams as { onToolOutcome?: ToolOutcomeObserver })

169+

.onToolOutcome;

163170

for (let i = 0; i < 3; i += 1) {

164171

await executeWrappedToolOutcome(

165172

"gateway",

166173

{ action: "lookup", path: "x" },

167174

"identical-result",

175+

onToolOutcome,

168176

);

169177

}

170178

attemptReturned = true;

@@ -200,9 +208,16 @@ describe("post-compaction loop guard wired into runEmbeddedPiAgent", () => {

200208

// Attempt 2 (post-compaction): identical args, but DIFFERENT result hash

201209

// each time. This fills the window without triggering the persisted-loop

202210

// abort because the tool is making progress.

203-

mockedRunEmbeddedAttempt.mockImplementationOnce(async () => {

211+

mockedRunEmbeddedAttempt.mockImplementationOnce(async (attemptParams: unknown) => {

212+

const onToolOutcome = (attemptParams as { onToolOutcome?: ToolOutcomeObserver })

213+

.onToolOutcome;

204214

for (let i = 0; i < 3; i += 1) {

205-

await executeWrappedToolOutcome("gateway", { action: "lookup", path: "x" }, `result-${i}`);

215+

await executeWrappedToolOutcome(

216+

"gateway",

217+

{ action: "lookup", path: "x" },

218+

`result-${i}`,

219+

onToolOutcome,

220+

);

206221

}

207222

return makeAttemptResult({

208223

promptError: null,

@@ -235,9 +250,11 @@ describe("post-compaction loop guard wired into runEmbeddedPiAgent", () => {

235250

// Attempt 2 (post-compaction): two distinct records → window full,

236251

// guard disarms with no abort. We then append more identical records

237252

// afterwards in this test to confirm they are not observed by the guard.

238-

mockedRunEmbeddedAttempt.mockImplementationOnce(async () => {

239-

await executeWrappedToolOutcome("read", { path: "/a" }, "ra");

240-

await executeWrappedToolOutcome("write", { path: "/b" }, "rb");

253+

mockedRunEmbeddedAttempt.mockImplementationOnce(async (attemptParams: unknown) => {

254+

const onToolOutcome = (attemptParams as { onToolOutcome?: ToolOutcomeObserver })

255+

.onToolOutcome;

256+

await executeWrappedToolOutcome("read", { path: "/a" }, "ra", onToolOutcome);

257+

await executeWrappedToolOutcome("write", { path: "/b" }, "rb", onToolOutcome);

241258

return makeAttemptResult({

242259

promptError: null,

243260

toolMetas: [{ toolName: "read" }, { toolName: "write" }],

@@ -293,12 +310,15 @@ describe("post-compaction loop guard wired into runEmbeddedPiAgent", () => {

293310

// Attempt 2 (post-compaction): three identical live tool outcomes while

294311

// history is already at the cap. The guard aborts on the third result

295312

// before the mocked attempt can return.

296-

mockedRunEmbeddedAttempt.mockImplementationOnce(async () => {

313+

mockedRunEmbeddedAttempt.mockImplementationOnce(async (attemptParams: unknown) => {

314+

const onToolOutcome = (attemptParams as { onToolOutcome?: ToolOutcomeObserver })

315+

.onToolOutcome;

297316

for (let i = 0; i < 3; i += 1) {

298317

await executeWrappedToolOutcome(

299318

"gateway",

300319

{ action: "lookup", path: "x" },

301320

"identical-result",

321+

onToolOutcome,

302322

);

303323

}

304324

// History is still capped at HISTORY_TRIM_CAP after the trim.