@@ -323,6 +323,13 @@ func LookupStaticModelInfo(modelID string) *ModelInfo {
323323 return nil
324324}
325325
326+ // defaultCopilotClaudeContextLength is the conservative prompt token limit for
327+ // Claude models accessed via the GitHub Copilot API. Individual accounts are
328+ // capped at 128K; business accounts at 168K. When the dynamic /models API fetch
329+ // succeeds, the real per-account limit overrides this value. This constant is
330+ // only used as a safe fallback.
331+ const defaultCopilotClaudeContextLength = 128000
332+
326333// GetGitHubCopilotModels returns the available models for GitHub Copilot.
327334// These models are available through the GitHub Copilot API at api.githubcopilot.com.
328335func GetGitHubCopilotModels () []* ModelInfo {
@@ -534,7 +541,7 @@ func GetGitHubCopilotModels() []*ModelInfo {
534541 Type : "github-copilot" ,
535542 DisplayName : "Claude Haiku 4.5" ,
536543 Description : "Anthropic Claude Haiku 4.5 via GitHub Copilot" ,
537- ContextLength : 200000 ,
544+ ContextLength : defaultCopilotClaudeContextLength ,
538545 MaxCompletionTokens : 64000 ,
539546 SupportedEndpoints : []string {"/chat/completions" },
540547 },
@@ -546,7 +553,7 @@ func GetGitHubCopilotModels() []*ModelInfo {
546553 Type : "github-copilot" ,
547554 DisplayName : "Claude Opus 4.1" ,
548555 Description : "Anthropic Claude Opus 4.1 via GitHub Copilot" ,
549- ContextLength : 200000 ,
556+ ContextLength : defaultCopilotClaudeContextLength ,
550557 MaxCompletionTokens : 32000 ,
551558 SupportedEndpoints : []string {"/chat/completions" },
552559 },
@@ -558,7 +565,7 @@ func GetGitHubCopilotModels() []*ModelInfo {
558565 Type : "github-copilot" ,
559566 DisplayName : "Claude Opus 4.5" ,
560567 Description : "Anthropic Claude Opus 4.5 via GitHub Copilot" ,
561- ContextLength : 200000 ,
568+ ContextLength : defaultCopilotClaudeContextLength ,
562569 MaxCompletionTokens : 64000 ,
563570 SupportedEndpoints : []string {"/chat/completions" },
564571 Thinking : & ThinkingSupport {Levels : []string {"low" , "medium" , "high" }},
@@ -571,7 +578,7 @@ func GetGitHubCopilotModels() []*ModelInfo {
571578 Type : "github-copilot" ,
572579 DisplayName : "Claude Opus 4.6" ,
573580 Description : "Anthropic Claude Opus 4.6 via GitHub Copilot" ,
574- ContextLength : 200000 ,
581+ ContextLength : defaultCopilotClaudeContextLength ,
575582 MaxCompletionTokens : 64000 ,
576583 SupportedEndpoints : []string {"/chat/completions" },
577584 Thinking : & ThinkingSupport {Levels : []string {"low" , "medium" , "high" }},
@@ -584,7 +591,7 @@ func GetGitHubCopilotModels() []*ModelInfo {
584591 Type : "github-copilot" ,
585592 DisplayName : "Claude Sonnet 4" ,
586593 Description : "Anthropic Claude Sonnet 4 via GitHub Copilot" ,
587- ContextLength : 200000 ,
594+ ContextLength : defaultCopilotClaudeContextLength ,
588595 MaxCompletionTokens : 64000 ,
589596 SupportedEndpoints : []string {"/chat/completions" },
590597 Thinking : & ThinkingSupport {Levels : []string {"low" , "medium" , "high" }},
@@ -597,7 +604,7 @@ func GetGitHubCopilotModels() []*ModelInfo {
597604 Type : "github-copilot" ,
598605 DisplayName : "Claude Sonnet 4.5" ,
599606 Description : "Anthropic Claude Sonnet 4.5 via GitHub Copilot" ,
600- ContextLength : 200000 ,
607+ ContextLength : defaultCopilotClaudeContextLength ,
601608 MaxCompletionTokens : 64000 ,
602609 SupportedEndpoints : []string {"/chat/completions" },
603610 Thinking : & ThinkingSupport {Levels : []string {"low" , "medium" , "high" }},
@@ -610,7 +617,7 @@ func GetGitHubCopilotModels() []*ModelInfo {
610617 Type : "github-copilot" ,
611618 DisplayName : "Claude Sonnet 4.6" ,
612619 Description : "Anthropic Claude Sonnet 4.6 via GitHub Copilot" ,
613- ContextLength : 200000 ,
620+ ContextLength : defaultCopilotClaudeContextLength ,
614621 MaxCompletionTokens : 64000 ,
615622 SupportedEndpoints : []string {"/chat/completions" },
616623 Thinking : & ThinkingSupport {Levels : []string {"low" , "medium" , "high" }},
0 commit comments