Repository navigation
GitHub Copilot plugin ignores user-configured model limit overrides #21564
Description
Problem
User-configured limit overrides for GitHub Copilot models are silently discarded. The Copilot plugin always overwrites limit.context, limit.input, and limit.output with API-reported values, even when the user explicitly sets them in opencode.json.
This causes compaction to trigger much earlier than expected — around 11-13% of the configured context window — because:
- The user sets
limit.context: 1000000in config - The Copilot plugin fetches model info from the API and rebuilds limits entirely from the response (
max_context_window_tokens,max_prompt_tokens,max_output_tokens) - The
prevmodel (carrying user config) is passed tobuild()but only used forfamily,name,options,variants,capabilities, etc. — not forlimit - Compaction checks
limit.input(=max_prompt_tokens, ~128K from API), notlimit.context - The UI percentage is calculated against
limit.context, so compaction at ~128K tokens shows as ~12.8% of 1M
Config example
{
"provider": {
"github-copilot": {
"models": {
"claude-opus-4.6": {
"limit": {
"context": 1000000,
"output": 64000
}
}
}
}
},
"compaction": {
"auto": true,
"prune": true,
"reserved": 2000
}
}Despite this config, compaction triggers at ~128K tokens (the API-reported max_prompt_tokens), not at ~1M.
Root cause
In packages/opencode/src/plugin/github-copilot/models.ts, the build() function:
function build(key: string, remote: Item, url: string, prev?: Model): Model {
return {
// ...
limit: {
context: remote.capabilities.limits.max_context_window_tokens,
input: remote.capabilities.limits.max_prompt_tokens,
output: remote.capabilities.limits.max_output_tokens,
},
// prev is used for family, name, options, variants, etc. but NOT limit
}
}Other fields from prev (user config) are preserved with the prev?.field ?? remote.field pattern, but limit always comes from the API response.
Expected behavior
User-configured limit overrides should be respected, consistent with how other model properties (options, variants, capabilities) from user config take precedence. Something like:
limit: {
context: prev?.limit?.context ?? remote.capabilities.limits.max_context_window_tokens,
input: prev?.limit?.input ?? remote.capabilities.limits.max_prompt_tokens,
output: prev?.limit?.output ?? remote.capabilities.limits.max_output_tokens,
},Additional context
The compaction trigger in overflow.ts prioritizes limit.input over limit.context:
const usable = input.model.limit.input
? input.model.limit.input - reserved
: context - maxOutputTokens(model)So even if limit.context were respected, users would also need to set limit.input to actually delay compaction. This should be documented, or limit.context should influence the compaction calculation when limit.input is not explicitly set by the user.
Activity
github-actions commentedon Apr 8, 2026
This issue might be a duplicate of existing issues. Please check:
Please review those issues and consider whether this is a duplicate or a related but distinct problem (e.g. user-configured overrides being ignored vs. API-reported limits being wrong in the first place).
github-actions commentedon Jul 3, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.