Repository navigation
fix(compaction): avoid timeouts from obsolete session history - #180836
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 changesCompaction reads the complete current semantic window instead of hydrating obsolete retained history. Example: A Telegram session retains about 130,000 events across 19 resets, with about 2,400 events after the latest reset.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this PR addresses a source-confirmed compaction failure and preserves complete current-context coverage; no definite introduced defect was found. Priority: P1 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherGateway, automatic, and CLI compaction prepare a SessionManager through the existing durable or memory history owner, then summarize and persist a compaction boundary. flowchart TD
A[Gateway or automatic compaction] --> B[SessionManager preparation]
B --> C[Existing history owner]
C --> D[Complete current semantic window]
D --> E[Existing summarizer]
E --> F[Existing transcript writer]
Technical reviewBest possible solution: Use the existing history owners to load complete semantic compaction context while preserving archive rows, reset identity, ancestry, and ordinary replay limits. Do we have a high-confidence way to reproduce the issue? Current-main source confirms full retained-history hydration under an independent 60-second worker deadline, matching the linked release report; this read-only review ran no reproduction. Is this the best way to solve the issue? The rewrite repairs the read boundary through existing owners without changing reset identity or silently clipping summary coverage, and its added distinctions serve that invariant. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 804687a51137. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +105, Tests +247, Docs +2. Total +354 across 24 files. Added test files: 2. 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 HistoryReview history (2 earlier review cycles)
Reviewed October 23, 2026, 1:18 AM ET / 05:18 UTC (Revision 3). |
Preflight, manual and CLI-harness compaction opened an unbounded SessionManager, so a session that kept its id across resets hydrated its whole archive under the history worker's fixed read budget and never compacted. Compaction now reads the same bounded view an attempt or overflow recovery hydrates, and manual compaction reads its session facts inside that bounded snapshot. The bounded readers reserve the latest boundary ahead of the tail: when the newest turns alone fill the byte cap, the oldest of them give way so the previous compaction summary stays in the window that compaction summarizes. Closes openclaw#180514
7bebc1c to
aa79227
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…text Read the complete semantic window through the existing transcript owners, including the previous summary and reset/compaction retention. Preserve ancestry and the same selection across reloads; leave replay byte limits, stored history, schema, and reset identity unchanged. Rework the contributor's bounded-window fix to preserve summary coverage. Remove foreground/summarizer budget projection and ordinary replay changes. Validation uses isolated autoreview and PR CI; local dependency installation is refused by the host's older Node security patch level. Fixes openclaw#180514 Co-authored-by: Sukhdeep Johar <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…aw#180836) * fix(compaction): hydrate the bounded model-context view for compaction Preflight, manual and CLI-harness compaction opened an unbounded SessionManager, so a session that kept its id across resets hydrated its whole archive under the history worker's fixed read budget and never compacted. Compaction now reads the same bounded view an attempt or overflow recovery hydrates, and manual compaction reads its session facts inside that bounded snapshot. The bounded readers reserve the latest boundary ahead of the tail: when the newest turns alone fill the byte cap, the oldest of them give way so the previous compaction summary stays in the window that compaction summarizes. Closes openclaw#180514 * test(compaction): assert the prepared Gateway session through its typed shape * chore(compaction): satisfy formatting and SQL guardrails --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Sukhdeep Johar <[email protected]>
What Problem This Solves
Fixes compaction repeatedly timing out on long-lived sessions because every attempt hydrates obsolete history retained behind daily resets or
/new.Fixes #180514.
User Impact
Manual and automatic compaction load the complete current context, including the previous summary and boundary-retained messages, without loading obsolete archive history. A smaller foreground model does not discard older current messages or an oversized previous summary before summarization. Saved transcript rows, reset identity, retention, configuration, and the summarizer's existing input-budget policy are unchanged.
Why This Change Was Made
The manual preparation owner and automatic compaction opener requested full transcript hydration. That streamed all retained rows under the history worker's independent 60-second deadline, even though the compactor subsequently ignored obsolete history.
The maintainer rewrite uses the existing SQL and memory readers with a semantic-window selection: the latest boundary, its retained context, and following entries. Compaction retains custom messages and branch summaries in its kept tail; resets retain the existing paired message/tool-result subset. Complete prior summaries remain available regardless of ordinary replay byte limits. Existing ancestry metadata and the same selection survive manager reloads and writes.
This replaces the original attempt-window cap and removes its foreground/summarizer budget plumbing. Ordinary byte-capped turn reads keep their existing behavior. No schema, persistent state, config option, or new cache is introduced. A genuinely large current context can still require substantial work; this fix removes obsolete-history work without silently reducing summary coverage.
Simplification removed the model-budget fallback chain and the changes to ordinary replay reservation. Versus the merged main base, production is +242/-137 (net +105), tests +249/-2, and docs +2/-0. The remaining production growth carries an explicit complete-context selection through the existing SQL, memory, and reload owners; deleting those distinctions would reintroduce truncation or full archive reads. This uses the campaign LOC escape hatch.
Thanks @sukhdeepjohar for the original investigation, worker snapshot preparation, and regression intent. The contributor commits remain in this branch's history.
Evidence
5c24c3b645be001ccc34b213e9eac9933929d45c:session-manager.ts:475passes undefined hydration limits,compaction-session-execution.ts:137opens without limits, andsession-transcript-worker-runtime.ts:159defaults to 60 seconds.666f3feee0b4ec497441249fa67cd13a0da266c8, including changed Node tests, PostgreSQL conformance, lint, formatting, architecture guards, typechecks, and build. Fresh main was merged immediately before publication; it does not overlap the reviewed files.The first rewrite CI run 39902689520 passed the changed Node test jobs and typechecks. It found formatting differences in two files and a raw-SQL justification comment attached to the return statement instead of the SQL expression. The follow-up changes only formatting/comment placement; SQL and runtime behavior are unchanged. The repaired exact head now passes the complete workflow; no inherited-failure exception is needed.
ClawSweeper reviewed the rewritten head
666f3feee0b4ec497441249fa67cd13a0da266c8and found no actionable code defects; the earlier summary-coverage decision is resolved. Its sole remaining request is shipped-entry-point live proof. That proof-only hold is overridden by the explicit maintainer policy for this task: no local contributor-code execution, live Gateway/channel e2e, or remote leases; PR CI is the broad gate. This does not claim that CI supplies live-provider evidence. The single re-review request is complete.