[PR #12273] fix: correct Copilot GPT-5.2 token limits #14144

Open
opened 2026-02-16 18:18:57 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12273

State: open
Merged: No


What does this PR do?

Fixes #11086

GitHub Copilot’s gpt-5.2 / gpt-5.2-codex models are currently ingested from models.dev with incorrect limit values, which makes OpenCode think the context window is much smaller than it really is. Since OpenCode uses model.limit.context / model.limit.output for both the context meter and auto-compaction overflow checks, this shows an inflated % used and triggers compaction far too early (e.g. ~90–100k tokens). (Refs #11086, duplicate #12247.)

This PR fixes that by overriding the token limits during models.dev -> Provider.Model conversion, but only for providerID starting with github-copilot and only for model IDs gpt-5.2 and gpt-5.2-codex. The override sets:

  • context: 400000
  • input: 272000
  • output: 128000

This works because every downstream consumer (UI usage, overflow/compaction thresholds, max output calculations) reads from Provider.Model.limit. Correcting the limits at ingestion time fixes behavior without changing session logic, and the scope is intentionally narrow to avoid impacting other Copilot models.

How did you verify your code works?

  • Added a regression test that asserts the override is applied for both github-copilot/gpt-5.2 and github-copilot/gpt-5.2-codex.
  • Ran cd packages/opencode && bun test test/provider/provider.test.ts.
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12273 **State:** open **Merged:** No --- ### What does this PR do? Fixes #11086 GitHub Copilot’s `gpt-5.2` / `gpt-5.2-codex` models are currently ingested from models.dev with incorrect `limit` values, which makes OpenCode think the context window is much smaller than it really is. Since OpenCode uses `model.limit.context` / `model.limit.output` for both the context meter and auto-compaction overflow checks, this shows an inflated % used and triggers compaction far too early (e.g. ~90–100k tokens). (Refs #11086, duplicate #12247.) This PR fixes that by overriding the token limits during models.dev -> `Provider.Model` conversion, but only for `providerID` starting with `github-copilot` and only for model IDs `gpt-5.2` and `gpt-5.2-codex`. The override sets: - `context: 400000` - `input: 272000` - `output: 128000` This works because every downstream consumer (UI usage, overflow/compaction thresholds, max output calculations) reads from `Provider.Model.limit`. Correcting the limits at ingestion time fixes behavior without changing session logic, and the scope is intentionally narrow to avoid impacting other Copilot models. ### How did you verify your code works? - Added a regression test that asserts the override is applied for both `github-copilot/gpt-5.2` and `github-copilot/gpt-5.2-codex`. - Ran `cd packages/opencode && bun test test/provider/provider.test.ts`.
yindo added the pull-request label 2026-02-16 18:18:57 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14144