Repository navigation
feat(providers): per-model context windows and a global auto-compact percentage - #184
Merged
Merged
Conversation
…percentage Each model row in the provider form has its own context window field, filled from model discovery when the provider reports one. Context window lookup goes through one source per provider (listed fields, Ollama, LM Studio, DeepSeek, Qwen). Auto-compact now triggers at a percentage of the context window, 90% by default and set in General, replacing the per-provider fallback window. Closes #105
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.
Closes #105
What changed
Context window per model
modelContextWindowskeep pre-filling as before. Storage (modelContextWindows) and resolution (getContextWindowForModel) are unchanged.contextWindowper model. Lookup lives insrc/server/upstream/contextWindows/, one source per provider, run in order after the model list:listed: readsmax_input_tokens,context_lengthorcontext_windowfrom the model list itself. Covers OpenRouter, Anthropic and Kimi with no extra request.ollama:POST /api/showper model (concurrency 4), readingmodel_info["<arch>.context_length"]. Used for the Ollama preset or when the list hasowned_by: library.lmstudio:GET /api/v1/models,max_context_lengthbykey. LM Studio preset only.deepseek:GET https://api.deepseek.com/models,context_window.qwen: DashScope nativeGET /api/v1/models(paged),model_info.max_input_tokens.index.ts.Auto-compact
/contextuses the same threshold function instead of its own copy of the formula.autoCompactPercentin user settings and read by the CLI.CLAUDE_CODE_AUTO_COMPACT_WINDOWinsettings.jsonis cleared on activation.CLAUDE_AUTOCOMPACT_PCT_OVERRIDEis removed.Other
glass-panel-focus).How it was tested
bun test: 1410 pass, 0 fail.desktop:bun run lintclean,bun run test -- --run1292 pass, 4 skipped. Touched server and CLI test files also pass with--randomize.fetch(field precedence, range, failures, concurrency, paging, no extra requests for other providers), the 90% and configured thresholds against a temporary config dir, stale window cleanup on activation, the General setting and store, the form rows and fill-only-empty behavior, and the composer focus ring (fails without the change).Not verified
/anthropic/v1/models; if that endpoint does not exist, discovery fails before the DeepSeek source runs.