fix(ai): update GitHub Copilot extended context windows to 1M

Updates GitHub Copilot built-in model metadata so models with GitHub's extended 1M capability use contextWindow 1000000 in Pi, preventing early compaction and under-budgeting for Claude Opus 4.7/4.8 and GPT-5.3 Codex/5.4/5.5.

Verified against raw docs markdown extended-capabilities table and live /models reports.

closes #6439
This commit is contained in:
Mario Zechner
2026-07-09 10:39:27 +02:00
parent cb222bf99d
commit 9eedaf8cf3
3 changed files with 25 additions and 7 deletions
+1
View File
@@ -15,6 +15,7 @@
- Fixed OpenAI Completions and Responses providers to send `(no tool output)` instead of `(see attached image)` when a tool result has empty text and no image content, preventing the model from hallucinating image attachments.
- Fixed OpenAI Responses and Azure OpenAI Responses requests to avoid sending `max_output_tokens` values below the provider minimum ([#6265](https://github.com/earendil-works/pi/issues/6265)).
- Fixed retry classification for Cloudflare 524 timeout responses ([#6239](https://github.com/earendil-works/pi/issues/6239)).
- Fixed GitHub Copilot extended context window models (Claude Opus 4.7/4.8, Claude Opus 4.6, Claude Sonnet 4.6/5, Claude Fable 5, GPT-5.3 Codex, GPT-5.4, GPT-5.5) to use `contextWindow: 1000000`, preventing premature compaction and under-budgeting ([#6439](https://github.com/earendil-works/pi/issues/6439)).
### Added
+19 -2
View File
@@ -212,6 +212,20 @@ const OPENCODE_OPENAI_COMPLETIONS_LONG_CACHE_RETENTION_UNSUPPORTED_MODELS = new
"opencode-go:kimi-k2.6",
]);
// GitHub's "Models with extended capabilities" table lists these Copilot models as supporting
// the extended 1 million token context window.
const GITHUB_COPILOT_EXTENDED_CONTEXT_MODELS = new Set([
"claude-fable-5",
"claude-opus-4.6",
"claude-opus-4.7",
"claude-opus-4.8",
"claude-sonnet-4.6",
"claude-sonnet-5",
"gpt-5.3-codex",
"gpt-5.4",
"gpt-5.5",
]);
// Checked manually against the authenticated GitHub Copilot /models endpoint on 2026-06-15.
// Keep this to narrow corrections over models.dev metadata instead of snapshotting Copilot's catalog.
const GITHUB_COPILOT_THINKING_LEVEL_OVERRIDES = {
@@ -1606,11 +1620,14 @@ async function generateModels() {
// Temporary overrides until upstream model metadata is corrected.
for (const candidate of allModels) {
if (candidate.provider === "github-copilot" && GITHUB_COPILOT_EXTENDED_CONTEXT_MODELS.has(candidate.id)) {
candidate.contextWindow = 1000000;
}
if (
(candidate.provider === "anthropic" ||
candidate.provider === "opencode" ||
candidate.provider === "opencode-go" ||
candidate.provider === "github-copilot") &&
candidate.provider === "opencode-go") &&
(candidate.id === "claude-opus-4-6" ||
candidate.id === "claude-sonnet-4-6" ||
candidate.id === "claude-opus-4.6" ||
@@ -97,7 +97,7 @@ export const GITHUB_COPILOT_MODELS = {
cacheRead: 0.5,
cacheWrite: 6.25,
},
contextWindow: 200000,
contextWindow: 1000000,
maxTokens: 32000,
} satisfies Model<"anthropic-messages">,
"claude-opus-4.8": {
@@ -117,7 +117,7 @@ export const GITHUB_COPILOT_MODELS = {
cacheRead: 0.5,
cacheWrite: 6.25,
},
contextWindow: 200000,
contextWindow: 1000000,
maxTokens: 64000,
} satisfies Model<"anthropic-messages">,
"claude-sonnet-4": {
@@ -365,7 +365,7 @@ export const GITHUB_COPILOT_MODELS = {
cacheRead: 0.175,
cacheWrite: 0,
},
contextWindow: 400000,
contextWindow: 1000000,
maxTokens: 128000,
} satisfies Model<"openai-responses">,
"gpt-5.4": {
@@ -384,7 +384,7 @@ export const GITHUB_COPILOT_MODELS = {
cacheRead: 0.25,
cacheWrite: 0,
},
contextWindow: 400000,
contextWindow: 1000000,
maxTokens: 128000,
} satisfies Model<"openai-responses">,
"gpt-5.4-mini": {
@@ -441,7 +441,7 @@ export const GITHUB_COPILOT_MODELS = {
cacheRead: 0.5,
cacheWrite: 0,
},
contextWindow: 400000,
contextWindow: 1000000,
maxTokens: 128000,
} satisfies Model<"openai-responses">,
"kimi-k2.7-code": {