Skip to content

Commit d4c3621

Browse files
committed
feat(copilot/gemini): add Gemini 3 Pro reasoning and dynamic model fetching
- Add full Copilot model registry (all GPT, Claude, Gemini, Grok models) - Implement dynamic model fetching from Copilot API with caching - Add Gemini reasoning capture and injection for tool calls - Add reasoning_opaque and reasoning_text handling for Gemini 3 models - Evict model and reasoning caches on auth removal - Add 30-second retry delay for 429 quota errors Credit: Reverse engineering insights adapted from github.com/aadishv/vscre
1 parent 11a07b6 commit d4c3621

File tree

5 files changed

+685
-10
lines changed

5 files changed

+685
-10
lines changed

internal/registry/copilot_models.go

Lines changed: 206 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,217 @@ func GenerateCopilotAliases(models []*ModelInfo) []*ModelInfo {
2222
return result
2323
}
2424

25-
// GetCopilotModels returns the Copilot models (raptor-mini and oswe-vscode-prime).
25+
// GetCopilotModels returns a conservative set of fallback models for GitHub Copilot.
26+
// These are used when dynamic model fetching from the Copilot API fails.
2627
func GetCopilotModels() []*ModelInfo {
2728
now := time.Now().Unix()
2829
defaultParams := []string{"temperature", "top_p", "max_tokens", "stream", "tools"}
2930

3031
baseModels := []*ModelInfo{
32+
{
33+
ID: "gpt-4.1",
34+
Object: "model",
35+
Created: now,
36+
OwnedBy: "copilot",
37+
Type: "copilot",
38+
DisplayName: "GPT-4.1",
39+
Description: "Azure OpenAI model via GitHub Copilot",
40+
ContextLength: 128000,
41+
MaxCompletionTokens: 16384,
42+
SupportedParameters: defaultParams,
43+
},
44+
{
45+
ID: "gpt-4o",
46+
Object: "model",
47+
Created: now,
48+
OwnedBy: "copilot",
49+
Type: "copilot",
50+
DisplayName: "GPT-4o",
51+
Description: "Azure OpenAI model via GitHub Copilot",
52+
ContextLength: 128000,
53+
MaxCompletionTokens: 4096,
54+
SupportedParameters: defaultParams,
55+
},
56+
{
57+
ID: "gpt-41-copilot",
58+
Object: "model",
59+
Created: now,
60+
OwnedBy: "copilot",
61+
Type: "copilot",
62+
DisplayName: "GPT-4.1 Copilot",
63+
Description: "Azure OpenAI fine-tuned model via GitHub Copilot",
64+
ContextLength: 128000,
65+
MaxCompletionTokens: 16384,
66+
SupportedParameters: defaultParams,
67+
},
68+
{
69+
ID: "gpt-5",
70+
Object: "model",
71+
Created: now,
72+
OwnedBy: "copilot",
73+
Type: "copilot",
74+
DisplayName: "GPT-5",
75+
Description: "Azure OpenAI model via GitHub Copilot",
76+
ContextLength: 400000,
77+
MaxCompletionTokens: 128000,
78+
SupportedParameters: defaultParams,
79+
},
80+
{
81+
ID: "gpt-5-mini",
82+
Object: "model",
83+
Created: now,
84+
OwnedBy: "copilot",
85+
Type: "copilot",
86+
DisplayName: "GPT-5 mini",
87+
Description: "Azure OpenAI model via GitHub Copilot",
88+
ContextLength: 264000,
89+
MaxCompletionTokens: 64000,
90+
SupportedParameters: defaultParams,
91+
},
92+
{
93+
ID: "gpt-5-codex",
94+
Object: "model",
95+
Created: now,
96+
OwnedBy: "copilot",
97+
Type: "copilot",
98+
DisplayName: "GPT-5-Codex (Preview)",
99+
Description: "OpenAI model via GitHub Copilot (Preview)",
100+
ContextLength: 400000,
101+
MaxCompletionTokens: 128000,
102+
SupportedParameters: defaultParams,
103+
},
104+
{
105+
ID: "gpt-5.1",
106+
Object: "model",
107+
Created: now,
108+
OwnedBy: "copilot",
109+
Type: "copilot",
110+
DisplayName: "GPT-5.1",
111+
Description: "OpenAI model via GitHub Copilot (Preview)",
112+
ContextLength: 264000,
113+
MaxCompletionTokens: 64000,
114+
SupportedParameters: defaultParams,
115+
},
116+
{
117+
ID: "gpt-5.1-codex",
118+
Object: "model",
119+
Created: now,
120+
OwnedBy: "copilot",
121+
Type: "copilot",
122+
DisplayName: "GPT-5.1-Codex",
123+
Description: "OpenAI model via GitHub Copilot (Preview)",
124+
ContextLength: 400000,
125+
MaxCompletionTokens: 128000,
126+
SupportedParameters: defaultParams,
127+
},
128+
{
129+
ID: "gpt-5.1-codex-mini",
130+
Object: "model",
131+
Created: now,
132+
OwnedBy: "copilot",
133+
Type: "copilot",
134+
DisplayName: "GPT-5.1-Codex-Mini",
135+
Description: "OpenAI model via GitHub Copilot (Preview)",
136+
ContextLength: 400000,
137+
MaxCompletionTokens: 128000,
138+
SupportedParameters: defaultParams,
139+
},
140+
{
141+
ID: "claude-haiku-4.5",
142+
Object: "model",
143+
Created: now,
144+
OwnedBy: "copilot",
145+
Type: "copilot",
146+
DisplayName: "Claude Haiku 4.5",
147+
Description: "Anthropic model via GitHub Copilot",
148+
ContextLength: 144000,
149+
MaxCompletionTokens: 16000,
150+
SupportedParameters: defaultParams,
151+
},
152+
{
153+
ID: "claude-opus-4.1",
154+
Object: "model",
155+
Created: now,
156+
OwnedBy: "copilot",
157+
Type: "copilot",
158+
DisplayName: "Claude Opus 4.1",
159+
Description: "Anthropic model via GitHub Copilot",
160+
ContextLength: 200000,
161+
MaxCompletionTokens: 16000,
162+
SupportedParameters: defaultParams,
163+
},
164+
{
165+
ID: "claude-sonnet-4",
166+
Object: "model",
167+
Created: now,
168+
OwnedBy: "copilot",
169+
Type: "copilot",
170+
DisplayName: "Claude Sonnet 4",
171+
Description: "Anthropic model via GitHub Copilot",
172+
ContextLength: 216000,
173+
MaxCompletionTokens: 16000,
174+
SupportedParameters: defaultParams,
175+
},
176+
{
177+
ID: "claude-sonnet-4.5",
178+
Object: "model",
179+
Created: now,
180+
OwnedBy: "copilot",
181+
Type: "copilot",
182+
DisplayName: "Claude Sonnet 4.5",
183+
Description: "Anthropic model via GitHub Copilot",
184+
ContextLength: 144000,
185+
MaxCompletionTokens: 16000,
186+
SupportedParameters: defaultParams,
187+
},
188+
{
189+
ID: "claude-opus-4.5",
190+
Object: "model",
191+
Created: now,
192+
OwnedBy: "copilot",
193+
Type: "copilot",
194+
DisplayName: "Claude Opus 4.5 (Preview)",
195+
Description: "Anthropic model via GitHub Copilot (Preview)",
196+
ContextLength: 144000,
197+
MaxCompletionTokens: 16000,
198+
SupportedParameters: defaultParams,
199+
},
200+
{
201+
ID: "gemini-2.5-pro",
202+
Object: "model",
203+
Created: now,
204+
OwnedBy: "copilot",
205+
Type: "copilot",
206+
DisplayName: "Gemini 2.5 Pro",
207+
Description: "Google model via GitHub Copilot",
208+
ContextLength: 128000,
209+
MaxCompletionTokens: 64000,
210+
SupportedParameters: defaultParams,
211+
},
212+
{
213+
ID: "gemini-3-pro-preview",
214+
Object: "model",
215+
Created: now,
216+
OwnedBy: "copilot",
217+
Type: "copilot",
218+
DisplayName: "Gemini 3 Pro (Preview)",
219+
Description: "Google model via GitHub Copilot (Preview)",
220+
ContextLength: 128000,
221+
MaxCompletionTokens: 64000,
222+
SupportedParameters: defaultParams,
223+
},
224+
{
225+
ID: "grok-code-fast-1",
226+
Object: "model",
227+
Created: now,
228+
OwnedBy: "copilot",
229+
Type: "copilot",
230+
DisplayName: "Grok Code Fast 1",
231+
Description: "xAI model via GitHub Copilot",
232+
ContextLength: 128000,
233+
MaxCompletionTokens: 64000,
234+
SupportedParameters: defaultParams,
235+
},
31236
{
32237
ID: "oswe-vscode-prime",
33238
Object: "model",

0 commit comments

Comments
 (0)