Repository navigation
fix: every agent attempt re-hashes unchanged tool descriptions because the report digest cache can never hit - #129145
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 26, 2026, 5:31 AM ET / 09:31 UTC. ClawSweeper reviewWhat this changesThe PR adds a bounded content-keyed cache for tool-description hashes and regression tests for tool objects rebuilt between prompt-report builds. Merge readiness⛔ Blocked until real behavior proof is added - 3 items remain Keep open. Current main still re-hashes summaries after the object-keyed entry-cache miss, while this branch adds a bounded cache keyed by the exact summary text; the prior retained-bytes concern is resolved. The remaining merge blocker is the contributor’s acknowledged lack of after-fix real runtime proof. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherBefore each agent attempt, OpenClaw finalizes authorized tools and builds a system-prompt report for session metadata. That report hashes tool summaries and then feeds prompt accounting used alongside the model attempt. flowchart LR
A[Authorized tools] --> B[Tool finalization]
B --> C[System prompt report]
C --> D[Summary digest cache]
D --> E[Session prompt metadata]
E --> F[Model attempt]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +26, Tests +104. Total +130 across 2 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the bounded content-keyed digest cache only after a real after-fix trace confirms report output is unchanged and rebuilt tools avoid repeated summary hashing. Do we have a high-confidence way to reproduce the issue? Yes, from source: finalization creates fresh tool identities while current-main report generation keys its entry cache on those identities and re-hashes summaries after each miss; the review did not execute a live agent attempt. Is this the best way to solve the issue? Yes. Caching only the pure hash of the already-trimmed summary fixes the broken reuse boundary without conflating schema metadata or retaining full tool wrappers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7da8c19fd021. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
ce2e19c to
8f62f2f
Compare
…of tool identity
toolReportEntryCache is a WeakMap keyed on the AgentTool object, but
finalizeAgentTools rebuilds every tool on every attempt (normalizeToolParameters
returns a {...tool} copy, then three more wrapper .map passes), so the cache
misses 100% of the time and buildSystemPromptReport re-runs one sha256 per tool
per attempt over an unchanged description.
Add a bounded content-keyed layer for the summary digest, keyed on the exact
string hashed, so it survives the tool-object churn. Byte-identical by
construction. Schema stats deliberately stay on toolSchemaStatsCache so a tool
reusing a name and description with different parameters still reports its own
schemaHash.
The 512-entry limit bounded cardinality only. Keys are the summary text, so a sequence of large runtime-generated descriptions could pin megabytes for the process lifetime. Summaries over the length cap still hash, they just never enter the cache.
8f62f2f to
d3d8fe5
Compare
Remove the stale whole-tool report cache. Reuse only pure summary hashes across rebuilt tool wrappers while keeping schema statistics with the parameter object owner. Bound both retained key size and entry count; cover real finalization, Code Mode updates, schema replacement, and oversized summaries. Co-authored-by: Tran Quang <[email protected]>
|
@clawsweeper re-review Replaced the whole-tool object cache with bounded summary-content hashing and retained the existing schema-statistics owner. The actual Node 24 tool finalizer/reporter/Code Mode trace reproduces stale metadata and repeated hashing before the repair, then current metadata and 8-to-2 hash reuse afterward. The body records the local regression watchdog limitation; fresh exact-head hosted execution remains required before landing. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Keep plain-Node fixture actors lightweight while resolving the canonical identity helper and its transitive TypeScript imports for cleanup cancellation. Preserve real process ownership and existing deadlines.
|
@clawsweeper re-review The final candidate is now |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Keep main's equivalent cancellation-fixture loader verbatim, resolving the parallel explanatory comment while preserving contributor ancestry. The tested reporter and regression bytes remain unchanged. Co-authored-by: Tran Quang <[email protected]>
|
@clawsweeper re-review The latest durable review is from August 26 and earlier refreshes failed source verification. Current head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…e the report digest cache can never hit (openclaw#129145) * fix(agents): key the per-tool report digest cache on content instead of tool identity toolReportEntryCache is a WeakMap keyed on the AgentTool object, but finalizeAgentTools rebuilds every tool on every attempt (normalizeToolParameters returns a {...tool} copy, then three more wrapper .map passes), so the cache misses 100% of the time and buildSystemPromptReport re-runs one sha256 per tool per attempt over an unchanged description. Add a bounded content-keyed layer for the summary digest, keyed on the exact string hashed, so it survives the tool-object churn. Byte-identical by construction. Schema stats deliberately stay on toolSchemaStatsCache so a tool reusing a name and description with different parameters still reports its own schemaHash. * fix: bound the bytes retained by the tool summary digest cache The 512-entry limit bounded cardinality only. Keys are the summary text, so a sequence of large runtime-generated descriptions could pin megabytes for the process lifetime. Summaries over the length cap still hash, they just never enter the cache. * test(ci): load cancellation identity helpers through tsx Keep plain-Node fixture actors lightweight while resolving the canonical identity helper and its transitive TypeScript imports for cleanup cancellation. Preserve real process ownership and existing deadlines. --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Tran Quang <[email protected]>
What Problem This Solves
Rebuilt tool definitions miss the report's object-keyed cache, so unchanged descriptions are hashed again during prompt preparation. A retained tool can also keep stale summary metadata after Code Mode updates its description.
Cache only the SHA-256 of normalized summary content, bounded to 512 keys of at most 4,096 UTF-16 units. Remove the whole-entry object cache and keep schema statistics with their existing parameter-identity owner. Unchanged reports stay identical; updated descriptions and replaced parameter objects produce current metadata. No persistent store, configuration, or schema changes. Fixes #129116.
Evidence
Before editing, a Node 24.20.0 runtime probe called the actual tool finalizer, reporter, and Code Mode updater on trusted main. Normal hook and abort wrappers rebuilt tool objects while retaining schema objects. Reports stayed byte-equivalent, but SHA-256 calls were 8 on the first report and 5 on the next instead of 2; a retained wrapper also returned the old description hash. A separately authored equivalent repair changed that sequence to 8→2 and returned the current hash. The tested reporter bytes match the published candidate. This synthetic runtime-owner probe did not use a live Gateway session.
The same-host observations for 1,000 actual finalizations and reports were 0.042743 / 0.011746 seconds before/after. Full cold-process times were 33.128 / 124.215 seconds and RSS was 599,556,096 / 482,590,720 bytes. Imports and concurrent host activity dominate the cold runs, so these observations are not a throughput claim.
The authored regression suite failed on unchanged production with three expected failures and one passing oversized-key control. Its local positive run reached the canonical 900-second no-output watchdog before assertions; a process sample showed a filesystem rename wait, and the automatic retry was stopped. Hosted CI closes that gap: exact published head
7fa21e19f17901f671710594cda5ced6b47570d7passed all four new cases in reporter job 99424422578, with 1,479 passing tests in the full shard. Coverage uses real finalization, the real Code Mode updater, independent schema replacement, and oversized-key bypass. Contributor source was not executed locally; all trusted proof overlays were restored.CI also exposed a shared test-fixture loader regression before the cancellation supervisor could start: plain Node could not resolve the canonical PID helper's transitive source
.jsimport. Main now contains the equivalenttsx/esm/apiimport repair for the cancellation-only supervisor/fake-Git branch. The ordinary main merge keeps that fixture verbatim, resolving only a parallel two-line comment edit and removing the fixture from this PR's final diff. Existing real-fixture tests reproduce the loader failure before and pass cancellation, early-exit, sentinel, and identity controls afterward. No production imports, process-identity checks, timeouts, retries, or dependencies change.That fixture code passed the previously published candidate's Linux CI. Small-43 passed all 159 tests, including base-policy and workflow-sanity cancellation during timeout drainage. Small-45 passed 1,484 tests, including the early-owner-exit case. Small-46 passed 2,151 tests, including prepare and publish TERM-resistant cleanup cancellation in 21.7 and 21.4 seconds. These Linux results close the earlier Mac deadline gap without changing timeouts. Workflow 33371721400 completed successfully; the exact-head rollup has 220 successful checks, 44 skipped, one neutral, and no pending or failed checks.
The latest ClawSweeper request for an after-fix producer trace is addressed by the actual finalizer/report sequence above; a refresh has been requested on the final head in comment 5476852549. Its persisted-cache/schema warning does not apply to this process-local Map. Codex's separate dynamic-tool report owner is unchanged. Production +21/-8 (net +13), regression tests +112/-0, test support +0/-0 after retaining main's fixture. Production growth bounds pure-function reuse while removing the stale whole-entry cache. The complete two-file candidate passed fresh P0 review after main integration; reporter and regression bytes are unchanged from green head
7fa21e19. Trusted formatting and configured private staged scanning also passed. Final published-head native review, guard, artifact validation, and CI have completed successfully. Thanks @quangtran88 for the original fix.The final ordinary main merge is
68bd798bb2305075ce6b9ff3cd58c3d0debc04b7. Contributor ancestry is preserved, the only conflict keeps main's fixture comments, and the two cache files exactly match the previously tested repair.Final CI 33377097618 passed on this exact head after one failed-jobs-only rerun. The reporter job passed all four regression cases and 1,479 tests. The rerun job 99450543374 passed 7,585 tests across 646 files; the final rollup has 219 successful checks, 46 skipped, one neutral, and no pending or failed checks.
Named follow-up: the first attempt timed out in an unchanged global-session worker error-payload test at 123.414 seconds; the same case passed the retry in 107.537 seconds, while its main-agent control took 22 ms. Exact CI merge-source comparison and separate job routing found no candidate causal path. Its slow phase remains undiagnosed; this is not a root-cause repair claim. No timeout, assertion, environment or source changes were made for the retry.