Repository navigation
fix: compaction keeps stale decisions after corrections - #167757
Conversation
Co-authored-by: jacobtomlinson <[email protected]>
Worked on by: - @jacobtomlinson Co-authored-by: jacobtomlinson <[email protected]> OpenClaw-Publication: 2603ad3e-1e48-4d17-80f5-1f6277b42d53
|
🦞👀 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. |
|
Independent review completed for head Canonical AutoReview, P0–P3: scoped-clean; no actionable findings. The review covered the full six-file change and surrounding owners: correction input routing, previous-summary re-distillation, preserved/split-turn context, budgets, quality checks, cancellation, persistence, and fixture extraction. The published tree is byte-identical to the reviewed implementation commit This is completed independent AI source review, not a human GitHub approval. The reviewer did not independently execute tests; the live replay limitations remain documented in the PR body. Hosted CI and ClawSweeper’s separate review are not represented as complete or green. |
|
Codex review: needs maintainer review before merge. What this changesCompaction, which condenses conversation history, includes retained corrections in the main summary request so current decisions and task status replace stale facts. Example: The user corrects the launch date and verification returns a failed result.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR repairs a source-confirmed compaction gap that remains on current main. No blocking correctness or security defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherOpenClaw compaction turns older conversation into a persisted summary that later agent turns consume. The safeguard prepares model input, retains recent excerpts, and applies existing summary budgets and quality checks before persistence. flowchart LR
A[Prepared conversation] --> C[Compaction safeguard]
B[Previous summary] --> C
C --> D[Main summary with corrections]
C --> E[Retained recent and split-turn context]
D --> F[Budget and quality checks]
E --> F
F --> G[Persisted session summary]
Technical reviewBest possible solution: Reconcile corrected facts at the existing safeguard summary producer while retaining bounded historical excerpts. Do we have a high-confidence way to reproduce the issue? Yes, by source: a previous summary plus an all-preserved correction or split-turn correction can skip the main summarizer on current main. The supplied SDK before/after replay corroborates this path; this read-only review did not rerun it. Is this the best way to solve the issue? Yes. Routing the already-prepared correction context to the existing summary producer addresses why stronger instructions alone failed, without adding a competing state owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0907600c0e76. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +3, Tests +112, Docs +2. Total +117 across 6 files. Added test files: 1. 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 HistoryReviewed October 9, 2026, 6:13 AM ET / 10:13 UTC (Revision 3). |
|
Merged via squash.
|
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.
) Reconcile corrected facts and completed verification results in the main compaction summary instead of copying stale decisions alongside newer turn context. Preserve historical excerpts, prepared-window boundaries, chunking, budgets, cancellation, and persistence ownership. Validated with 85 focused tests and real model-backed SDK compaction replays with SQLite reopen checks. Gateway/CLI and original Nvidia/judge execution remain outside that proof. Original discussion: https://team.openclaw.ai/chat/roboclaw/dashboard/71e26bee-aa04-4ca2-ae2d-9c8a3c55879e Implementation and verification: https://team.openclaw.ai/chat/roboclaw/dashboard/4c5954fa-378d-4e55-afc7-79b718c8cbde Co-authored-by: jacobtomlinson <[email protected]>
What Problem This Solves
Fixes: compaction can leave superseded dates and pending verification status in its main Decisions section when later corrections are retained as recent-turn or split-turn context.
User Impact
The compacted handoff updates current decisions and task status instead of presenting contradictory old and corrected facts. Unaffected facts and explicitly historical verbatim excerpts remain available. No configuration change or migration is required.
Tradeoff: the reproduced split-turn case now makes two summary requests (main summary plus prefix) rather than one prefix-only request; larger preserved windows can require additional chunks.
Why This Change Was Made
Recent-turn preservation could remove every main-summary target. OpenClaw then copied the stale previous summary through a deterministic fallback, while a separate prefix request merely appended the correction. Strengthening the main prompt alone did not fix a prompt that was never invoked.
The main summary now reconciles the prepared, post-pruning history together with preserved turns and split-turn progress. Instructions require corrections and observed results to update the main sections, distinguish completed failed checks from pending work, and label superseded history. Existing window, pruning, pairing, budget, quality-check, cancellation, and persistence boundaries remain intact. Shared test fixtures were extracted so the regressions do not grow already-oversized files.
Evidence
AgentSession.compact()usingopenai/gpt-6-astra; disposed/reopened SQLite and inspected the persisted summary. Assessed the saved state against the supplied YAML criteria, not just an assistant reply.git diff --checkpass.Limits: this is an available-OpenAI-model SDK replay, not the original Nvidia-model/external-judge run or a Gateway/CLI end-to-end test. It does not establish broad cross-model or long-history reliability. Raw request traces, fixture databases, and private attachments are not included in this PR. Full build/full runtime suite were not run; hosted CI status remains separate from the local proof.
Focused validation commands and cost
pnpm test src/agents/agent-hooks/compaction-safeguard.test.ts src/agents/agent-hooks/compaction-safeguard-corrections.test.ts src/agents/agent-hooks/compaction-safeguard-quality.test.ts src/agents/compaction.summary-format.test.ts --maxWorkers=1 pnpm tsgo:coreThe four-file test command took 38.93 seconds including compiled-worker preparation. Standalone
pnpm test <file> --maxWorkers=1wall times: correction regressions 40.83 seconds (cold compiled-worker preparation dominates; three cases run in milliseconds), existing safeguard suite 13.09 seconds. These exercise the real safeguard hook input routing; there are no new sleeps or per-case Gateway boots. Test typechecks used the repository changed-path graph selector. CI seconds are not yet available.Worked on by
Work sessions
View the OpenClaw team session