Repository navigation
fix: compacted sessions incorrectly hit context read limits - #169723
evan-zhang wants to merge 2 commits into
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: needs real behavior proof before merge. What this changesAlign bounded session-context reads and byte accounting with the latest reset or compaction window while preserving required state. Example: A session contains a discarded 32,000-byte assistant reply, a retained user request, and a small compaction summary under a 20,000-byte read budget.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain This PR fixes a distinct defect still present on current main; the follow-up resolves the prior model-identity finding, and no new actionable code defect was identified. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherSQLite transcript projections feed session hydration and compaction-pressure accounting, converting durable events into bounded context and byte/count facts. flowchart TD
A[SQLite transcript] --> B[Active branch projection]
B --> C[Reset and compaction window]
C --> D[Required state controls]
C --> E[Bounded context acquisition]
D --> E
D --> F[Pressure accounting]
E --> G[SessionManager and AgentSession]
Technical reviewBest possible solution: Use the existing boundary-window owner for both bounded hydration and pressure accounting while retaining detached model state and cache checkpoints. Do we have a high-confidence way to reproduce the issue? Current-main source admits summarized ancestors into bounded acquisition while accounting excludes them; the added 32,000-byte-prefix regressions exercise that mismatch, but this read-only review ran no code. Is this the best way to solve the issue? The repair aligns the existing acquisition and accounting owners, preserves state through detached metadata, and avoids rewriting stored history or adding configuration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7c4ff5ae0a4c. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +250, Tests +836. Total +1086 across 10 files. Added test files: 2. View PR surface stats
Review metrics
LabelsLabel changes: No label 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 HistoryReview history (1 earlier review cycle)
Reviewed October 12, 2026, 4:56 AM ET / 08:56 UTC (Revision 2). |
|
This pull request has been automatically marked as stale after 7 days without qualifying human activity. |
|
Closing due to inactivity. |
What Problem This Solves
Fixes long SQLite-backed sessions refusing further work or compaction with a truncated-context error even after compaction reduced the active context below the read limit.
User Impact
Users can continue a compacted session without starting over. Existing byte and event limits still reject genuinely oversized active context; no data migration or transcript rewrite is required.
Why This Change Was Made
The pressure counter used the latest logical compaction window while the bounded reader could still charge summarized ancestors against its limit. Both now select the same retained semantic tail and required state controls. Cache checkpoint recovery continues to use the existing projection-prefix owner.
An omitted assistant that supplies model identity now contributes detached model metadata rather than its old message body, with matching admission and acquisition costs. Appending a newer model carrier invalidates the old cached control facts. Ambiguous legacy role predicates conservatively retain raw accounting and acquisition together.
Related: #115904, #160149.
Evidence
9ea2d5edd52ae727f4741aa5bb4dc47eecdcea1a. Indexed/unindexed minimal reproductions and the original native regression fail on that original runtime and pass with this repair. Additional indexed/unindexed discarded-assistant cases fail against the first PR head (32,563/32,524 bytes against a 20,000-byte budget); source hashes were restored exactly after runtime-only negative controls.SessionManager.openBoundedAsync→AgentSession.compactregression covers both old-user and discarded-assistant prefixes. Each performs three consecutive compact/reopen rounds, preserving seven task-state markers, the current tool call/result pair, and original stored-row digests. The deterministic provider only returns markers actually present in its request; the assistant variant also checks model identity on its first bounded open.The initial PR CI identified assertion-safety and database-worker call-count issues, addressed in the follow-up without changing guard baselines (worker calls remain 599; dialect occurrences remain mechanical 6/design 44). Its
uses a stale-version postimagefailure was independently reproduced on pinned starting main and the candidate with the sameSessionActorStaleVersionError; the affected actor/persistence/test files are unchanged. The built-CLI deletion lifecycle failure (agent.waitabort without the expected stop reason) remains unclassified. Current-head broad CI must still be evaluated; these are not reported as green checks.Full
build:runtimestops in the optional A2UI asset stage because that package/prebuilt bundle is absent in this isolated dependency setup. The officialopenclaw-unifiedruntime compiler passes. Tests use the official Vitest wrapper and database-worker lane. No live provider was called.Before merge, the requested shipped CLI/Gateway compact-and-continue trace is still needed. The consecutive-compaction checks exercise native SQLite/SessionManager/AgentSession with a deterministic offline summary provider; they do not establish shipped-CLI behavior, live-provider summary quality, client delivery, or production soak stability.