Repository navigation
feat: add contextManagement.compactionTriggerAt to lower the auto-compaction trigger - #493
Open
yujiachen-y wants to merge 1 commit into
Open
yujiachen-y wants to merge 1 commit into
yujiachen-y wants to merge 1 commit into
Conversation
…paction trigger Users can set an upper bound for the automatic context compaction trigger in config.yaml, as a ratio of the context window in (0, 1] or as an absolute token count above 1. The effective trigger is min(setting, built-in trigger), so the setting can only start compaction earlier; there is no lower bound by design. Invalid numbers such as 1.5 are logged once and ignored, and an unreadable config falls back to the built-in trigger. Refs #488
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
Adds
contextManagement.compactionTriggerAttoconfig.yamlso users can make automatic context compaction start earlier, for example to keep requests smaller. Refs #488.(0, 1]is a ratio of the current model's context window; an integer above 1 is an absolute token count.min(setting, built-in trigger). The setting can only start compaction earlier, never later, so it cannot push requests past the Provider input limit. Comparable to Codex'smodel_auto_compact_token_limit, which is clamped to 90% of the window.1.5,0, negatives, non-finite) are logged once ascontext_compaction_trigger_config_ignoredand treated as unset. Non-number YAML values are dropped by the config parser. A failing config read falls back to the built-in trigger instead of throwing.Out of scope, intentionally: disabling automatic compaction, per-model settings (the ratio already scales with each model's window), and the tool-result watermark (
toolResultCompaction). Showing the effective trigger in/contextneeds the trigger threaded through the context-usage snapshot and is left for a follow-up.Implementation:
@mavis/context-manager:resolveCompactionTokenBudgettakes an optionalcompactionTriggerAt; validation lives inisValidCompactionTriggerSetting/resolveConfiguredCompactionTrigger. OnlyautomaticTriggerAtchanges;providerInputLimitand its other consumers (manual compaction, reminder admission) are untouched.local-runtime-v2:AutomaticContextCompactorreads the setting per call through an injected getter wired inproduction-composition.ts.@mavis/config: parses the new key; it only keeps numbers because@mavis/configcannot depend on@mavis/context-manager.docs/tui-capabilities.md.Validation
pnpm verify(full profile) on2a8d121, darwin: 15 gates passed;test:windowsandtest:release-packagenot applicable locally.provider-budget.test.ts(ratio, absolute, above built-in, invalid values),automatic-context-compactor.test.ts(probe starts earlier only from a valid setting; invalid or throwing getter keeps the built-in trigger),packages/config/test/context-management-config.test.ts(parsing). The compactor test fails on the baseline compactor and passes with this change.config.yaml, 200K window / 32K output):0.5→ 100,000;120000→ 120,000;0.95,1.5and"0.5"→ built-in 159,600.Publication and contribution checks
release/public-source.json; new tests are declared intest/vitest-suites.jsonwhere applicable.Maintainer handoff
Publication scope or license changes (if any): none; one new test file.
Shared-source port: pending.
Need help on this PR? Tag
@codesmith-botwith what you need.