Repository navigation
fix(agents): scale aggregate tool-result budget with context window and compact on pressure - #100077
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 4, 2026, 3:51 PM ET / 19:51 UTC. Summary PR surface: Source +127, Tests +145. Total +272 across 6 files. Reproducibility: Source-reproducible: current main still applies a fixed aggregate prompt-history cap while compaction routing is window-relative, and the linked issue includes logs. I did not run a live long-lived 1M-window provider replay in this read-only review. Review metrics: 2 noteworthy metrics.
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:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Fix the failing test type error, add redacted after-fix runtime proof for the aggregate-pressure recovery path, and land this only after maintainers accept the new session recovery policy. Do we have a high-confidence way to reproduce the issue? Source-reproducible: current main still applies a fixed aggregate prompt-history cap while compaction routing is window-relative, and the linked issue includes logs. I did not run a live long-lived 1M-window provider replay in this read-only review. Is this the best way to solve the issue? No, not as submitted: the implementation is in the right runtime area, but the branch currently fails a required type check and lacks after-fix real behavior proof. Maintainers also need to accept the aggregate-pressure recovery policy before merge. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2f6459093ad3. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +127, Tests +145. Total +272 across 6 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
|
cdbf11b to
dc15eb3
Compare
What Problem This Solves
Fixes #100042.
OpenClaw had a unit mismatch between window-relative compaction and an absolute aggregate tool-result cap. Large
contextWindowsessions could hit the 256k-char aggregate tool-result clamp on every model call long before window-relative compaction saw pressure, silently truncating even fresh tool output to empty content while only emitting an INFO-level signal.Why This Change Was Made
The aggregate tool-result budget now scales with the model context window:
max(perResultMaxChars * 4, floor(contextWindowTokens * 4 * 0.5)). The 0.5 share mirrors safeguard compactionmaxHistoryShareandSINGLE_TOOL_RESULT_CONTEXT_SHARE, while the 4x per-result floor preserves existing small-window behavior.Trailing tool results are structurally excluded from aggregate clearing and protected with the 2000-char min-keep floor when truncation is still needed. Protected trailing aggregate pressure is reported separately from destructive replacements, so fresh output can request compaction without being erased.
Aggregate engagement is routed through the existing precheck overflow recovery as
compact_then_truncate, so the session performs real compaction and then runs the persistent tool-result truncation backstop for forward progress. Failure mode is bounded:MAX_OVERFLOW_COMPACTION_ATTEMPTS = 3, then one persistent truncation attempt, then explicit give-up with the existing blocked context-overflow response; no unbounded compaction loop.User Impact
Large-
contextWindowsessions no longer silently lose fresh tool output just because the absolute aggregate cap was hit. Operators get a once-per-session WARN with/compactand/newhints when aggregate pressure engages. Small-window behavior is unchanged because the old 4x aggregate floor is preserved.Evidence
Field evidence for the failure mode is documented in issue #100042.
Verification run after the final rebase:
pnpm tsgo— passed, exit code 0.node scripts/run-vitest.mjs src/agents/embedded-agent-runner/tool-result-truncation.test.ts— passed, 47 tests.node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/attempt.spawn-workspace.context-engine.test.ts— passed, 69 tests.git diff --check— passed..agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main --prompt-file <issue-context>— clean, no accepted/actionable findings.