Skip to content

plugin.copilot: strict schema decode crashes with "Missing key" when a Copilot model lacks max_context_window_tokens #30909

Closed as not planned

Description

@emaxlele

Description

The plugin.copilot service fails to fetch the Copilot models list and logs an ERROR in every session because the API response contains at least one model (consistently at array index 15) whose capabilities.limits object does not include max_context_window_tokens. The Effect schema decoder treats this as a hard error rather than handling the missing field gracefully.

Environment

  • OpenCode Desktop: tested on 1.15.13 and 1.16.0
  • OS: Windows 11 x64
  • Provider: GitHub Copilot (via github-copilot/* models)

Log evidence

Repeated in every session, multiple times per minute:

ERROR service=plugin.copilot error=Missing key
  at ["data"][15]["capabilities"]["limits"]["max_context_window_tokens"]
  failed to fetch copilot models

The error is always at the same path ["data"][15], pointing to a specific model in the GitHub Copilot models API response that does not expose max_context_window_tokens.

Root cause hypothesis

The OpenCode Copilot plugin decodes the GitHub Copilot models API response (GET https://api.githubcopilot.com/models or equivalent) using an Effect Schema that requires capabilities.limits.max_context_window_tokens to be present on every model. GitHub appears to have added (or always had) at least one model entry that omits this field.

The fix should be to mark the field as optional in the schema, e.g.:

// current (strict — breaks on missing field)
max_context_window_tokens: Schema.Number

// proposed (tolerant)
max_context_window_tokens: Schema.optional(Schema.Number)

Impact

  • The entire Copilot models list fails to load every time the field is missing, meaning no Copilot models are available until the next retry.
  • The error floods the server log on every session.
  • Present since at least v1.15.13; still present in v1.16.0.

Steps to reproduce

  1. Configure OpenCode with a GitHub Copilot provider.
  2. Open any session.
  3. Inspect server logs — observe repeated Missing key at ["data"][15]["capabilities"]["limits"]["max_context_window_tokens"] failed to fetch copilot models.

Expected behaviour

Models that lack max_context_window_tokens should be decoded successfully (field treated as optional / defaulted to undefined or a sensible fallback), and the rest of the models list should load normally.

OpenCode version

1.15.13 / 1.16.0

Operating System

Windows 11 x64

Terminal

N/A (Desktop app)

Activity

  1. github-actions commented on Aug 5, 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