Skip to content

feat(compaction): allow larger summaries without overflowing context - #196347

Closed
RomneyDa wants to merge 2 commits into
mainfrom
openclaw/openclaw-issue-fix-status
Closed

RomneyDa wants to merge 2 commits into
mainfrom
openclaw/openclaw-issue-fix-status

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Closes #194408
Related: #195028, #194719, #196207

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.maxSummaryChars or override it through agents.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

  • Before: new config case rejected the key; runtime global/per-agent cases produced 16,000 instead of 48,000/64,000 characters. Those runtime assertions ran and failed, but the base test wrapper subsequently exited 2 because it detected a concurrent QA fixture edit during cleanup; this is not claimed as a clean baseline invocation.
  • After: 21/21 summary-limit and existing small-context cases pass, covering persisted/replayed defaults and overrides, automatic/manual token fitting, and high fixed pressure. Config/settings/request-budget/safeguard suites, core compaction suites, and 21/21 Gateway compaction tests pass. Prompt-prefix stability: 14/14 pass.
  • Real isolated Gateway, synthetic providers: configurable-limit scenario persists more than 48k and at most 64k characters, retains the final decision, and resumes; the existing 16k summary-priority sibling passes; manual RPC fits a CJK-heavy summary to a 64k foreground window while using a separate 200k summarizer. All three scenarios pass. The original 32k fixture correctly rejected its ~49k fixed instructions/tools before summarization; the fixture now uses a viable foreground window.
  • Package: the full build completed before the mechanical helper relocation (with nonfatal UI bundle-budget warnings). A fresh runtime-only package from 8595de2bc73e6799461a52a85ccd1e895bae12cc passed archive inventory and import-graph integrity; SHA-256 766b30bfed23b2403335b0a05fc01abeddb52983bec7a210e3d7a477820d6252. The publication commit efe7b6dc099c6f9af098c2ed78dec54ead4a22be has an identical source tree. This is runtime/install proof, not release qualification.
  • Checks: targeted core/session typechecking, changed-TypeScript lint, formatting, and git diff --check pass. 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.
  • Upgrade result — partial, suite failed: isolated 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 returned ok, 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 with main volume legacy session-store archive changed; later assertions, including the remaining scheduled-job proof, did not run. This is not a passing upgrade suite.
  • Live-model limitation: the isolated QA profile had no route-compatible provider authentication, so live summarization/resumption was not exercised. The deterministic Gateway checks above use synthetic provider responses, not live inference.

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 20261110T002138Z completed the update in 450 seconds and passed installed-package identity verification. It failed at scripts/e2e/lib/upgrade-survivor/sqlite-volume.mjs:540, which requires exactly one retained legacy sessions.json archive.

The captured migration manifest records the main store as classification: imported, reason: verified-index-import, then disposal.state: disposed at 2026-11-10T00:30:24.667Z. The ops store, which includes an intentionally missing-transcript fixture, is classification: 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 1

The 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.

@clawsweeper

clawsweeper Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling extensions: qa-lab size: L labels Nov 10, 2026
@RomneyDa
RomneyDa marked this pull request as ready for review November 10, 2026 00:33
@RomneyDa RomneyDa closed this Nov 10, 2026
RomneyDa added a commit to aniruddhaadak80/openclaw that referenced this pull request Nov 10, 2026
Carry the reviewed compaction-only delta from openclaw#196347 onto the original contributor commit. Preserve contributor ancestry without merging unrelated working-branch history. The patch is byte-identical to bd63497..efe7b6d; all affected base files are also identical.
RomneyDa added a commit that referenced this pull request Nov 10, 2026
…axSummaryChars (#196207)

* feat(compaction): make compaction summary char cap configurable via maxSummaryChars

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 #194408

* fix(compaction): add per-agent limits and foreground-window proof

Carry the reviewed compaction-only delta from #196347 onto the original contributor commit. Preserve contributor ancestry without merging unrelated working-branch history. The patch is byte-identical to bd63497..efe7b6d; all affected base files are also identical.

* test(compaction): use real settings in shared runner fixture

---------

Co-authored-by: Aniruddha Adak <[email protected]>
Co-authored-by: Dallin Romney <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 10, 2026
…axSummaryChars (openclaw#196207)

* feat(compaction): make compaction summary char cap configurable via maxSummaryChars

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

* fix(compaction): add per-agent limits and foreground-window proof

Carry the reviewed compaction-only delta from openclaw#196347 onto the original contributor commit. Preserve contributor ancestry without merging unrelated working-branch history. The patch is byte-identical to 331af21..efe7b6d; all affected base files are also identical.

* test(compaction): use real settings in shared runner fixture

---------

Co-authored-by: Aniruddha Adak <[email protected]>
Co-authored-by: Dallin Romney <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: qa-lab gateway Gateway runtime size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Compaction: make MAX_COMPACTION_SUMMARY_CHARS (16,000) configurable; two-thirds of production compactions hit it

1 participant