Skip to content

feat(compaction): use model-managed CLM by default - #232

Open
MelodyVAR wants to merge 2 commits into
mainfrom
feat/clm-default-compaction
Open

MelodyVAR wants to merge 2 commits into
mainfrom
feat/clm-default-compaction

Conversation

@MelodyVAR

@MelodyVAR MelodyVAR commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Long sessions currently go straight to native summary compaction when they cross the context threshold. This makes clm-v1 the default: the model first makes a bounded edit of eligible old observations in a working view, while the canonical session history stays intact.

Behavior

  • Keep the existing native trigger (contextWindow - reserveTokens). CLM maintenance runs before a prompt or after a complete tool turn; a settled answer defers routine maintenance until another request needs the context.
  • Validate edits atomically against their session, branch, source digest, and working revision. Preserve user messages, control metadata, reasoning, and tool linkage; archive and persist accepted revisions before using them. Resume, native compaction, and task-state snapshots retain the working context and remaining work.
  • Reuse a matching actor request prefix, system prompt, and tool schemas for JSON maintenance. Cold or changed contexts use the isolated edit-tool transport. Maintenance never dispatches project tools. Physical cache hits still depend on provider behavior; edited prefixes invalidate subsequent cached tokens.
  • Bound maintenance to two requests, 90 seconds, and 8,192 output tokens by default, with a three-turn cooldown and a minimum saving of both 1,024 tokens and 5%. No useful edit, rejection, or failure falls back to native compaction. Cancellation and user steering take priority; real overflow keeps native recovery.
  • Account for accepted, rejected, and late maintenance usage in session totals, and expose progress/cancellation in the CLI.

Existing explicit off and lightweight-v1 settings remain effective. --context-projection off selects native compaction. Disabling automatic compaction also disables implicit CLM; explicitly selecting clm-v1 still permits manual edits. /compact remains available for a native summary, and /clm-compact requests an explicit working-context edit.

This PR includes the CLM implementation and its tested cache/fallback behavior. The independent completion verifier is outside its scope.

Validation

  • Offline workspace build passed.
  • pnpm run check passed, including formatting, type checking, repository boundaries, and browser smoke checks.
  • ./test.sh passed with its isolated test environment. Coding-agent: 4,344 passed / 55 skipped; CLI: 666 passed; agent-core: 524 passed / 1 skipped; providers: 435 passed / 6 skipped. The remaining workspace and script tests also passed.
  • Default-mode integration tests cover first-request setup, automatic edits, reduced working-context estimates, final-answer deferral, explicit disabling, cache-prefix reuse, cancellation, stale edits, and native fallback. Native-only regressions explicitly select off and retain their original assertions.
  • Built CLI help reports clm-v1 as the default. A real CLI regression also verifies that explicit --context-projection off survives resource loading and leaves the config file unchanged.

Keep canonical history while validating bounded edits to a persisted working
view. Reuse compatible actor prefixes for maintenance and retain native
compaction for failures, overflow recovery, and explicit requests.

Honor explicit projection settings and disabled auto-compaction, defer unused
maintenance after final answers, and cover default and native behavior in the
session, CLI, persistence, and usage regressions.
Apply the CLI mode after resource discovery reloads settings, so an explicit
off selection takes precedence over the default CLM mode. Exercise the real
CLI startup path with a local streaming endpoint and keep the config unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant