Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
copilot_chat: Return true context window size (#47557)
Anil Pai13ad175c8de2
diff --git a/crates/copilot_chat/src/copilot_chat.rs b/crates/copilot_chat/src/copilot_chat.rsindex 513b813517c..86247bce793 100644--- a/crates/copilot_chat/src/copilot_chat.rs+++ b/crates/copilot_chat/src/copilot_chat.rs@@ -223,7 +223,7 @@ impl Model {}pub fn max_token_count(&self) -> u64 {- self.capabilities.limits.max_prompt_tokens+ self.capabilities.limits.max_context_window_tokens as u64}pub fn supports_tools(&self) -> bool {@@ -1038,6 +1038,61 @@ mod tests {assert_eq!(schema.data[0].vendor, ModelVendor::Unknown);}+ #[test]+ fn test_max_token_count_returns_context_window_not_prompt_tokens() {+ let json = r#"{+ "data": [+ {+ "billing": { "is_premium": true, "multiplier": 1 },+ "capabilities": {+ "family": "claude-sonnet-4",+ "limits": { "max_context_window_tokens": 200000, "max_output_tokens": 16384, "max_prompt_tokens": 90000 },+ "object": "model_capabilities",+ "supports": { "streaming": true, "tool_calls": true },+ "type": "chat"+ },+ "id": "claude-sonnet-4",+ "is_chat_default": false,+ "is_chat_fallback": false,+ "model_picker_enabled": true,+ "name": "Claude Sonnet 4",+ "object": "model",+ "preview": false,+ "vendor": "Anthropic",+ "version": "claude-sonnet-4"+ },+ {+ "billing": { "is_premium": false, "multiplier": 1 },+ "capabilities": {+ "family": "gpt-4o",+ "limits": { "max_context_window_tokens": 128000, "max_output_tokens": 16384, "max_prompt_tokens": 110000 },+ "object": "model_capabilities",+ "supports": { "streaming": true, "tool_calls": true },+ "type": "chat"+ },+ "id": "gpt-4o",+ "is_chat_default": true,+ "is_chat_fallback": false,+ "model_picker_enabled": true,+ "name": "GPT-4o",+ "object": "model",+ "preview": false,+ "vendor": "Azure OpenAI",+ "version": "gpt-4o"+ }+ ],+ "object": "list"+ }"#;++ let schema: ModelSchema = serde_json::from_str(json).unwrap();++ // max_token_count() should return context window (200000), not prompt tokens (90000)+ assert_eq!(schema.data[0].max_token_count(), 200000);++ // GPT-4o should return 128000 (context window), not 110000 (prompt tokens)+ assert_eq!(schema.data[1].max_token_count(), 128000);+ }+#[test]fn test_models_with_pending_policy_deserialize() {// This test verifies that models with policy states other than "enabled"