Repository navigation
fix(agents): preserve fresh tool result text under aggregate cap - #98955
Conversation
|
Codex review: passed. Reviewed July 2, 2026, 4:34 AM ET / 08:34 UTC. Summary PR surface: Source +54, Tests +124. Total +178 across 2 files. Reproducibility: yes. source-level: the linked issues give a deterministic saturated-history prompt projection path, and current main shows aggregate recovery can clear tool-result text to empty. I did not run a live WebChat or Discord session in this read-only review. Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land this narrow prompt-projection fix after maintainers accept the fresh-result priority tradeoff and required merge gates remain green. Do we have a high-confidence way to reproduce the issue? Yes, source-level: the linked issues give a deterministic saturated-history prompt projection path, and current main shows aggregate recovery can clear tool-result text to empty. I did not run a live WebChat or Discord session in this read-only review. Is this the best way to solve the issue? Yes, this is the best focused fix I found: it repairs the live prompt-projection helper that wipes fresh tool text, rather than only masking provider placeholder fallbacks or changing persisted session truncation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f2abf57d32ad. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +54, Tests +124. Total +178 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
My maintainer take on the remaining decision point: I would accept the fresh-result priority tradeoff and merge this after normal review. In saturated sessions, the newest tool result is the output the model most needs for the next step. Older tool-result history has already exceeded the aggregate budget, so preserving cache/projection stability for old text is less valuable than keeping a fresh I also think the current proof is sufficient for this specific root cause. The PR-head saturated prompt-history proof exercises the live projection helper that sits on the provider prompt boundary and shows fresh So my recommendation is option 1 from ClawSweeper: accept the fresh-result priority. The remaining risk is understood and documented: old model-visible tool output may shrink more aggressively under aggregate pressure, but that is the right behavior for recovering useful current tool output. |
|
@clawsweeper approve |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
@clawsweeper automerge |
|
🦞✅ Source: What merged:
Automerge notes:
The automerge loop is complete. Automerge progress:
|
…955) Summary: - The branch updates agent tool-result truncation so live prompt projection protects trailing fresh tool-resul ... ges under the aggregate cap, adds a bounded aggregate elision marker, and extends focused truncation tests. - PR surface: Source +54, Tests +124. Total +178 across 2 files. - Reproducibility: yes. source-level: the linked issues give a deterministic saturated-history prompt projecti ... clear tool-result text to empty. I did not run a live WebChat or Discord session in this read-only review. Automerge notes: - No ClawSweeper repair was needed after automerge opt-in. Validation: - ClawSweeper review passed for head 50069fdd6f7fe394611bd05c3ef2e428c29a17d0. - Required merge gates passed before the squash merge. Prepared head SHA: 50069fdd6f7fe394611bd05c3ef2e428c29a17d0 Review: openclaw/openclaw#98955 (comment) Co-authored-by: momothemage <[email protected]> Approved-by: momothemage
…955) Summary: - The branch updates agent tool-result truncation so live prompt projection protects trailing fresh tool-resul ... ges under the aggregate cap, adds a bounded aggregate elision marker, and extends focused truncation tests. - PR surface: Source +54, Tests +124. Total +178 across 2 files. - Reproducibility: yes. source-level: the linked issues give a deterministic saturated-history prompt projecti ... clear tool-result text to empty. I did not run a live WebChat or Discord session in this read-only review. Automerge notes: - No ClawSweeper repair was needed after automerge opt-in. Validation: - ClawSweeper review passed for head 50069fdd6f7fe394611bd05c3ef2e428c29a17d0. - Required merge gates passed before the squash merge. Prepared head SHA: 50069fdd6f7fe394611bd05c3ef2e428c29a17d0 Review: openclaw/openclaw#98955 (comment) Co-authored-by: momothemage <[email protected]> Approved-by: momothemage
Closes #98874
Related: #96857
What Problem This Solves
Fixes an issue where users in long-lived WebChat, Discord, or other direct agent sessions could see fresh text tool outputs such as
exec,read,browser, orsession_statusdegrade into(see attached image)or otherwise disappear from the model-visible prompt when aggregate tool-result history was already saturated.Why This Change Was Made
Prompt-history tool-result truncation now protects the trailing fresh tool-result batch first, then recovers aggregate budget from older projected history before falling back to trimming the fresh batch only when that batch itself exceeds the aggregate cap. Aggregate elision now uses a budget-bounded marker so the recovery plan cannot claim success while leaving counted tool-result text above the configured budget.
This stays scoped to the live prompt projection path; persisted session truncation and preemptive recovery estimates keep their existing aggregate-budget behavior.
User Impact
Agents can inspect small fresh command/file/status outputs even after old session history has filled the aggregate tool-result budget. Oversized or multi-tool fresh batches remain bounded, so context-overflow protection still applies without turning ordinary new text into an image-only placeholder.
Evidence
ABCoutput previously risked clearing the fresh result; the new test preservesABCwhile keeping total tool-result text within the 32k aggregate cap.feature/issue-98874-tool-result-textat50069fdd6f. The redactedtsxterminal proof importscreateToolResultPromptProjectionState,truncateOversizedToolResultsInMessages, andgetToolResultTextLength, fills the aggregate history with 50 priorexectool results, freezes that projection, then appends a freshexecresult containingABC:node scripts/run-vitest.mjs src/agents/embedded-agent-runner/tool-result-truncation.test.ts --maxWorkers=1 --reporter=dotpassed: 1 file / 42 tests.pnpm exec oxlint src/agents/embedded-agent-runner/tool-result-truncation.ts src/agents/embedded-agent-runner/tool-result-truncation.test.tspassed.git diff --checkpassed..agents/skills/autoreview/scripts/autoreview --mode localpassed with no accepted/actionable findings after the review-triggered fixes.AI-assisted: yes, implemented and reviewed with Codex.