Python
fix DeepSeek V4 context windows
Amar Teja Kommineni9ae0f36bf2eb
diff --git a/coworker/providers/matrix.py b/coworker/providers/matrix.pyindex 6dcee64b..0c15d4a6 100644--- a/coworker/providers/matrix.py+++ b/coworker/providers/matrix.py@@ -187,11 +187,13 @@ MATRIX: dict[str, ModelEntry] = {# GLM-5.2 shipped with a 1M window (docs.z.ai, read 2026-09-08: "1M" context,# 128K output); the 128,000 here was stale and compacted it at 102,400 (OPE-170)."zai:glm-5.2": ModelEntry("GLM-5.2 · Z AI", _AGENTIC, 1_000_000),+ # DeepSeek's native API exposes the full 1M context for both V4 variants+ # (verified against the official model table 2026-08-10)."deepseek:deepseek-v4-flash": ModelEntry(- "DeepSeek V4 Flash · DeepSeek", _AGENTIC, 128_000+ "DeepSeek V4 Flash · DeepSeek", _AGENTIC, 1_000_000),"deepseek:deepseek-v4-pro": ModelEntry(- "DeepSeek V4 Pro · DeepSeek", _AGENTIC, 128_000+ "DeepSeek V4 Pro · DeepSeek", _AGENTIC, 1_000_000),"kimi:kimi-k2.6": ModelEntry("Kimi K2.6 · Moonshot", _AGENTIC, 256_000),"minimax:MiniMax-M2.5": ModelEntry("MiniMax M2.5 · MiniMax"),@@ -223,6 +225,7 @@ MATRIX: dict[str, ModelEntry] = {"Kimi K2.6 · via Together", _AGENTIC, 262_144),"together:deepseek-ai/DeepSeek-V4-Pro": ModelEntry(+ # Together's serverless deployment exposes 512K, not the model-level 1M."DeepSeek V4 Pro · via Together", _AGENTIC, 512_000),"together:meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8": ModelEntry(@@ -236,7 +239,7 @@ MATRIX: dict[str, ModelEntry] = {"Kimi K2.6 · via Fireworks", _AGENTIC, 256_000),"fireworks:accounts/fireworks/models/deepseek-v4-pro": ModelEntry(- "DeepSeek V4 Pro · via Fireworks", _AGENTIC, 128_000+ "DeepSeek V4 Pro · via Fireworks", _AGENTIC, 1_048_576),"fireworks:accounts/fireworks/models/llama4-maverick-instruct-basic": ModelEntry("Llama 4 Maverick · via Fireworks", _AGENTIC, 1_000_000@@ -261,7 +264,7 @@ MATRIX: dict[str, ModelEntry] = {"Kimi K2.6 · via OpenRouter", _AGENTIC, 256_000),"openrouter:deepseek/deepseek-v4-pro": ModelEntry(- "DeepSeek V4 Pro · via OpenRouter", _AGENTIC, 128_000+ "DeepSeek V4 Pro · via OpenRouter", _AGENTIC, 1_048_576),"openrouter:meta-llama/llama-4-maverick": ModelEntry("Llama 4 Maverick · via OpenRouter", _AGENTIC, 1_000_000diff --git a/tests/test_token_usage.py b/tests/test_token_usage.pyindex 663bf7f1..9951b523 100644--- a/tests/test_token_usage.py+++ b/tests/test_token_usage.py@@ -360,3 +360,16 @@ def test_model_context_windows_covers_verified_entries_only():assert windows["anthropic:claude-fable-5"] == 1_000_000assert "together:thinkingmachines/Inkling" not in windows # unverified stays absentassert all(isinstance(v, int) and v > 0 for v in windows.values())+++def test_deepseek_v4_context_windows_match_provider_limits():+ windows = model_context_windows()+ expected = {+ "deepseek:deepseek-v4-flash": 1_000_000,+ "deepseek:deepseek-v4-pro": 1_000_000,+ "together:deepseek-ai/DeepSeek-V4-Pro": 512_000,+ "fireworks:accounts/fireworks/models/deepseek-v4-pro": 1_048_576,+ "openrouter:deepseek/deepseek-v4-pro": 1_048_576,+ }++ assert {model: windows[model] for model in expected} == expected