Repository navigation
fix: avoid compaction from expired Anthropic runtime context - #186304
Conversation
Preserve append-only replay and raw storage limits while using the current Anthropic route to discount cleared runtime-context bodies for compaction and fallback windows. Refs #185044; thanks @travellingsoldier85 for the report.
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR excludes expired temporary Anthropic runtime-context bodies from compaction pressure and fallback-window sizing. Example: An Anthropic tool-driven turn renews a 30-KB runtime-context envelope across ten read calls with a 204,800-byte guard.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it addresses a confirmed compaction-accounting bug still present on main, preserves intentional append-only replay, and introduces no actionable defect found in this review. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherTranscript accounting and the selected provider route feed compaction admission and context assembly, which produce either a compaction request or a bounded model-history view while retaining stored replay. flowchart TD
A[Stored transcript] --> B[Raw byte accounting]
A --> C[Bounded history read]
D[Current Anthropic route] --> E[Expired body classification]
C --> E
B --> F[Compaction pressure]
E --> F
F --> G[Compaction admission]
E --> H[Fallback context window]
Technical reviewBest possible solution: Use shared, route-aware expiration accounting for compaction decisions while preserving transcript bytes and raw acquisition limits. Do we have a high-confidence way to reproduce the issue? Current-main source establishes renewal, provider-side expiration, and raw-byte admission; the supplied Gateway comparison exercises the reported interaction, although this read-only review ran no product code. Is this the best way to solve the issue? The change fixes the accounting owner rather than deleting intentional replay carriers, shares expiration semantics with fallback sizing, and conservatively preserves existing behavior on other routes. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 577ab8628f35. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +189, Tests +205, Docs +6. Total +400 across 12 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 27, 2026, 5:08 PM ET / 21:08 UTC. |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
Inherited failure details: |
…w#186304) * fix: ignore expired runtime context in compaction pressure Preserve append-only replay and raw storage limits while using the current Anthropic route to discount cleared runtime-context bodies for compaction and fallback windows. Refs openclaw#185044; thanks @travellingsoldier85 for the report. * test: simplify compaction pressure accounting stub * test: acknowledge declined compaction latch writes
Closes #185044. Thanks @travellingsoldier85 for the report.
What Problem This Solves
Fixes premature compaction after tool rounds renew temporary Anthropic runtime context, even when the effective model context remains below the configured byte guard.
User Impact
Long tool-driven turns keep their useful history without unnecessary compaction. Stored transcripts remain append-only, and raw storage and history-read bounds stay unchanged. No configuration or migration is required.
Why This Change Was Made
The byte-pressure owner now discounts only runtime-context body bytes proven expired by the current direct Anthropic API-key route. It retains envelope bytes and all history outside the bounded read. Preflight, manual compaction, the retry latch, and fallback-window selection use the same accounting semantics. OAuth, proxy routes, persistent updates, and ordinary history retain their existing byte charge.
Evidence
Reproduced through an isolated macOS Gateway using a deterministic Anthropic-compatible SSE relay: a 30-KB ingress envelope and ten real
readtool rounds. The stored carriers and serialized wire payload remain intact.The fixed ten-tool turn completed in 5.027s. Its request carried 341,828 serialized message bytes and 34,168 effective bytes after
clear_at. A 0.139s follow-up retained all ten tool results; all 49 prior transcript rows were byte-identical. Real Ollamaqwen3:8binference also passed through the Gateway before and after the fix (one read, expected terminal reply; 11.900s / 4.125s). These timings are observations, not a performance comparison.Focused tests: 88 passed across eight files/five shards (862.96s, including cold compilation); the final fixture cleanup also passes the six-case regression rerun (115.68s). The new preflight regression fails on the original code and passes with the fix; controls cover non-clearing API routes, OAuth, proxies, persistent updates, and genuine user history. Production and touched-test types, lint, formatting, docs links, and all seven affected ratchets pass. Full build passes (15m42s). Isolated Codex review is clean at P0–P2.
Production LOC: +215/-26 (net +189); tests: +206/-1 (net +205). The added bounded reader shares current-route classification and conservative accounting across the pressure consumers; the same expiration classifier serves fallback sizing. Storage retains its existing raw counters.
Limitations: macOS local proof only; no live Anthropic API call. Rows outside the bounded accounting read remain conservatively charged. Wire bandwidth and disk footprint are unchanged.
Hosted reviews completed on
49a326c: GitHub Codex and ClawSweeper reported no findings; ClawSweeper lists no before-merge items and rates the supplied proof sufficient.CI at handoff (2026-10-27 21:33 UTC): run 40581738226 has 20 successful checks and 28 queued jobs, with no failed checks. The required
openclaw/ci-gateremains pending. Landing awaits that gate.