Repository navigation
fix(compaction): stop a failed summary audit from leaving a session permanently uncompactable - #130393
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. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Codex review: needs real behavior proof before merge. What this changesThis PR commits a bounded degraded summary after exhausted quality checks and preserves visible warnings about lost context. Example: Native Ollama llama3.2 with an 8,192-token context, a 48-token output cap, and notifyUser false.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain This PR retains useful, owner-approved recovery work that current main does not provide; no definite introduced bug was found. Priority: P1 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe safeguard receives prepared conversation history and model summaries, fits and audits them, and passes committed boundaries through SQLite storage, session events, replies, and status. flowchart TD
A[Prepared conversation history] --> B[Safeguard summarization]
B --> C[Budget and quality audit]
C --> D[Accepted or degraded summary]
D --> E[SQLite transcript owner]
E --> F[Session continuation]
E --> G[Completion notices and status]
Technical reviewBest possible solution: Land the approved recovery at the existing safeguard and transcript owners once its required behavior and upgrade evidence is complete. Do we have a high-confidence way to reproduce the issue? Current-main source still cancels exhausted audits, and the supplied native-model control demonstrates repeated cancellation without shrinking history; no new reproduction was executed during this read-only review. Is this the best way to solve the issue? The approved bounded fallback fixes the recovery decision at its existing owner, retains generated facts where possible, and records losses without adding a configuration switch. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cfc2e29fe0ad. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +258, Tests +587, Docs +21, Other 0. Total +866 across 44 files. Added test files: 5. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 (26 earlier review cycles; latest 8 shown)
Reviewed October 10, 2026, 9:19 PM ET / October 11, 2026, 01:19 UTC (Revision 27). |
|
Pushed Cover retention-infeasible quality failures. Correct and the more serious of the three: Retain generated split-turn context in the fallback. Also correct. Normal finalization passes both One canonical path. Both terminal cases call a single Update the quality-guard default contract. Three files stated the old contract and all three were wrong after this PR:
Each now describes the bounded degraded artifact, names On the decision needed. My read is option 1 as written, and the docs now carry the tradeoff explicitly rather than leaving it implicit in code. The asymmetry that decides it: a lossy summary loses some fidelity once, while a cancel loses the session permanently, because nothing shrinks and every later turn fails the same preflight. Happy to reverse to option 3 if maintainers would rather keep the abort, but then the retention-infeasible branch still needs covering, since today it strands sessions on a path no config can turn off. Evidence
Mutation-checked in both directions, each restored byte-identical (
The retention test is the one this PR previously left uncovered. It was Honest limit on my side: I could not run the full Claude assisted with the patch and this comment. The submitter owns the conclusions and final review. |
Main moved again under this branch: 50dd07c (openclaw#167640) added the summary-timeout exception to the qualityGuard and safeguard reference lines this branch rewrites, which conflicted in both docs pages. Both keep the degraded-fallback text and take main's exception sentences. 0cf5e29 (openclaw#167757) merged cleanly: the terminal audit branch now keys on reconciliationMessages, and the shared safeguard test harness moved into compaction-safeguard.test-support.ts. The degraded-fallback suite drops its local harness for that shared one.
|
Resolved the conflicts against main and pushed Resolutions, all at main's owners:
Validation on the refreshed head (M4 Pro, Node 26.10.0, pnpm 12.7.0): 13 compaction test files, 261 passed, 0 failed, including the four degraded-fallback cases, both SQLite reload cases and The red checks on Owner decision, still open. The review notes that #164246's timeout exception excludes quality failures, and #167640 says so in the docs. This PR asks for that same trade, a usable session over full retention, for a summary that was generated and then failed the audit, and it also covers manual Also added @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Main's 1d09a03 (openclaw#167916) reworked the safeguard under this branch and conflicted in four files: - compaction-safeguard.ts: main's imports stay, minus the two the tool-failure helpers took with them to their own module. - compaction-safeguard.test-support.ts: main's setSummarizeCompactionHistoryForTest seam stays; the two tool-failure entries are gone with the helpers. - compaction-safeguard.test.ts: main's fail-closed case stays replaced by the degraded-fallback suite. - assertion-safety-baseline.txt: compaction-safeguard.ts 11 -> 9, the same two casts that moved with the tool-failure helpers. Two changes the textual merge could not see: openclaw#167916 dropped effectivePreviousSummary with history pruning, so the degraded fallback builds from previousSummary, and the degraded-fallback suite uses the renamed summarizeCompactionHistory seam.
|
Main conflicted with the branch again, so it is merged once more: On the merged head (M4 Pro, Node 26.10.0): 13 compaction test files, 260 passed, 0 failed (degraded-fallback 4, degraded-reload 2, tool-failures 3, provider-boundary 5, Cost note, corrected 2026-10-10: an earlier version of this comment said the degraded-reload file got slower on this head and put that down to main's SQLite session path. It was load on the shared M4. Interleaved on the same machine, three rounds each, the file took 3.7, 5.1 and 8.3 s of test time on Ran the upgrade from the released v2026.9.9: a session written by the published
Full commands and output are in the body under "Upgrade from the released v2026.9.9". Not run: a rollback to v2026.9.9 after the database is at v25, and a live model. |
Merge main and reconcile CJK summary fitting. Recover the best generated summary after audit exhaustion, preserve committed degradation through status and notices, and clarify best-effort retention. Co-authored-by: Alex Mittell <[email protected]>
Reuse the notice presentation owner for completion and status formatting. Keep warnings in returned replies when no streaming dispatcher exists, preserve abort fencing, and assert retained summary facts instead of a discarded fallback template.
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
Related: #120162
Related: #138416
What Problem This Solves
Fixes long sessions becoming permanently uncompactable when a small model repeatedly fails the safeguard summary audit or required facts cannot fit the summary budget.
User Impact
OpenClaw commits the best available bounded summary and continues the session. It marks the compaction record as degraded, keeps a degradation warning in
/statusfor that history, and always displays a notice—even withnotifyUser: false—that older details, exact identifiers, or pending requests may be missing. The notice suggests resending important context,/new, or a larger model.Maintainer decision (Peter Steinberger, 2026-10-10): accept marked lossy fallback for exhausted quality audits and infeasible retention, including manual compaction. Preservation is best-effort on this path. Complete messages remain in the stored transcript, but facts omitted from active context are not automatically recovered by later summaries. This introduces no configuration switch or database schema migration. Existing installations use the same behavior after updating; older versions ignore the additive quality metadata.
Why This Change Was Made
Cancelling a failed audit leaves the context at the same size, so every later compaction can fail again. The safeguard now keeps the generated candidate with the fewest audit failures, reuses it if a corrective generation fails, and preserves as much request, identifier, and split-turn context as the existing budget permits. An incomplete structured summary is normalized without discarding its generated facts. Caller cancellation remains terminal; missing models, credentials, and an initial generation failure keep their existing error paths.
The transcript writer projects only committed degraded boundaries into session metadata, so stale bookkeeping cannot erase the warning. A fresh session lifecycle clears it. Completion events and recovery receipts carry the same committed details through manual commands, automatic compaction, and notifications. Imported histories conservatively retain the warning if they contain a degraded boundary.
This preserves @amittell's original contribution and commits, merges current main instead of rebasing, and reconciles the merged CJK fitting fix. The two documentation findings are resolved: request retention is best-effort under constrained budgets, and caller abort signals are distinguished from provider-local timeouts.
Evidence
Native Ollama
llama3.2:latest, an 8,192-token context, 48-token model output cap, two quality attempts, and isolated synthetic history through the publicsessions compactCLI and Gateway:5c7004136d9c: both attempts returnedok: false,compacted: false, andCompaction safeguard finalized summary failed quality checks.The log reports missing sections/identifiers; after repeating the command the original ten messages remain with zero compaction records. CLI wall time: 9.14 s, then 5.01 s.{ cancel: true }; the affordable CJK case passes. Cold wrapper wall time: 74.55 s.Candidate
6def8754a71amerges main76a282c7a1c6to include the upstream typecheck and mock-isolation repairs. The compaction owner is unchanged by that second merge.6def8754a71ae44bd09f2982661573b62e1f6ab1: the same failed audit commits a degraded boundary, reduces active history from 296 to 250 estimated tokens / ten to five messages, prints the warning withnotifyUser: false, and showsCompactions: 1 · degraded historythrough real/status. The same native Ollama session then answers “A ripe banana is typically yellow.” Both durable markers remain after continuation. Compaction: 8.40 s CLI / 2.857 s runtime; correct continuation: 5.24 s CLI / 1.386 s runtime. Its first continuation completed but produced tool-shaped text; one explicit no-tools follow-up answered correctly without changing model or configuration. This is a response-quality limitation, not an audit-cancellation loop.pnpm buildpassed on the exact final head (4m 59.8s). It emits the same non-gating UI startup-size warning seen in the main control build; this PR changes no UI bundle source.6def8754a71a. The first review caught an obsolete fallback fixture; it now asserts retained generated facts instead of discarded template text.git diff --checkpassed.Production +477/-219 (net +258); tests/support +1060/-473 (net +587); docs +40/-19. Production growth is needed for committed degradation/status state and complete mandatory-notice delivery across manual, automatic, preflight, and direct-return paths. Existing presentation owners are reused; discarded fallback scaffolding and duplicated exact-artifact fixtures were removed. The stored flag is additive session metadata in the existing SQLite owner; no schema/version/configuration change.
Focused test cost
Commands:
TMPDIR=<isolated-temp> node scripts/run-vitest.mjs <file> --maxWorkers=1.|
compaction-safeguard.degraded-fallback.test.ts| 5 | 39.89 s ||
compaction-safeguard.summary-budget.test.ts| 3 | 10.62 s ||
compaction-safeguard.test.ts| 62 | 21.62 s ||
compaction-safeguard-quality.test.ts| 4 | 2.98 s ||
compaction-safeguard-tool-failures.test.ts| 3 | 2.26 s ||
compact.hooks.test.ts| 82 | 50.36 s ||
agent-session-compaction.degraded-reload.test.ts| 2 | 15.71 s ||
agent-session-compaction.provider-boundary.test.ts| 5 | 13.00 s ||
agent-session-compaction.test.ts| 17 | 17.78 s ||
agent-runner-execution-compaction.test.ts| 9 | 33.04 s ||
agent-runner.misc.runreplyagent.test.ts| 66 | 67.01 s ||
agent-runner.direct-replies.test.ts| 12 | 26.02 s ||
sessions-compact.test.ts| 9 | 3.66 s ||
status-message.test.ts| 26 | 19.43 s |Wall time includes cold compilation/imports. The persisted-reload cases exercise the actual SQLite writer and reopen path; most pure safeguard test bodies take milliseconds. Existing hook and reply suites retain their established coverage and setup. Exact-head CI completed with 62 successful jobs; the three failing jobs took 148 s, 352 s, and 503 s. They fail inherited native-binding tests, as detailed below; these are whole-job wall times, not incremental test cost.
Review and inherited CI
Codex autoreview is scoped-clean at P2 on this exact head. ClawSweeper's exact-head review has Findings: None and acknowledges the approved product decision and both documentation fixes.
Maintainer-approved proof limitation: additional Telegram Test Server, latest-stable upgrade, and data-compatibility runs are deferred; exact-head native Ollama/Gateway behavior and real SQLite reopen/stale-write/reset coverage are supplied above.
Exact-head CI run 38098684939 finished failure, including
openclaw/ci-gate. Build, production/test types, lint, and baseline-ratchet jobs passed. Each failed test family was then reproduced without this PR's changes in a clean detached main checkout at76a282c7a1c6ca958517ce15f13e17371c14be11:test/canonical-descendant.integration.test.ts: the full file in original order fails the same 70 initialization/rollback binding cases; 4 pass. Main control wall time 107.53 s. Errors includeCodex session binding changed during initializationandCodex initialization binding owner changed before rollback.src/config/sessions/session-native-binding.reclamation.test.ts: both CI cases, successorfalseandtrue, reproduce the same 120,000 ms timeout on main. The remainder was stopped after the bounded attribution attempt rather than replaying more timeouts.src/config/sessions/session-agent-purge.test.ts: the targetedsettles the purge's typed native binding when the agent commit is refused: falsecase reproduces the same 120,000 ms timeout on main (1 failed, 7 skipped; 172.56 s wall).These are inherited failures, not a green CI result. No workflow reruns or extra pushes were used to seek green. The lead must use the native inherited-failure exception or wait for the baseline repairs; this worker has not landed the PR.