fix: model context windows

This commit is contained in:
cau1k 2025-12-15 00:17:59 -05:00
parent 7d4cdd09c3
commit 1871962e2e
No known key found for this signature in database
2 changed files with 103 additions and 96 deletions

View file

@ -137,10 +137,17 @@ async function fetchCopilotModels(githubToken: string): Promise<Model<any>[]> {
const input: ("text" | "image")[] = supportsVision ? ["text", "image"] : ["text"];
const limits = (caps as Record<string, unknown>).limits;
// Copilot exposes both:
// - max_context_window_tokens: the model's full context window capability
// - max_prompt_tokens: the maximum prompt tokens Copilot will accept
// For pi's purposes (compaction, prompt sizing), the prompt limit is the effective context window.
const contextWindow =
limits && typeof limits === "object" && typeof (limits as any).max_context_window_tokens === "number"
? (limits as any).max_context_window_tokens
: 128000;
limits && typeof limits === "object" && typeof (limits as any).max_prompt_tokens === "number"
? (limits as any).max_prompt_tokens
: limits && typeof limits === "object" && typeof (limits as any).max_context_window_tokens === "number"
? (limits as any).max_context_window_tokens
: 128000;
const maxTokens =
limits && typeof limits === "object" && typeof (limits as any).max_output_tokens === "number"
? (limits as any).max_output_tokens