Repository navigation
improve: bound retained tool-result projection data - #139157
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 5, 2026, 11:03 AM ET / 15:03 UTC. ClawSweeper reviewWhat this changesReduces memory retained between agent turns by replacing cached original tool-output text and complete messages with source hashes and the content needed for replay. Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this optimization remains useful on current main, and the introduced patch has no blocking correctness findings. Priority: P2 Review scores
Verification
How this fits togetherThe embedded agent runner prepares conversation history before sending it to a model. Its session-owned projection cache preserves previously shortened tool results across turns while canonical history supplies current metadata and images. flowchart TD
A[Canonical conversation history] --> B[Tool-result projection]
C[Source hashes and retained content] --> B
B --> C
D[Saved pruning markers] --> B
B --> E[Model request]
F[Compaction or session reset] --> C
Before merge
Agent review detailsSecurityNone. PR surfaceSource +21, Tests +56, Other 0. Total +77 across 11 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep the compact session-owned cache and existing replay lifecycle; arbitrary entry eviction would discard still-needed frozen projections. Do we have a high-confidence way to reproduce the issue? Yes for excess retention: current main stores full source strings and replacement messages, and the PR supplies a concrete cache-only heap comparison. This read-only review did not rerun it. Is this the best way to solve the issue? Yes. Repairing the shared storage owner removes redundant retention without expiring frozen projections or changing persisted markers; the small production increase supports the distinct ordinary and TTL replay contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 12a3b102f507. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
* origin/main: (46 commits) fix(gateway): keep chat metadata responsive across auth refresh (openclaw#139192) fix(doctor): keep Workshop relocation lint read-only (openclaw#139193) perf(ui): retain unchanged forwarded avatar publications (openclaw#139181) fix(config): guide exec policy migration repairs (openclaw#139143) test(i18n): refresh representative Watch key (openclaw#139197) fix(agents): preserve recovered scheduled-run outcomes (openclaw#139037) refactor(acp): simplify pending operation accounting (openclaw#139189) fix(plugin-sdk): harden account scope for pairing requests and challenges (openclaw#139142) perf(gateway): avoid redundant PR landing ancestry checks (openclaw#139186) perf(ui): release captured audio cache leases directly (openclaw#139174) fix(skills): validate names in library forms (openclaw#139184) fix(sessions): reduce cold catalog listing delays (openclaw#139146) perf(cron): scan preserved action output once (openclaw#139163) fix(agents): keep fresh tool results readable under context pressure (openclaw#139165) fix(compaction): heartbeat sessions ignore the active transcript byte cap (openclaw#136533) perf(agents): reuse snapshotted web search result rows (openclaw#139162) fix(onboarding): keep Tauri setup recoverable and verify model results (openclaw#139140) fix(memory): rank indexed sessions by source activity (openclaw#139112) perf(terminal): avoid rebuilding sanitized link fallbacks (openclaw#139159) perf(agents): bound retained tool result projection data (openclaw#139157) ...
What Problem This Solves
The session-owned tool-result projection cache retained complete source text for every frozen result, including results that did not need truncation. Cached replacement messages also retained details and non-text content. A long history could therefore keep large read/web outputs alive after the caller released the original messages.
Why This Change Was Made
Store a framed SHA-256 source digest and only the projected output needed for replay. The shared projection-state owner records text blocks for ordinary truncation and exact projected content for cache-TTL replay. Current canonical messages supply metadata and non-text blocks. This removes the complete-message cache and original-text arrays without changing the existing identity, reset, compaction, TTL marker, or source-rewrite invalidation rules.
User Impact
Less session-cache retention after large tool outputs leave the active caller. Existing projected prompt bytes remain frozen across attempts, current metadata stays current, and compaction/reset reclaim the same entries. There is no new setting, schema, storage format or provider eligibility change.
Production +67/-46 (net +21); tests/support +89/-33 (net +56); assertion baseline +1/-1. The production growth establishes one projection-storage owner shared by ordinary and TTL replay. It replaces complete message/source retention while preserving their different content contracts; this ownership boundary needs the additional code.
Evidence
openai/gpt-5.6-lunamodel across code-mode and tool-search profiles, 14 stages and 50 phases. That B1 run exited cleanly without forced shutdown; all 69 owned process identities and both listeners were cleared. This proves compiled behavior for the combined candidate, not an isolated performance gain from this PR.Related #127992 changes OpenAI cache-TTL route eligibility. This PR changes the generic projection cache representation and leaves that eligibility policy untouched.
Data-model compatibility proof: only the process-local projection cache representation changes. Source hashes are never serialized. The existing
openclaw.cache-ttlmarker still records the same projection key, soft/hard mode and hard-clear placeholder; its reader is unchanged. Existing saved markers rebuild the compact cache through the same restoration path, and final soft/hard restart, pruning-disabled replay, ambiguous-key, compaction/reset and malformed-content tests pass. The canonical transcript and SQLite schema/versions are unchanged, so no migration or upgrade action is required. This addresses the latest ClawSweeper compatibility request; there are no code findings or separate rank-up moves.Current-main composition: external #139156 adds synchronous replacement-plan budget measurements in the same module. A conflict-free merge-tree reconstruction preserves its changes and this exact introduced patch (stable patch ID
5819fd67901d77fd1834925312b9129da738a8e7); those measurements never enter session projection state. The isolated measurements above remain attributed to the reviewed candidate, not this additional upstream optimization. Exact-head CI run 33973209966 passed.