Skip to content

GitHub Copilot plugin ignores user-configured model limit overrides #21564

Closed as not planned

Description

@giorgosdi

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:

  1. The user sets limit.context: 1000000 in config
  2. 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)
  3. The prev model (carrying user config) is passed to build() but only used for family, name, options, variants, capabilities, etc. — not for limit
  4. Compaction checks limit.input (= max_prompt_tokens, ~128K from API), not limit.context
  5. 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

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 8, 2026
  2. github-actions commented on Apr 8, 2026

    @github-actions
    Contributor

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

  3. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  4. github-actions commented on Jul 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions