Repository navigation
feat(compaction): make compaction summary char cap configurable via maxSummaryChars - #196207
Conversation
…axSummaryChars Adds agents.defaults.compaction.maxSummaryChars (default 16000, range 1000-200000) so long-context deployments can raise the persisted compaction summary budget instead of truncating two-thirds of compactions. The preserved-turn/split-turn budgets derive from the resolved cap and the foreground token-budget check remains the safety net against overflow. Closes openclaw#194408
|
🦞👀 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. |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
Codex review: needs real behavior proof before merge. What this changesThis PR adds global and per-agent summary character limits while preserving the 16,000-character default and foreground-window fitting. Example: A research agent sets maxSummaryChars to 64000 and generates a 52,000-character summary with sufficient foreground context space.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep open: current main still has the fixed summary ceiling, and this maintainer-adopted feature remains useful; a previously reported runner-fixture defect still breaks exact-head CI. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherAgent configuration flows into session compaction settings; core and safeguard producers summarize conversation history, fit the artifact to the foreground budget, and persist it for subsequent requests. flowchart LR
A[Global and agent configuration] --> B[Prepared session settings]
C[Conversation history] --> D[Core or safeguard summarization]
B --> D
E[Foreground request budget] --> F[Summary fitting]
D --> F
F --> G[Persisted summary and replay]
Technical reviewBest possible solution: Keep the existing compaction owners and default, with one resolved override bounded by foreground token pressure. Do we have a high-confidence way to reproduce the issue? Current-main source still fixes summary fitting and persistence at 16,000 characters without this override; no target code was executed during this review. Is this the best way to solve the issue? The existing settings, fitting, safeguard, and persistence owners provide a coherent implementation; helper extraction preserves existing exports, and the added tests cover distinct configuration and window boundaries. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1ebc46e1a52f. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +176, Tests +207, Docs +26, Generated 0, Other +236. Total +645 across 32 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 (1 earlier review cycle)
Reviewed November 9, 2026, 10:08 PM ET / November 10, 2026, 03:08 UTC (Revision 2). |
Adapt the reviewed summary-cap change to the canonical release compaction request-budget, provenance, and streamed-hydration owners. Preserve the 16000-character default and existing 600-character preserved tool excerpts. Carry global and per-agent limits through normal, manual, CLI, fork and Gateway RPC paths with foreground-window fitting before persistence. Keep manual preflight and its zero-retention fallback within the same request constraints when a raised cap needs a foreground budget. (cherry picked from commit c7152f3) (adapted from commit df8e4d101ced84ee5f0678b3570113d5939f9240) Co-authored-by: Aniruddha Adak <[email protected]> Co-authored-by: Dallin Romney <[email protected]> Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
Closes #194408
Related: #195028, #194719; consolidates the now-closed #196347
Contributor and consolidation
Original configurable-cap proposal and commit by @aniruddhaadak80. The follow-up
a444bd49a9b4ea743f9fe593460dc9d865510357directly descends from the contributor's original6fda397edd35d9b72b191438aac4c0b792bc5d88; their commit and authorship are preserved.The reviewed compaction-only patch from #196347 is now applied without unrelated working-branch history: 32 files, +807/−162. Its diff against the original contributor base is byte-identical to
bd63497962a1..efe7b6dc099c, and every affected base file is identical between those bases. The full repository tree is not identical because unrelated later changes were excluded. Existing focused proof is reused for this unchanged patch; fresh CI is not claimed as passed.An earlier consolidation mistakenly merged unrelated newer-base commits. That maintainer merge was replaced using an exact-head lease, without rewriting the contributor's original commit. Overlapping cap/settings implementations remain consolidated into one owner.
What Problem This Solves
Long-context agents still lose generated summary content at the fixed 16,000-character ceiling, even after the summary-priority fix in #195028.
User Impact
Operators can set
agents.defaults.compaction.maxSummaryCharsor override it throughagents.entries.<id>.compaction.maxSummaryChars(1,000–200,000). Omission preserves today's 16,000-character default. Larger summaries increase replay cost; this is a ceiling, not a target or a guarantee that previously lost facts return. No automatic default scaling, state-format change, or provider-native compaction change.Why This Change Was Made
Carry one resolved setting through the existing compaction settings, safeguard sections, token fitting, and persistence owner. Derived section budgets retain the merged summary-priority behavior. Raised limits remain bounded by the foreground request window, including manual RPC compaction with a separately configured larger summarizer and high fixed instruction/tool pressure.
The core cap/fitting helpers are extracted without changing their public exports; existing split-turn formatting and quality-retry helpers move into the existing quality module to satisfy file-size constraints. No new config/runtime manager or cache is introduced.
Evidence
8595de2bc73e6799461a52a85ccd1e895bae12ccpassed archive inventory and import-graph integrity; SHA-256766b30bfed23b2403335b0a05fc01abeddb52983bec7a210e3d7a477820d6252. The publication commitefe7b6dc099c6f9af098c2ed78dec54ead4a22behas an identical source tree. This is runtime/install proof, not release qualification.git diff --checkpass. Fresh independent review and local AutoReview found no remaining P0–P2 issues after repairing both manual-budget findings. A second AutoReview was clean after the helper relocation; affected safeguard/quality tests passed (41 cases), and the final unchanged retry-helper move passed 34/34 safeguard cases plus lint and the line-cap ratchet. Local ClawSweeper could not start because its Git preparation timed out; hosted ClawSweeper acknowledged the PR.published-upgrade-survivor/sqlite-volume, stable[email protected]→ the exact candidate tarball, with 8 synthetic sessions, 5 events per session, and 2 scheduled jobs. The updater returnedok, candidate Doctor/config/plugin/recovery/Gateway checks passed, installed-package identity matched, and the migration assertions verified session records and transcript events. The suite then failed withmain volume legacy session-store archive changed; later assertions, including the remaining scheduled-job proof, did not run. This is not a passing upgrade suite.The 207-line regression allocation covers the new 184-line session boundary suite, 21 schema lines, and 2 Gateway budget-handoff assertions; existing core/safeguard tests are reused.
Upgrade failure investigation
Run
20261110T002138Zcompleted the update in 450 seconds and passed installed-package identity verification. It failed atscripts/e2e/lib/upgrade-survivor/sqlite-volume.mjs:540, which requires exactly one retained legacysessions.jsonarchive.The captured migration manifest records the main store as
classification: imported,reason: verified-index-import, thendisposal.state: disposedat2026-11-10T00:30:24.667Z. The ops store, which includes an intentionally missing-transcript fixture, isclassification: protected,reason: incomplete-index-import, and remains retained. The existing Doctor retirement owner (src/commands/doctor-session-sqlite-retirement.ts:643–665) removes verified recovery originals and records this disposal. Both that owner and the failing fixture are unchanged from the PR base; the archive-presence assertion conflicts with that cleanup behavior. No assertion was weakened, no failure was suppressed, and the suite was not rerun merely for green. Remaining uncertainty: assertions after the archive check were not reached; this run is not full upgrade-survivor qualification.Reproduce the focused boundary proof
pnpm test src/agents/sessions/agent-session-summary-limit.test.ts src/agents/sessions/agent-session-small-context-compaction.test.ts --maxWorkers=1 pnpm openclaw qa suite --provider-mode mock-openai \ --scenario compaction-summary-limit \ --scenario compaction-summary-priority \ --scenario compaction-summary-window --concurrency 1The Gateway cases exercise the actual RPC, summarization pipeline, database persistence, and replay; only model responses are synthetic. The two summary-limit/default cases passed together, and the corrected window fixture passed in its targeted rerun.
CI fixture correction (
2da313ad1ab5)Addresses the latest ClawSweeper P2 finding and the 19 failures in CI run 42731031733. The shared runner fixture now creates a fresh real
SettingsManager.inMemory()both initially and after reset, replacing the incompletegetGlobalSettings-only mock. No production behavior, assertions, or timeouts changed. The follow-up is one file, +5/−6; the full PR is now 33 files, +812/−168.Validation: all 94 tests in the three CI-failing suites pass (149.07 seconds including runner preparation). All 63 tests in the five other shared-fixture consumer suites pass (261.90 seconds including preparation; durable delegate/queued-successor cases exercise persistence and cancellation). Total: 157/157 tests in eight suites. Targeted lint, agents-other test typechecking, formatting, and diff checks pass. Local AutoReview of the fixture delta found no actionable P0–P2 issues; the final formatter change only wraps one expression. Existing production proof and the documented live-model/upgrade gaps are unchanged. Fresh hosted CI is pending, not claimed green.