Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

update context counter live as tokens stream (#262)

kt4e30b5e44b87
diff --git a/packages/ai/src/models.generated.ts b/packages/ai/src/models.generated.ts
index 78dc2edf37..488efa2dd1 100644
--- a/packages/ai/src/models.generated.ts
+++ b/packages/ai/src/models.generated.ts
@@ -4489,25 +4489,6 @@ export const MODELS = {
contextWindow: 400000,
maxTokens: 128000,
} satisfies Model<"openai-responses">,
- "raptor-mini": {
- id: "raptor-mini",
- name: "Raptor mini",
- api: "openai-completions",
- provider: "github-copilot",
- baseUrl: "https://api.individual.githubcopilot.com",
- headers: {"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},
- compat: {"supportsStore":false,"supportsDeveloperRole":false,"supportsReasoningEffort":false},
- reasoning: true,
- input: ["text", "image"],
- cost: {
- input: 0.25,
- output: 2,
- cacheRead: 0.025,
- cacheWrite: 0,
- },
- contextWindow: 400000,
- maxTokens: 128000,
- } satisfies Model<"openai-completions">,
},
"google": {
"gemini-2.0-flash": {
@@ -4791,42 +4772,6 @@ export const MODELS = {
contextWindow: 262144,
maxTokens: 32768,
} satisfies Model<"google-generative-ai">,
- "gemma-4-E2B-it": {
- id: "gemma-4-E2B-it",
- name: "Gemma 4 E2B IT",
- api: "google-generative-ai",
- provider: "google",
- baseUrl: "https://generativelanguage.googleapis.com/v1beta",
- reasoning: true,
- thinkingLevelMap: {"off":null,"minimal":"MINIMAL","low":null,"medium":null,"high":"HIGH"},
- input: ["text", "image"],
- cost: {
- input: 0,
- output: 0,
- cacheRead: 0,
- cacheWrite: 0,
- },
- contextWindow: 131072,
- maxTokens: 8192,
- } satisfies Model<"google-generative-ai">,
- "gemma-4-E4B-it": {
- id: "gemma-4-E4B-it",
- name: "Gemma 4 E4B IT",
- api: "google-generative-ai",
- provider: "google",
- baseUrl: "https://generativelanguage.googleapis.com/v1beta",
- reasoning: true,
- thinkingLevelMap: {"off":null,"minimal":"MINIMAL","low":null,"medium":null,"high":"HIGH"},
- input: ["text", "image"],
- cost: {
- input: 0,
- output: 0,
- cacheRead: 0,
- cacheWrite: 0,
- },
- contextWindow: 131072,
- maxTokens: 8192,
- } satisfies Model<"google-generative-ai">,
},
"google-vertex": {
"gemini-1.5-flash": {
@@ -5178,6 +5123,24 @@ export const MODELS = {
} satisfies Model<"openai-completions">,
},
"huggingface": {
+ "MiniMaxAI/MiniMax-M2": {
+ id: "MiniMaxAI/MiniMax-M2",
+ name: "MiniMax-M2",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 0.3,
+ output: 1.2,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 204800,
+ maxTokens: 128000,
+ } satisfies Model<"openai-completions">,
"MiniMaxAI/MiniMax-M2.1": {
id: "MiniMaxAI/MiniMax-M2.1",
name: "MiniMax-M2.1",
@@ -5232,6 +5195,42 @@ export const MODELS = {
contextWindow: 204800,
maxTokens: 131072,
} satisfies Model<"openai-completions">,
+ "MiniMaxAI/MiniMax-M3": {
+ id: "MiniMaxAI/MiniMax-M3",
+ name: "MiniMax-M3",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 0.3,
+ output: 1.2,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 524288,
+ maxTokens: 128000,
+ } satisfies Model<"openai-completions">,
+ "Qwen/Qwen3-235B-A22B": {
+ id: "Qwen/Qwen3-235B-A22B",
+ name: "Qwen3 235B-A22B",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 0.2,
+ output: 0.8,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 40960,
+ maxTokens: 16384,
+ } satisfies Model<"openai-completions">,
"Qwen/Qwen3-235B-A22B-Thinking-2507": {
id: "Qwen/Qwen3-235B-A22B-Thinking-2507",
name: "Qwen3-235B-A22B-Thinking-2507",
@@ -5250,6 +5249,42 @@ export const MODELS = {
contextWindow: 262144,
maxTokens: 131072,
} satisfies Model<"openai-completions">,
+ "Qwen/Qwen3-32B": {
+ id: "Qwen/Qwen3-32B",
+ name: "Qwen3 32B",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 0.29,
+ output: 0.59,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 131072,
+ maxTokens: 16384,
+ } satisfies Model<"openai-completions">,
+ "Qwen/Qwen3-Coder-30B-A3B-Instruct": {
+ id: "Qwen/Qwen3-Coder-30B-A3B-Instruct",
+ name: "Qwen3-Coder 30B-A3B Instruct",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: false,
+ input: ["text"],
+ cost: {
+ input: 0.07,
+ output: 0.26,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 262144,
+ maxTokens: 65536,
+ } satisfies Model<"openai-completions">,
"Qwen/Qwen3-Coder-480B-A35B-Instruct": {
id: "Qwen/Qwen3-Coder-480B-A35B-Instruct",
name: "Qwen3-Coder-480B-A35B-Instruct",
@@ -5322,6 +5357,60 @@ export const MODELS = {
contextWindow: 262144,
maxTokens: 131072,
} satisfies Model<"openai-completions">,
+ "Qwen/Qwen3.5-122B-A10B": {
+ id: "Qwen/Qwen3.5-122B-A10B",
+ name: "Qwen3.5 122B-A10B",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 0.4,
+ output: 3.2,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 262144,
+ maxTokens: 65536,
+ } satisfies Model<"openai-completions">,
+ "Qwen/Qwen3.5-27B": {
+ id: "Qwen/Qwen3.5-27B",
+ name: "Qwen3.5 27B",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 0.3,
+ output: 2.4,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 262144,
+ maxTokens: 65536,
+ } satisfies Model<"openai-completions">,
+ "Qwen/Qwen3.5-35B-A3B": {
+ id: "Qwen/Qwen3.5-35B-A3B",
+ name: "Qwen3.5 35B-A3B",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 0.25,
+ output: 2,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 262144,
+ maxTokens: 65536,
+ } satisfies Model<"openai-completions">,
"Qwen/Qwen3.5-397B-A17B": {
id: "Qwen/Qwen3.5-397B-A17B",
name: "Qwen3.5-397B-A17B",
@@ -5340,6 +5429,60 @@ export const MODELS = {
contextWindow: 262144,
maxTokens: 32768,
} satisfies Model<"openai-completions">,
+ "Qwen/Qwen3.5-9B": {
+ id: "Qwen/Qwen3.5-9B",
+ name: "Qwen3.5 9B",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 0.17,
+ output: 0.25,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 262144,
+ maxTokens: 65536,
+ } satisfies Model<"openai-completions">,
+ "Qwen/Qwen3.6-27B": {
+ id: "Qwen/Qwen3.6-27B",
+ name: "Qwen3.6 27B",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 0.47,
+ output: 3.19,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 262144,
+ maxTokens: 65536,
+ } satisfies Model<"openai-completions">,
+ "Qwen/Qwen3.6-35B-A3B": {
+ id: "Qwen/Qwen3.6-35B-A3B",
+ name: "Qwen3.6 35B-A3B",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 0.15,
+ output: 0.95,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 262144,
+ maxTokens: 65536,
+ } satisfies Model<"openai-completions">,
"XiaomiMiMo/MiMo-V2-Flash": {
id: "XiaomiMiMo/MiMo-V2-Flash",
name: "MiMo-V2-Flash",
@@ -5358,6 +5501,42 @@ export const MODELS = {
contextWindow: 262144,
maxTokens: 4096,
} satisfies Model<"openai-completions">,
+ "XiaomiMiMo/MiMo-V2.5-Pro": {
+ id: "XiaomiMiMo/MiMo-V2.5-Pro",
+ name: "MiMo-V2.5-Pro",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 1,
+ output: 3,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 1048576,
+ maxTokens: 131072,
+ } satisfies Model<"openai-completions">,
+ "deepseek-ai/DeepSeek-R1": {
+ id: "deepseek-ai/DeepSeek-R1",
+ name: "DeepSeek-R1",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 0.7,
+ output: 2.5,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 64000,
+ maxTokens: 32768,
+ } satisfies Model<"openai-completions">,
"deepseek-ai/DeepSeek-R1-0528": {
id: "deepseek-ai/DeepSeek-R1-0528",
name: "DeepSeek-R1-0528",
@@ -5366,51 +5545,123 @@ export const MODELS = {
baseUrl: "https://router.huggingface.co/v1",
compat: {"supportsDeveloperRole":false},
reasoning: true,
- input: ["text"],
+ input: ["text"],
+ cost: {
+ input: 3,
+ output: 5,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 163840,
+ maxTokens: 163840,
+ } satisfies Model<"openai-completions">,
+ "deepseek-ai/DeepSeek-V3.2": {
+ id: "deepseek-ai/DeepSeek-V3.2",
+ name: "DeepSeek-V3.2",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 0.28,
+ output: 0.4,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 163840,
+ maxTokens: 65536,
+ } satisfies Model<"openai-completions">,
+ "deepseek-ai/DeepSeek-V4-Flash": {
+ id: "deepseek-ai/DeepSeek-V4-Flash",
+ name: "DeepSeek V4 Flash",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 0.14,
+ output: 0.28,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 1048576,
+ maxTokens: 384000,
+ } satisfies Model<"openai-completions">,
+ "deepseek-ai/DeepSeek-V4-Pro": {
+ id: "deepseek-ai/DeepSeek-V4-Pro",
+ name: "DeepSeek V4 Pro",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 0.435,
+ output: 0.87,
+ cacheRead: 0.003625,
+ cacheWrite: 0,
+ },
+ contextWindow: 1048576,
+ maxTokens: 393216,
+ } satisfies Model<"openai-completions">,
+ "google/gemma-4-26B-A4B-it": {
+ id: "google/gemma-4-26B-A4B-it",
+ name: "Gemma 4 26B A4B IT",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text", "image"],
cost: {
- input: 3,
- output: 5,
+ input: 0.13,
+ output: 0.4,
cacheRead: 0,
cacheWrite: 0,
},
- contextWindow: 163840,
- maxTokens: 163840,
+ contextWindow: 262144,
+ maxTokens: 32768,
} satisfies Model<"openai-completions">,
- "deepseek-ai/DeepSeek-V3.2": {
- id: "deepseek-ai/DeepSeek-V3.2",
- name: "DeepSeek-V3.2",
+ "google/gemma-4-31B-it": {
+ id: "google/gemma-4-31B-it",
+ name: "Gemma 4 31B IT",
api: "openai-completions",
provider: "huggingface",
baseUrl: "https://router.huggingface.co/v1",
compat: {"supportsDeveloperRole":false},
reasoning: true,
- input: ["text"],
+ input: ["text", "image"],
cost: {
- input: 0.28,
+ input: 0.14,
output: 0.4,
cacheRead: 0,
cacheWrite: 0,
},
- contextWindow: 163840,
- maxTokens: 65536,
+ contextWindow: 262144,
+ maxTokens: 32768,
} satisfies Model<"openai-completions">,
- "deepseek-ai/DeepSeek-V4-Pro": {
- id: "deepseek-ai/DeepSeek-V4-Pro",
- name: "DeepSeek V4 Pro",
+ "meta-llama/Llama-3.3-70B-Instruct": {
+ id: "meta-llama/Llama-3.3-70B-Instruct",
+ name: "Llama-3.3-70B-Instruct",
api: "openai-completions",
provider: "huggingface",
baseUrl: "https://router.huggingface.co/v1",
compat: {"supportsDeveloperRole":false},
- reasoning: true,
+ reasoning: false,
input: ["text"],
cost: {
- input: 0.435,
- output: 0.87,
- cacheRead: 0.003625,
+ input: 0.59,
+ output: 0.79,
+ cacheRead: 0,
cacheWrite: 0,
},
- contextWindow: 1048576,
- maxTokens: 393216,
+ contextWindow: 131072,
+ maxTokens: 4096,
} satisfies Model<"openai-completions">,
"moonshotai/Kimi-K2-Instruct": {
id: "moonshotai/Kimi-K2-Instruct",
@@ -5502,6 +5753,132 @@ export const MODELS = {
contextWindow: 262144,
maxTokens: 262144,
} satisfies Model<"openai-completions">,
+ "moonshotai/Kimi-K2.7-Code": {
+ id: "moonshotai/Kimi-K2.7-Code",
+ name: "Kimi K2.7 Code",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 0.95,
+ output: 4,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 262144,
+ maxTokens: 262144,
+ } satisfies Model<"openai-completions">,
+ "stepfun-ai/Step-3.5-Flash": {
+ id: "stepfun-ai/Step-3.5-Flash",
+ name: "Step 3.5 Flash",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 0.1,
+ output: 0.3,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 262144,
+ maxTokens: 256000,
+ } satisfies Model<"openai-completions">,
+ "stepfun-ai/Step-3.7-Flash": {
+ id: "stepfun-ai/Step-3.7-Flash",
+ name: "Step 3.7 Flash",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 0.2,
+ output: 1.15,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 262144,
+ maxTokens: 256000,
+ } satisfies Model<"openai-completions">,
+ "zai-org/GLM-4.5": {
+ id: "zai-org/GLM-4.5",
+ name: "GLM-4.5",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 0.6,
+ output: 2.2,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 131072,
+ maxTokens: 98304,
+ } satisfies Model<"openai-completions">,
+ "zai-org/GLM-4.5-Air": {
+ id: "zai-org/GLM-4.5-Air",
+ name: "GLM-4.5-Air",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 0.13,
+ output: 0.85,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 131072,
+ maxTokens: 98304,
+ } satisfies Model<"openai-completions">,
+ "zai-org/GLM-4.5V": {
+ id: "zai-org/GLM-4.5V",
+ name: "GLM-4.5V",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 0.6,
+ output: 1.8,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 65536,
+ maxTokens: 16384,
+ } satisfies Model<"openai-completions">,
+ "zai-org/GLM-4.6": {
+ id: "zai-org/GLM-4.6",
+ name: "GLM-4.6",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 0.55,
+ output: 2.2,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 204800,
+ maxTokens: 131072,
+ } satisfies Model<"openai-completions">,
"zai-org/GLM-4.7": {
id: "zai-org/GLM-4.7",
name: "GLM-4.7",
@@ -5574,6 +5951,24 @@ export const MODELS = {
contextWindow: 202752,
maxTokens: 131072,
} satisfies Model<"openai-completions">,
+ "zai-org/GLM-5.2": {
+ id: "zai-org/GLM-5.2",
+ name: "GLM-5.2",
+ api: "openai-completions",
+ provider: "huggingface",
+ baseUrl: "https://router.huggingface.co/v1",
+ compat: {"supportsDeveloperRole":false},
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 1.4,
+ output: 4.4,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 262144,
+ maxTokens: 131072,
+ } satisfies Model<"openai-completions">,
},
"kimi-coding": {
"k2p7": {
@@ -7783,6 +8178,23 @@ export const MODELS = {
contextWindow: 204800,
maxTokens: 131072,
} satisfies Model<"openai-completions">,
+ "glm-5.2": {
+ id: "glm-5.2",
+ name: "GLM-5.2",
+ api: "openai-completions",
+ provider: "opencode",
+ baseUrl: "https://opencode.ai/zen/v1",
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 1.4,
+ output: 4.4,
+ cacheRead: 0.26,
+ cacheWrite: 0,
+ },
+ contextWindow: 1000000,
+ maxTokens: 131072,
+ } satisfies Model<"openai-completions">,
"gpt-5": {
id: "gpt-5",
name: "GPT-5",
@@ -8438,9 +8850,9 @@ export const MODELS = {
"qwen3.7-max": {
id: "qwen3.7-max",
name: "Qwen3.7 Max",
- api: "anthropic-messages",
+ api: "openai-completions",
provider: "opencode-go",
- baseUrl: "https://opencode.ai/zen/go",
+ baseUrl: "https://opencode.ai/zen/go/v1",
reasoning: true,
input: ["text"],
cost: {
@@ -8451,13 +8863,13 @@ export const MODELS = {
},
contextWindow: 1000000,
maxTokens: 65536,
- } satisfies Model<"anthropic-messages">,
+ } satisfies Model<"openai-completions">,
"qwen3.7-plus": {
id: "qwen3.7-plus",
name: "Qwen3.7 Plus",
- api: "anthropic-messages",
+ api: "openai-completions",
provider: "opencode-go",
- baseUrl: "https://opencode.ai/zen/go",
+ baseUrl: "https://opencode.ai/zen/go/v1",
reasoning: true,
input: ["text", "image"],
cost: {
@@ -8468,7 +8880,7 @@ export const MODELS = {
},
contextWindow: 1000000,
maxTokens: 65536,
- } satisfies Model<"anthropic-messages">,
+ } satisfies Model<"openai-completions">,
},
"openrouter": {
"ai21/jamba-large-1.7": {
@@ -8590,23 +9002,6 @@ export const MODELS = {
contextWindow: 200000,
maxTokens: 4096,
} satisfies Model<"openai-completions">,
- "anthropic/claude-3.5-haiku": {
- id: "anthropic/claude-3.5-haiku",
- name: "Anthropic: Claude 3.5 Haiku",
- api: "openai-completions",
- provider: "openrouter",
- baseUrl: "https://openrouter.ai/api/v1",
- reasoning: false,
- input: ["text", "image"],
- cost: {
- input: 0.7999999999999999,
- output: 4,
- cacheRead: 0.08,
- cacheWrite: 1,
- },
- contextWindow: 200000,
- maxTokens: 8192,
- } satisfies Model<"openai-completions">,
"anthropic/claude-fable-5": {
id: "anthropic/claude-fable-5",
name: "Anthropic: Claude Fable 5",
@@ -8862,13 +9257,13 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 0.22,
- output: 0.85,
+ input: 0.25,
+ output: 0.7999999999999999,
cacheRead: 0.06,
cacheWrite: 0,
},
contextWindow: 262144,
- maxTokens: 262144,
+ maxTokens: 80000,
} satisfies Model<"openai-completions">,
"arcee-ai/trinity-mini": {
id: "arcee-ai/trinity-mini",
@@ -9023,6 +9418,23 @@ export const MODELS = {
contextWindow: 128000,
maxTokens: 4000,
} satisfies Model<"openai-completions">,
+ "cohere/north-mini-code:free": {
+ id: "cohere/north-mini-code:free",
+ name: "Cohere: North Mini Code (free)",
+ api: "openai-completions",
+ provider: "openrouter",
+ baseUrl: "https://openrouter.ai/api/v1",
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 0,
+ output: 0,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 256000,
+ maxTokens: 64000,
+ } satisfies Model<"openai-completions">,
"deepseek/deepseek-chat": {
id: "deepseek/deepseek-chat",
name: "DeepSeek: DeepSeek V3",
@@ -9197,23 +9609,6 @@ export const MODELS = {
contextWindow: 1048576,
maxTokens: 384000,
} satisfies Model<"openai-completions">,
- "essentialai/rnj-1-instruct": {
- id: "essentialai/rnj-1-instruct",
- name: "EssentialAI: Rnj 1 Instruct",
- api: "openai-completions",
- provider: "openrouter",
- baseUrl: "https://openrouter.ai/api/v1",
- reasoning: false,
- input: ["text"],
- cost: {
- input: 0.15,
- output: 0.15,
- cacheRead: 0,
- cacheWrite: 0,
- },
- contextWindow: 32768,
- maxTokens: 4096,
- } satisfies Model<"openai-completions">,
"google/gemini-2.5-flash": {
id: "google/gemini-2.5-flash",
name: "Google: Gemini 2.5 Flash",
@@ -9330,8 +9725,25 @@ export const MODELS = {
cacheRead: 0.049999999999999996,
cacheWrite: 0.08333333333333334,
},
- contextWindow: 1048576,
- maxTokens: 65535,
+ contextWindow: 1048576,
+ maxTokens: 65535,
+ } satisfies Model<"openai-completions">,
+ "google/gemini-3-pro-image": {
+ id: "google/gemini-3-pro-image",
+ name: "Google: Nano Banana Pro (Gemini 3 Pro Image)",
+ api: "openai-completions",
+ provider: "openrouter",
+ baseUrl: "https://openrouter.ai/api/v1",
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 2,
+ output: 12,
+ cacheRead: 0.19999999999999998,
+ cacheWrite: 0.375,
+ },
+ contextWindow: 65536,
+ maxTokens: 32768,
} satisfies Model<"openai-completions">,
"google/gemini-3.1-flash-lite": {
id: "google/gemini-3.1-flash-lite",
@@ -9622,6 +10034,23 @@ export const MODELS = {
contextWindow: 256000,
maxTokens: 80000,
} satisfies Model<"openai-completions">,
+ "liquid/lfm-2.5-1.2b-thinking:free": {
+ id: "liquid/lfm-2.5-1.2b-thinking:free",
+ name: "LiquidAI: LFM2.5-1.2B-Thinking (free)",
+ api: "openai-completions",
+ provider: "openrouter",
+ baseUrl: "https://openrouter.ai/api/v1",
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 0,
+ output: 0,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 32768,
+ maxTokens: 4096,
+ } satisfies Model<"openai-completions">,
"meta-llama/llama-3.1-70b-instruct": {
id: "meta-llama/llama-3.1-70b-instruct",
name: "Meta: Llama 3.1 70B Instruct",
@@ -9784,9 +10213,9 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 0.15,
- output: 0.8999999999999999,
- cacheRead: 0.049999999999999996,
+ input: 0.12,
+ output: 0.48,
+ cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 204800,
@@ -9801,13 +10230,13 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 0.25,
- output: 1,
- cacheRead: 0.049999999999999996,
+ input: 0.18,
+ output: 0.72,
+ cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 204800,
- maxTokens: 131072,
+ maxTokens: 196608,
} satisfies Model<"openai-completions">,
"minimax/minimax-m3": {
id: "minimax/minimax-m3",
@@ -10160,7 +10589,7 @@ export const MODELS = {
cost: {
input: 0.6,
output: 2.5,
- cacheRead: 0,
+ cacheRead: 0.6,
cacheWrite: 0,
},
contextWindow: 262144,
@@ -10192,13 +10621,13 @@ export const MODELS = {
reasoning: true,
input: ["text", "image"],
cost: {
- input: 0.6799999999999999,
+ input: 0.66,
output: 3.41,
- cacheRead: 0.33999999999999997,
+ cacheRead: 0.144,
cacheWrite: 0,
},
contextWindow: 262144,
- maxTokens: 262142,
+ maxTokens: 262144,
} satisfies Model<"openai-completions">,
"moonshotai/kimi-k2.7-code": {
id: "moonshotai/kimi-k2.7-code",
@@ -10217,23 +10646,6 @@ export const MODELS = {
contextWindow: 262144,
maxTokens: 16384,
} satisfies Model<"openai-completions">,
- "nex-agi/nex-n2-pro:free": {
- id: "nex-agi/nex-n2-pro:free",
- name: "Nex AGI: Nex-N2-Pro (free)",
- api: "openai-completions",
- provider: "openrouter",
- baseUrl: "https://openrouter.ai/api/v1",
- reasoning: true,
- input: ["text", "image"],
- cost: {
- input: 0,
- output: 0,
- cacheRead: 0,
- cacheWrite: 0,
- },
- contextWindow: 262144,
- maxTokens: 262144,
- } satisfies Model<"openai-completions">,
"nvidia/llama-3.3-nemotron-super-49b-v1.5": {
id: "nvidia/llama-3.3-nemotron-super-49b-v1.5",
name: "NVIDIA: Llama 3.3 Nemotron Super 49B V1.5",
@@ -11105,13 +11517,13 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 0.039,
- output: 0.18,
+ input: 0.03,
+ output: 0.15,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 131072,
- maxTokens: 4096,
+ maxTokens: 131072,
} satisfies Model<"openai-completions">,
"openai/gpt-oss-120b:free": {
id: "openai/gpt-oss-120b:free",
@@ -11175,7 +11587,7 @@ export const MODELS = {
cost: {
input: 0.075,
output: 0.3,
- cacheRead: 0.037,
+ cacheRead: 0.0375,
cacheWrite: 0,
},
contextWindow: 131072,
@@ -11385,6 +11797,23 @@ export const MODELS = {
contextWindow: 1048756,
maxTokens: 262144,
} satisfies Model<"openai-completions">,
+ "poolside/laguna-m.1": {
+ id: "poolside/laguna-m.1",
+ name: "Poolside: Laguna M.1",
+ api: "openai-completions",
+ provider: "openrouter",
+ baseUrl: "https://openrouter.ai/api/v1",
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 0.19999999999999998,
+ output: 0.39999999999999997,
+ cacheRead: 0.09999999999999999,
+ cacheWrite: 0,
+ },
+ contextWindow: 262144,
+ maxTokens: 32768,
+ } satisfies Model<"openai-completions">,
"poolside/laguna-m.1:free": {
id: "poolside/laguna-m.1:free",
name: "Poolside: Laguna M.1 (free)",
@@ -11402,39 +11831,39 @@ export const MODELS = {
contextWindow: 262144,
maxTokens: 32768,
} satisfies Model<"openai-completions">,
- "poolside/laguna-xs.2:free": {
- id: "poolside/laguna-xs.2:free",
- name: "Poolside: Laguna XS.2 (free)",
+ "poolside/laguna-xs.2": {
+ id: "poolside/laguna-xs.2",
+ name: "Poolside: Laguna XS.2",
api: "openai-completions",
provider: "openrouter",
baseUrl: "https://openrouter.ai/api/v1",
reasoning: true,
input: ["text"],
cost: {
- input: 0,
- output: 0,
- cacheRead: 0,
+ input: 0.09999999999999999,
+ output: 0.19999999999999998,
+ cacheRead: 0.049999999999999996,
cacheWrite: 0,
},
contextWindow: 262144,
maxTokens: 32768,
} satisfies Model<"openai-completions">,
- "prime-intellect/intellect-3": {
- id: "prime-intellect/intellect-3",
- name: "Prime Intellect: INTELLECT-3",
+ "poolside/laguna-xs.2:free": {
+ id: "poolside/laguna-xs.2:free",
+ name: "Poolside: Laguna XS.2 (free)",
api: "openai-completions",
provider: "openrouter",
baseUrl: "https://openrouter.ai/api/v1",
reasoning: true,
input: ["text"],
cost: {
- input: 0.19999999999999998,
- output: 1.1,
+ input: 0,
+ output: 0,
cacheRead: 0,
cacheWrite: 0,
},
- contextWindow: 131072,
- maxTokens: 131072,
+ contextWindow: 262144,
+ maxTokens: 32768,
} satisfies Model<"openai-completions">,
"qwen/qwen-2.5-72b-instruct": {
id: "qwen/qwen-2.5-72b-instruct",
@@ -11453,6 +11882,23 @@ export const MODELS = {
contextWindow: 131072,
maxTokens: 16384,
} satisfies Model<"openai-completions">,
+ "qwen/qwen-2.5-7b-instruct": {
+ id: "qwen/qwen-2.5-7b-instruct",
+ name: "Qwen: Qwen2.5 7B Instruct",
+ api: "openai-completions",
+ provider: "openrouter",
+ baseUrl: "https://openrouter.ai/api/v1",
+ reasoning: false,
+ input: ["text"],
+ cost: {
+ input: 0.04,
+ output: 0.09999999999999999,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 131072,
+ maxTokens: 32768,
+ } satisfies Model<"openai-completions">,
"qwen/qwen-plus": {
id: "qwen/qwen-plus",
name: "Qwen: Qwen-Plus",
@@ -12125,9 +12571,9 @@ export const MODELS = {
reasoning: true,
input: ["text", "image"],
cost: {
- input: 0.15,
+ input: 0.14,
output: 1,
- cacheRead: 0.049999999999999996,
+ cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 262144,
@@ -12252,6 +12698,23 @@ export const MODELS = {
contextWindow: 256000,
maxTokens: 128000,
} satisfies Model<"openai-completions">,
+ "sakana/fugu-ultra": {
+ id: "sakana/fugu-ultra",
+ name: "Sakana: Fugu Ultra",
+ api: "openai-completions",
+ provider: "openrouter",
+ baseUrl: "https://openrouter.ai/api/v1",
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 5,
+ output: 30,
+ cacheRead: 0.5,
+ cacheWrite: 0,
+ },
+ contextWindow: 1000000,
+ maxTokens: 128000,
+ } satisfies Model<"openai-completions">,
"sao10k/l3.1-euryale-70b": {
id: "sao10k/l3.1-euryale-70b",
name: "Sao10K: Llama 3.1 Euryale 70B v2.2",
@@ -12312,30 +12775,13 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 0.06599999999999999,
- output: 0.26,
- cacheRead: 0.029,
+ input: 0.063,
+ output: 0.21,
+ cacheRead: 0.020999999999999998,
cacheWrite: 0,
},
contextWindow: 262144,
- maxTokens: 262144,
- } satisfies Model<"openai-completions">,
- "thedrummer/rocinante-12b": {
- id: "thedrummer/rocinante-12b",
- name: "TheDrummer: Rocinante 12B",
- api: "openai-completions",
- provider: "openrouter",
- baseUrl: "https://openrouter.ai/api/v1",
- reasoning: false,
- input: ["text"],
- cost: {
- input: 0.16999999999999998,
- output: 0.43,
- cacheRead: 0,
- cacheWrite: 0,
- },
- contextWindow: 32768,
- maxTokens: 32768,
+ maxTokens: 4096,
} satisfies Model<"openai-completions">,
"thedrummer/unslopnemo-12b": {
id: "thedrummer/unslopnemo-12b",
@@ -12431,13 +12877,13 @@ export const MODELS = {
reasoning: true,
input: ["text", "image"],
cost: {
- input: 0.14,
+ input: 0.105,
output: 0.28,
- cacheRead: 0.0028,
+ cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 1048576,
- maxTokens: 131072,
+ maxTokens: 4096,
} satisfies Model<"openai-completions">,
"xiaomi/mimo-v2.5-pro": {
id: "xiaomi/mimo-v2.5-pro",
@@ -12635,13 +13081,30 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 1.4,
- output: 4.4,
- cacheRead: 0.26,
+ input: 0.95,
+ output: 3,
+ cacheRead: 0.18,
cacheWrite: 0,
},
contextWindow: 1048576,
- maxTokens: 262144,
+ maxTokens: 32768,
+ } satisfies Model<"openai-completions">,
+ "z-ai/glm-5v-turbo": {
+ id: "z-ai/glm-5v-turbo",
+ name: "Z.ai: GLM 5V Turbo",
+ api: "openai-completions",
+ provider: "openrouter",
+ baseUrl: "https://openrouter.ai/api/v1",
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 1.2,
+ output: 4,
+ cacheRead: 0.24,
+ cacheWrite: 0,
+ },
+ contextWindow: 202752,
+ maxTokens: 131072,
} satisfies Model<"openai-completions">,
"~anthropic/claude-fable-latest": {
id: "~anthropic/claude-fable-latest",
@@ -12754,13 +13217,13 @@ export const MODELS = {
reasoning: true,
input: ["text", "image"],
cost: {
- input: 0.6799999999999999,
+ input: 0.66,
output: 3.41,
- cacheRead: 0.33999999999999997,
+ cacheRead: 0.144,
cacheWrite: 0,
},
contextWindow: 262144,
- maxTokens: 262142,
+ maxTokens: 262144,
} satisfies Model<"openai-completions">,
"~openai/gpt-latest": {
id: "~openai/gpt-latest",
@@ -13423,7 +13886,7 @@ export const MODELS = {
api: "anthropic-messages",
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
- reasoning: true,
+ reasoning: false,
input: ["text"],
cost: {
input: 1.5,
@@ -13440,7 +13903,7 @@ export const MODELS = {
api: "anthropic-messages",
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
- reasoning: true,
+ reasoning: false,
input: ["text"],
cost: {
input: 0.15,
@@ -13457,7 +13920,7 @@ export const MODELS = {
api: "anthropic-messages",
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
- reasoning: true,
+ reasoning: false,
input: ["text"],
cost: {
input: 0.5,
@@ -13570,6 +14033,40 @@ export const MODELS = {
contextWindow: 131072,
maxTokens: 32768,
} satisfies Model<"anthropic-messages">,
+ "alibaba/qwen3-vl-235b-a22b-instruct": {
+ id: "alibaba/qwen3-vl-235b-a22b-instruct",
+ name: "Qwen3 VL 235B A22B Instruct",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: false,
+ input: ["text", "image"],
+ cost: {
+ input: 0.39999999999999997,
+ output: 1.5999999999999999,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 131072,
+ maxTokens: 129024,
+ } satisfies Model<"anthropic-messages">,
+ "alibaba/qwen3-vl-instruct": {
+ id: "alibaba/qwen3-vl-instruct",
+ name: "Qwen3 VL 235B A22B Instruct",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: false,
+ input: ["text", "image"],
+ cost: {
+ input: 0.39999999999999997,
+ output: 1.5999999999999999,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 131072,
+ maxTokens: 129024,
+ } satisfies Model<"anthropic-messages">,
"alibaba/qwen3-vl-thinking": {
id: "alibaba/qwen3-vl-thinking",
name: "Qwen3 VL 235B A22B Thinking",
@@ -13669,25 +14166,93 @@ export const MODELS = {
cacheRead: 0.25,
cacheWrite: 1.5625,
},
- contextWindow: 991000,
- maxTokens: 64000,
+ contextWindow: 991000,
+ maxTokens: 64000,
+ } satisfies Model<"anthropic-messages">,
+ "alibaba/qwen3.7-plus": {
+ id: "alibaba/qwen3.7-plus",
+ name: "Qwen 3.7 Plus",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 0.39999999999999997,
+ output: 1.5999999999999999,
+ cacheRead: 0.08,
+ cacheWrite: 0.5,
+ },
+ contextWindow: 1000000,
+ maxTokens: 64000,
+ } satisfies Model<"anthropic-messages">,
+ "amazon/nova-2-lite": {
+ id: "amazon/nova-2-lite",
+ name: "Nova 2 Lite",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 0.3,
+ output: 2.5,
+ cacheRead: 0.075,
+ cacheWrite: 0,
+ },
+ contextWindow: 1000000,
+ maxTokens: 1000000,
+ } satisfies Model<"anthropic-messages">,
+ "amazon/nova-lite": {
+ id: "amazon/nova-lite",
+ name: "Nova Lite",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: false,
+ input: ["text", "image"],
+ cost: {
+ input: 0.06,
+ output: 0.24,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 300000,
+ maxTokens: 8192,
+ } satisfies Model<"anthropic-messages">,
+ "amazon/nova-micro": {
+ id: "amazon/nova-micro",
+ name: "Nova Micro",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: false,
+ input: ["text"],
+ cost: {
+ input: 0.035,
+ output: 0.14,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 128000,
+ maxTokens: 8192,
} satisfies Model<"anthropic-messages">,
- "alibaba/qwen3.7-plus": {
- id: "alibaba/qwen3.7-plus",
- name: "Qwen 3.7 Plus",
+ "amazon/nova-pro": {
+ id: "amazon/nova-pro",
+ name: "Nova Pro",
api: "anthropic-messages",
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
- reasoning: true,
+ reasoning: false,
input: ["text", "image"],
cost: {
- input: 0.39999999999999997,
- output: 1.5999999999999999,
- cacheRead: 0.08,
- cacheWrite: 0.5,
+ input: 0.7999999999999999,
+ output: 3.1999999999999997,
+ cacheRead: 0,
+ cacheWrite: 0,
},
- contextWindow: 1000000,
- maxTokens: 64000,
+ contextWindow: 300000,
+ maxTokens: 8192,
} satisfies Model<"anthropic-messages">,
"anthropic/claude-3-haiku": {
id: "anthropic/claude-3-haiku",
@@ -13931,6 +14496,23 @@ export const MODELS = {
contextWindow: 262100,
maxTokens: 80000,
} satisfies Model<"anthropic-messages">,
+ "arcee-ai/trinity-mini": {
+ id: "arcee-ai/trinity-mini",
+ name: "Trinity Mini",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: false,
+ input: ["text"],
+ cost: {
+ input: 0.045,
+ output: 0.15,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 131072,
+ maxTokens: 131072,
+ } satisfies Model<"anthropic-messages">,
"bytedance/seed-1.6": {
id: "bytedance/seed-1.6",
name: "Seed 1.6",
@@ -13938,7 +14520,7 @@ export const MODELS = {
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
reasoning: true,
- input: ["text"],
+ input: ["text", "image"],
cost: {
input: 0.25,
output: 2,
@@ -13948,6 +14530,23 @@ export const MODELS = {
contextWindow: 256000,
maxTokens: 32000,
} satisfies Model<"anthropic-messages">,
+ "bytedance/seed-1.8": {
+ id: "bytedance/seed-1.8",
+ name: "Bytedance Seed 1.8",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 0.25,
+ output: 2,
+ cacheRead: 0.049999999999999996,
+ cacheWrite: 0,
+ },
+ contextWindow: 256000,
+ maxTokens: 64000,
+ } satisfies Model<"anthropic-messages">,
"cohere/command-a": {
id: "cohere/command-a",
name: "Command A",
@@ -14039,8 +14638,8 @@ export const MODELS = {
api: "anthropic-messages",
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
- reasoning: true,
- input: ["text", "image"],
+ reasoning: false,
+ input: ["text"],
cost: {
input: 0.28,
output: 0.42,
@@ -14057,7 +14656,7 @@ export const MODELS = {
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
reasoning: true,
- input: ["text", "image"],
+ input: ["text"],
cost: {
input: 0.62,
output: 1.85,
@@ -14074,7 +14673,7 @@ export const MODELS = {
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
reasoning: true,
- input: ["text", "image"],
+ input: ["text"],
cost: {
input: 0.14,
output: 0.28,
@@ -14277,7 +14876,7 @@ export const MODELS = {
api: "anthropic-messages",
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
- reasoning: false,
+ reasoning: true,
input: ["text", "image"],
cost: {
input: 0.14,
@@ -14322,6 +14921,40 @@ export const MODELS = {
contextWindow: 32000,
maxTokens: 16384,
} satisfies Model<"anthropic-messages">,
+ "interfaze/interfaze-beta": {
+ id: "interfaze/interfaze-beta",
+ name: "Interfaze Beta",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 1.5,
+ output: 3.5,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 1000000,
+ maxTokens: 32000,
+ } satisfies Model<"anthropic-messages">,
+ "kwaipilot/kat-coder-pro-v1": {
+ id: "kwaipilot/kat-coder-pro-v1",
+ name: "KAT-Coder-Pro V1",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: false,
+ input: ["text"],
+ cost: {
+ input: 0.3,
+ output: 1.2,
+ cacheRead: 0.06,
+ cacheWrite: 0,
+ },
+ contextWindow: 256000,
+ maxTokens: 32000,
+ } satisfies Model<"anthropic-messages">,
"kwaipilot/kat-coder-pro-v2": {
id: "kwaipilot/kat-coder-pro-v2",
name: "Kat Coder Pro V2",
@@ -14356,6 +14989,23 @@ export const MODELS = {
contextWindow: 128000,
maxTokens: 100000,
} satisfies Model<"anthropic-messages">,
+ "meituan/longcat-flash-thinking-2601": {
+ id: "meituan/longcat-flash-thinking-2601",
+ name: "LongCat Flash Thinking 2601",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 0,
+ output: 0,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 32768,
+ maxTokens: 32768,
+ } satisfies Model<"anthropic-messages">,
"meta/llama-3.1-70b": {
id: "meta/llama-3.1-70b",
name: "Llama 3.1 70B Instruct",
@@ -14669,7 +15319,7 @@ export const MODELS = {
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
reasoning: false,
- input: ["text"],
+ input: ["text", "image"],
cost: {
input: 0.09999999999999999,
output: 0.3,
@@ -14679,6 +15329,57 @@ export const MODELS = {
contextWindow: 256000,
maxTokens: 256000,
} satisfies Model<"anthropic-messages">,
+ "mistral/magistral-medium": {
+ id: "mistral/magistral-medium",
+ name: "Magistral Medium 2509",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 2,
+ output: 5,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 128000,
+ maxTokens: 64000,
+ } satisfies Model<"anthropic-messages">,
+ "mistral/magistral-small": {
+ id: "mistral/magistral-small",
+ name: "Magistral Small 2509",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 0.5,
+ output: 1.5,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 128000,
+ maxTokens: 64000,
+ } satisfies Model<"anthropic-messages">,
+ "mistral/ministral-14b": {
+ id: "mistral/ministral-14b",
+ name: "Ministral 14B",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: false,
+ input: ["text", "image"],
+ cost: {
+ input: 0.19999999999999998,
+ output: 0.19999999999999998,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 256000,
+ maxTokens: 256000,
+ } satisfies Model<"anthropic-messages">,
"mistral/ministral-3b": {
id: "mistral/ministral-3b",
name: "Ministral 3B",
@@ -14713,6 +15414,23 @@ export const MODELS = {
contextWindow: 128000,
maxTokens: 4000,
} satisfies Model<"anthropic-messages">,
+ "mistral/mistral-large-3": {
+ id: "mistral/mistral-large-3",
+ name: "Mistral Large 3",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: false,
+ input: ["text", "image"],
+ cost: {
+ input: 0.5,
+ output: 1.5,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 256000,
+ maxTokens: 256000,
+ } satisfies Model<"anthropic-messages">,
"mistral/mistral-medium": {
id: "mistral/mistral-medium",
name: "Mistral Medium 3.1",
@@ -14737,7 +15455,7 @@ export const MODELS = {
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
reasoning: true,
- input: ["text"],
+ input: ["text", "image"],
cost: {
input: 1.5,
output: 7.5,
@@ -14917,6 +15635,23 @@ export const MODELS = {
contextWindow: 262144,
maxTokens: 32768,
} satisfies Model<"anthropic-messages">,
+ "nvidia/nemotron-3-nano-30b-a3b": {
+ id: "nvidia/nemotron-3-nano-30b-a3b",
+ name: "Nemotron 3 Nano 30B A3B",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 0.049999999999999996,
+ output: 0.24,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 262144,
+ maxTokens: 262144,
+ } satisfies Model<"anthropic-messages">,
"nvidia/nemotron-3-super-120b-a12b": {
id: "nvidia/nemotron-3-super-120b-a12b",
name: "NVIDIA Nemotron 3 Super 120B A12B",
@@ -14985,6 +15720,23 @@ export const MODELS = {
contextWindow: 131072,
maxTokens: 131072,
} satisfies Model<"anthropic-messages">,
+ "openai/gpt-3.5-turbo": {
+ id: "openai/gpt-3.5-turbo",
+ name: "GPT-3.5 Turbo",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: false,
+ input: ["text"],
+ cost: {
+ input: 0.5,
+ output: 1.5,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 16385,
+ maxTokens: 4096,
+ } satisfies Model<"anthropic-messages">,
"openai/gpt-4-turbo": {
id: "openai/gpt-4-turbo",
name: "GPT-4 Turbo",
@@ -15110,7 +15862,7 @@ export const MODELS = {
api: "anthropic-messages",
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
- reasoning: true,
+ reasoning: false,
input: ["text", "image"],
cost: {
input: 1.25,
@@ -15246,7 +15998,7 @@ export const MODELS = {
api: "anthropic-messages",
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
- reasoning: true,
+ reasoning: false,
input: ["text", "image"],
cost: {
input: 1.25,
@@ -15298,7 +16050,7 @@ export const MODELS = {
api: "anthropic-messages",
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
- reasoning: true,
+ reasoning: false,
thinkingLevelMap: {"xhigh":"xhigh"},
input: ["text", "image"],
cost: {
@@ -15352,7 +16104,7 @@ export const MODELS = {
api: "anthropic-messages",
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
- reasoning: true,
+ reasoning: false,
thinkingLevelMap: {"xhigh":"xhigh"},
input: ["text", "image"],
cost: {
@@ -15643,39 +16395,22 @@ export const MODELS = {
contextWindow: 200000,
maxTokens: 100000,
} satisfies Model<"anthropic-messages">,
- "perplexity/sonar": {
- id: "perplexity/sonar",
- name: "Sonar",
- api: "anthropic-messages",
- provider: "vercel-ai-gateway",
- baseUrl: "https://ai-gateway.vercel.sh",
- reasoning: false,
- input: ["text", "image"],
- cost: {
- input: 0,
- output: 0,
- cacheRead: 0,
- cacheWrite: 0,
- },
- contextWindow: 127000,
- maxTokens: 8000,
- } satisfies Model<"anthropic-messages">,
- "perplexity/sonar-pro": {
- id: "perplexity/sonar-pro",
- name: "Sonar Pro",
+ "sakana/fugu-ultra": {
+ id: "sakana/fugu-ultra",
+ name: "Fugu Ultra",
api: "anthropic-messages",
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
- reasoning: false,
+ reasoning: true,
input: ["text", "image"],
cost: {
- input: 0,
- output: 0,
- cacheRead: 0,
+ input: 5,
+ output: 30,
+ cacheRead: 0.5,
cacheWrite: 0,
},
- contextWindow: 200000,
- maxTokens: 8000,
+ contextWindow: 1000000,
+ maxTokens: 1000000,
} satisfies Model<"anthropic-messages">,
"stepfun/step-3.5-flash": {
id: "stepfun/step-3.5-flash",
@@ -15688,8 +16423,8 @@ export const MODELS = {
cost: {
input: 0.09,
output: 0.3,
- cacheRead: 0,
- cacheWrite: 0.02,
+ cacheRead: 0.02,
+ cacheWrite: 0,
},
contextWindow: 262114,
maxTokens: 262114,
@@ -15939,7 +16674,7 @@ export const MODELS = {
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
reasoning: true,
- input: ["text", "image"],
+ input: ["text"],
cost: {
input: 0.435,
output: 0.87,
@@ -16143,7 +16878,7 @@ export const MODELS = {
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
reasoning: true,
- input: ["text", "image"],
+ input: ["text"],
cost: {
input: 1.4,
output: 4.4,
@@ -16170,6 +16905,23 @@ export const MODELS = {
contextWindow: 1000000,
maxTokens: 128000,
} satisfies Model<"anthropic-messages">,
+ "zai/glm-5.2-fast": {
+ id: "zai/glm-5.2-fast",
+ name: "GLM 5.2 Fast",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 3,
+ output: 10.25,
+ cacheRead: 0.5,
+ cacheWrite: 0,
+ },
+ contextWindow: 1000000,
+ maxTokens: 128000,
+ } satisfies Model<"anthropic-messages">,
"zai/glm-5v-turbo": {
id: "zai/glm-5v-turbo",
name: "GLM 5V Turbo",
diff --git a/packages/ai/src/providers/openai-completions.ts b/packages/ai/src/providers/openai-completions.ts
index 667a9ecb08..1da54fd314 100644
--- a/packages/ai/src/providers/openai-completions.ts
+++ b/packages/ai/src/providers/openai-completions.ts
@@ -834,10 +834,23 @@ export function convertMessages(
assistantMsg.content = assistantText;
}
- // Use the signature from the first thinking block if available (for llama.cpp server + gpt-oss)
- const signature = nonEmptyThinkingBlocks[0].thinkingSignature;
- if (signature && signature.length > 0) {
- (assistantMsg as any)[signature] = nonEmptyThinkingBlocks.map((block) => block.thinking).join("\n");
+ // thinkingSignature holds the field the provider streamed reasoning in
+ // (reasoning_content / reasoning / reasoning_text), not a crypto signature.
+ // Prefer reasoning_content when the provider requires it (otherwise the
+ // reasoning_content="" default below would clobber the trace); else round-trip
+ // into the recorded field; with neither, keep the trace as text rather than
+ // inventing an unsupported field.
+ const reasoningText = nonEmptyThinkingBlocks
+ .map((block) => sanitizeSurrogates(block.thinking))
+ .join("\n");
+ const reasoningField = compat.requiresReasoningContentOnAssistantMessages
+ ? "reasoning_content"
+ : nonEmptyThinkingBlocks[0].thinkingSignature || undefined;
+ if (reasoningField) {
+ (assistantMsg as any)[reasoningField] = reasoningText;
+ } else {
+ assistantMsg.content =
+ assistantText.length > 0 ? `${reasoningText}\n\n${assistantText}` : reasoningText;
}
}
} else if (assistantText.length > 0) {
diff --git a/packages/ai/test/openai-completions-reasoning-replay.test.ts b/packages/ai/test/openai-completions-reasoning-replay.test.ts
new file mode 100644
index 0000000000..7f641d4e7b
--- /dev/null
+++ b/packages/ai/test/openai-completions-reasoning-replay.test.ts
@@ -0,0 +1,168 @@
+import { describe, expect, it } from "vitest";
+import { convertMessages } from "../src/providers/openai-completions.js";
+import type { AssistantMessage, Context, Model, OpenAICompletionsCompat, Usage } from "../src/types.js";
+
+const emptyUsage: Usage = {
+ input: 0,
+ output: 0,
+ cacheRead: 0,
+ cacheWrite: 0,
+ totalTokens: 0,
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
+};
+
+// requiresThinkingAsText: false -> exercises the native reasoning-field replay path.
+const compat = {
+ supportsStore: true,
+ supportsDeveloperRole: true,
+ supportsReasoningEffort: true,
+ supportsUsageInStreaming: true,
+ maxTokensField: "max_completion_tokens",
+ requiresToolResultName: false,
+ requiresAssistantAfterToolResult: false,
+ requiresThinkingAsText: false,
+ requiresReasoningContentOnAssistantMessages: false,
+ thinkingFormat: "openai",
+ openRouterRouting: {},
+ vercelGatewayRouting: {},
+ zaiToolStream: false,
+ supportsStrictMode: true,
+ cacheControlFormat: undefined,
+ sendSessionAffinityHeaders: false,
+ supportsLongCacheRetention: true,
+} satisfies Required<Omit<OpenAICompletionsCompat, "cacheControlFormat">> & {
+ cacheControlFormat?: OpenAICompletionsCompat["cacheControlFormat"];
+};
+
+function buildModel(): Model<"openai-completions"> {
+ return {
+ id: "repro-model",
+ name: "Repro Model",
+ api: "openai-completions",
+ provider: "repro-provider",
+ baseUrl: "http://127.0.0.1:1",
+ reasoning: true,
+ input: ["text"],
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
+ contextWindow: 128000,
+ maxTokens: 4096,
+ compat,
+ };
+}
+
+function buildContext(content: AssistantMessage["content"]): Context {
+ return {
+ messages: [
+ { role: "user", content: "hello", timestamp: 1 },
+ {
+ role: "assistant",
+ content,
+ api: "openai-completions",
+ provider: "repro-provider",
+ model: "repro-model",
+ usage: emptyUsage,
+ stopReason: "stop",
+ timestamp: 2,
+ } satisfies AssistantMessage,
+ { role: "user", content: "continue", timestamp: 3 },
+ ],
+ };
+}
+
+describe("openai-completions reasoning replay", () => {
+ it("replays thinking into the field recorded by thinkingSignature", () => {
+ const messages = convertMessages(
+ buildModel(),
+ buildContext([
+ { type: "thinking", thinking: "step by step", thinkingSignature: "reasoning" },
+ { type: "text", text: "answer" },
+ ]),
+ compat,
+ );
+
+ const assistant = messages[1] as unknown as Record<string, unknown>;
+ expect(assistant.content).toBe("answer");
+ expect(assistant.reasoning).toBe("step by step");
+ });
+
+ it("keeps unsigned thinking as text when the provider doesn't use a reasoning field", () => {
+ const messages = convertMessages(
+ buildModel(),
+ buildContext([
+ { type: "thinking", thinking: "unsigned reasoning" },
+ { type: "text", text: "answer" },
+ ]),
+ compat,
+ );
+
+ const assistant = messages[1] as unknown as Record<string, unknown>;
+ // No recorded field and provider doesn't force reasoning_content: prepend as text so the
+ // trace is still sent back without inventing a non-standard field.
+ expect(assistant.reasoning_content).toBeUndefined();
+ expect(assistant.content).toBe("unsigned reasoning\n\nanswer");
+ });
+
+ it("uses reasoning_content for unsigned thinking only when the provider requires it", () => {
+ const reasoningCompat = { ...compat, requiresReasoningContentOnAssistantMessages: true };
+ const messages = convertMessages(
+ buildModel(),
+ buildContext([
+ { type: "thinking", thinking: "unsigned reasoning" },
+ { type: "text", text: "answer" },
+ ]),
+ reasoningCompat,
+ );
+
+ const assistant = messages[1] as unknown as Record<string, unknown>;
+ expect(assistant.reasoning_content).toBe("unsigned reasoning");
+ expect(assistant.content).toBe("answer");
+ });
+
+ it("writes reasoning_content (not the signature field) when the provider requires it", () => {
+ const reasoningCompat = { ...compat, requiresReasoningContentOnAssistantMessages: true };
+ const messages = convertMessages(
+ buildModel(),
+ // Recorded signature is "reasoning", but a reasoning_content provider must get the
+ // trace in reasoning_content or the reasoning_content="" default would erase it.
+ buildContext([
+ { type: "thinking", thinking: "step by step", thinkingSignature: "reasoning" },
+ { type: "text", text: "answer" },
+ ]),
+ reasoningCompat,
+ );
+
+ const assistant = messages[1] as unknown as Record<string, unknown>;
+ expect(assistant.reasoning_content).toBe("step by step");
+ });
+
+ it("sanitizes unpaired surrogates in replayed reasoning", () => {
+ const reasoningCompat = { ...compat, requiresReasoningContentOnAssistantMessages: true };
+ const messages = convertMessages(
+ buildModel(),
+ // Lone high surrogate (U+D800) would break JSON serialization on the next turn.
+ buildContext([
+ { type: "thinking", thinking: "before\ud800after" },
+ { type: "text", text: "answer" },
+ ]),
+ reasoningCompat,
+ );
+
+ const assistant = messages[1] as unknown as Record<string, unknown>;
+ expect(assistant.reasoning_content as string).not.toContain("\ud800");
+ });
+
+ it("replays signed thinking alongside a tool call", () => {
+ const messages = convertMessages(
+ buildModel(),
+ buildContext([
+ { type: "thinking", thinking: "deciding to call a tool", thinkingSignature: "reasoning" },
+ { type: "toolCall", id: "call-1", name: "search", arguments: { q: "x" } },
+ ]),
+ compat,
+ );
+
+ const assistant = messages[1] as unknown as Record<string, unknown>;
+ expect(assistant.reasoning).toBe("deciding to call a tool");
+ expect(Array.isArray(assistant.tool_calls)).toBe(true);
+ });
+});
diff --git a/packages/coding-agent/src/modes/interactive/interactive-mode.ts b/packages/coding-agent/src/modes/interactive/interactive-mode.ts
index 4e75704187..95d5bce0f8 100644
--- a/packages/coding-agent/src/modes/interactive/interactive-mode.ts
+++ b/packages/coding-agent/src/modes/interactive/interactive-mode.ts
@@ -64,6 +64,7 @@ import { isNoModelsAvailableMessage } from "../../core/auth-guidance.js";
import { type AgentCronJob, parseHeartbeatCommand } from "../../core/cron-jobs.js";
import type {
AutocompleteProviderFactory,
+ ContextUsage,
EditorFactory,
ExtensionCommandContext,
ExtensionContext,
@@ -520,6 +521,9 @@ export class InteractiveMode {
private pulseTimer: NodeJS.Timeout | undefined = undefined;
private pulseFrame = 0;
private readonly activityTracker = new AgentActivityTracker();
+ // activityTracker token count already folded into the context snapshot; only output beyond
+ // this counts as live in-flight (keeps auto-retries from re-adding a failed attempt).
+ private contextUsageTokenBaseline = 0;
private readonly defaultHiddenThinkingLabel = "Thinking...";
private hiddenThinkingLabel = this.defaultHiddenThinkingLabel;
@@ -2034,6 +2038,10 @@ export class InteractiveMode {
private applyConnectionStateSnapshot(state: AgentConnectionState): void {
this.connectionState = state;
+ // Don't touch contextUsageTokenBaseline: a mid-stream snapshot reflects only completed
+ // turns (the in-flight message isn't persisted yet), so the in-flight delta must keep
+ // accumulating. The baseline is managed at turn end (refreshConnectionContextUsage) and
+ // reset on a new user message.
this.footer.setAutoCompactEnabled(state.autoCompactionEnabled);
this.sessionRecap = state.recap;
this.renderRecap();
@@ -2048,6 +2056,37 @@ export class InteractiveMode {
this.updateWorkingPulse();
}
+ // Bake this attempt's output into the snapshot so the tray doesn't dip in the gap between
+ // isStreaming clearing and the async refresh landing.
+ private applyOptimisticContextUsage(): void {
+ const snapshot = this.connectionState?.contextUsage;
+ if (!snapshot || snapshot.tokens === null || snapshot.contextWindow <= 0) return;
+ const completed = Math.max(0, this.activityTracker.getStatus().tokens - this.contextUsageTokenBaseline);
+ if (completed <= 0) return;
+ const tokens = snapshot.tokens + completed;
+ this.patchConnectionState({
+ contextUsage: {
+ tokens,
+ contextWindow: snapshot.contextWindow,
+ percent: (tokens / snapshot.contextWindow) * 100,
+ },
+ });
+ }
+
+ /** Refresh the tray's context usage from the session after a turn or compaction completes. */
+ private async refreshConnectionContextUsage(): Promise<void> {
+ const connection = this.agentConnection;
+ const sessionId = this.connectionState?.sessionId;
+ const stats = await connection?.getSessionStats?.().catch(() => undefined);
+ if (!stats) return;
+ // Drop the result if the user switched sessions or the connection was rebound while the
+ // async call was in flight — otherwise stale stats would overwrite the new session.
+ if (this.agentConnection !== connection || this.connectionState?.sessionId !== sessionId) return;
+ // Anything counted so far is now reflected in the snapshot; only later output is in-flight.
+ this.contextUsageTokenBaseline = this.activityTracker.getStatus().tokens;
+ this.patchConnectionState({ contextUsage: stats.contextUsage });
+ }
+
private updateConnectionStateFromEvent(event: AgentConnectionSessionEvent): void {
if (!this.connectionState) {
return;
@@ -2135,7 +2174,25 @@ export class InteractiveMode {
}
private getConnectionContextUsage(): AgentConnectionState["contextUsage"] {
- return this.connectionState?.contextUsage;
+ const snapshot = this.connectionState?.contextUsage;
+ if (!snapshot || snapshot.tokens === null || snapshot.contextWindow <= 0) {
+ return snapshot;
+ }
+ // Add only the output produced since the snapshot was last refreshed. The activity
+ // tracker accumulates across auto-retries within a turn, so subtract the baseline
+ // captured at the last refresh to avoid re-adding a failed attempt's tokens.
+ const inFlight = this.isAgentStreaming()
+ ? Math.max(0, this.activityTracker.getStatus().tokens - this.contextUsageTokenBaseline)
+ : 0;
+ if (inFlight <= 0) {
+ return snapshot;
+ }
+ const tokens = snapshot.tokens + inFlight;
+ return {
+ tokens,
+ contextWindow: snapshot.contextWindow,
+ percent: (tokens / snapshot.contextWindow) * 100,
+ } satisfies ContextUsage;
}
private getScopedModelState(): AgentConnectionState["scopedModels"] {
@@ -2202,6 +2259,7 @@ export class InteractiveMode {
this.activeBashComponent = undefined;
this.pendingBashComponents = [];
this.activityTracker.reset();
+ this.contextUsageTokenBaseline = 0;
this.resetPendingToolState();
this.resetChildAgentInspector();
this.setGoalAnnouncementBaseline(this.getGoalState());
@@ -3847,6 +3905,11 @@ export class InteractiveMode {
this.footer.invalidate();
this.updateConnectionStateFromEvent(event);
+ // A new user message resets the activity tracker to 0, so the in-flight baseline must
+ // reset with it. (agent_start on auto-retry does not reset the tracker.)
+ if (event.type === "message_start" && event.message.role === "user") {
+ this.contextUsageTokenBaseline = 0;
+ }
this.activityTracker.handleEvent(event);
this.updateWorkingLoaderMessage();
@@ -4059,6 +4122,9 @@ export class InteractiveMode {
this.flushPendingBashComponents();
this.resetPendingToolState();
+ this.applyOptimisticContextUsage();
+ await this.refreshConnectionContextUsage();
+
await this.checkShutdownRequested();
this.ui.requestRender();
@@ -4119,6 +4185,7 @@ export class InteractiveMode {
event.customInstructions,
),
);
+ await this.refreshConnectionContextUsage();
this.footer.invalidate();
} else if (event.errorMessage) {
if (event.errorSeverity === "warning") {
diff --git a/packages/coding-agent/test/interactive-mode-compaction.test.ts b/packages/coding-agent/test/interactive-mode-compaction.test.ts
index 2f89468738..130e1e6b28 100644
--- a/packages/coding-agent/test/interactive-mode-compaction.test.ts
+++ b/packages/coding-agent/test/interactive-mode-compaction.test.ts
@@ -18,6 +18,7 @@ describe("InteractiveMode compaction events", () => {
chatContainer: { clear: vi.fn() },
rebuildChatFromMessages: vi.fn(),
addMessageToChat: vi.fn(),
+ refreshConnectionContextUsage: vi.fn().mockResolvedValue(undefined),
showError: vi.fn(),
showWarning: vi.fn(),
showStatus: vi.fn(),
diff --git a/packages/coding-agent/test/interactive-mode-status.test.ts b/packages/coding-agent/test/interactive-mode-status.test.ts
index 8e53a2824a..cba191f954 100644
--- a/packages/coding-agent/test/interactive-mode-status.test.ts
+++ b/packages/coding-agent/test/interactive-mode-status.test.ts
@@ -1222,6 +1222,107 @@ describe("InteractiveMode tray goal label", () => {
});
});
+describe("InteractiveMode live context usage", () => {
+ type LiveContextHarness = {
+ connectionState: Pick<AgentConnectionState, "contextUsage"> | undefined;
+ activityTracker: { getStatus(): { tokens: number } };
+ isAgentStreaming(): boolean;
+ contextUsageTokenBaseline: number;
+ getConnectionContextUsage(): AgentConnectionState["contextUsage"];
+ };
+ const prototype = InteractiveMode.prototype as unknown as LiveContextHarness;
+
+ function createHarness(
+ opts: { streaming?: boolean; inFlight?: number; baseline?: number } = {},
+ ): LiveContextHarness {
+ const fakeThis = Object.create(InteractiveMode.prototype) as LiveContextHarness;
+ fakeThis.connectionState = { contextUsage: undefined };
+ fakeThis.activityTracker = { getStatus: () => ({ tokens: opts.inFlight ?? 0 }) };
+ fakeThis.isAgentStreaming = () => opts.streaming ?? false;
+ fakeThis.contextUsageTokenBaseline = opts.baseline ?? 0;
+ return fakeThis;
+ }
+
+ test("returns the snapshot verbatim when idle", () => {
+ const fakeThis = createHarness();
+ fakeThis.connectionState = { contextUsage: { contextWindow: 100_000, tokens: 42_000, percent: 42 } };
+
+ expect(prototype.getConnectionContextUsage.call(fakeThis)).toEqual({
+ contextWindow: 100_000,
+ tokens: 42_000,
+ percent: 42,
+ });
+ });
+
+ test("adds in-flight streaming output to the snapshot baseline while streaming", () => {
+ const fakeThis = createHarness({ streaming: true, inFlight: 3_000 });
+ fakeThis.connectionState = { contextUsage: { contextWindow: 100_000, tokens: 42_000, percent: 42 } };
+
+ // 42k baseline + 3k in-flight = 45k; ticks up live as the model writes.
+ expect(prototype.getConnectionContextUsage.call(fakeThis)).toMatchObject({ tokens: 45_000, percent: 45 });
+ });
+
+ test("only adds output beyond the refresh baseline (auto-retry does not double count)", () => {
+ // Tracker holds 5k from a failed attempt (baseline), now 6k after 1k of the retry.
+ const fakeThis = createHarness({ streaming: true, inFlight: 6_000, baseline: 5_000 });
+ fakeThis.connectionState = { contextUsage: { contextWindow: 100_000, tokens: 42_000, percent: 42 } };
+
+ // Only the 1k generated since the refresh is in-flight, not the failed attempt's 5k.
+ expect(prototype.getConnectionContextUsage.call(fakeThis)).toMatchObject({ tokens: 43_000 });
+ });
+
+ test("does not add in-flight output when not streaming", () => {
+ const fakeThis = createHarness({ streaming: false, inFlight: 3_000 });
+ fakeThis.connectionState = { contextUsage: { contextWindow: 100_000, tokens: 42_000, percent: 42 } };
+
+ expect(prototype.getConnectionContextUsage.call(fakeThis)).toMatchObject({ tokens: 42_000 });
+ });
+
+ test("passes through an unknown (post-compaction) snapshot without inflating it", () => {
+ const fakeThis = createHarness({ streaming: true, inFlight: 3_000 });
+ fakeThis.connectionState = { contextUsage: { contextWindow: 100_000, tokens: null, percent: null } };
+
+ expect(prototype.getConnectionContextUsage.call(fakeThis)).toMatchObject({ tokens: null, percent: null });
+ });
+
+ test("returns undefined when there is no snapshot yet", () => {
+ const fakeThis = createHarness({ streaming: true, inFlight: 3_000 });
+ fakeThis.connectionState = { contextUsage: undefined };
+
+ expect(prototype.getConnectionContextUsage.call(fakeThis)).toBeUndefined();
+ });
+
+ test("refreshConnectionContextUsage drops stale stats after a session switch", async () => {
+ type RefreshHarness = {
+ agentConnection: { getSessionStats(): Promise<{ contextUsage: unknown }> };
+ connectionState: { sessionId?: string; contextUsage?: unknown };
+ activityTracker: { getStatus(): { tokens: number } };
+ contextUsageTokenBaseline: number;
+ patchConnectionState(patch: Record<string, unknown>): void;
+ refreshConnectionContextUsage(): Promise<void>;
+ };
+ const refresh = (InteractiveMode.prototype as unknown as RefreshHarness).refreshConnectionContextUsage;
+ const fakeThis = Object.create(InteractiveMode.prototype) as RefreshHarness;
+ const patched: Record<string, unknown>[] = [];
+ fakeThis.activityTracker = { getStatus: () => ({ tokens: 0 }) };
+ fakeThis.contextUsageTokenBaseline = 0;
+ fakeThis.connectionState = { sessionId: "session-A", contextUsage: undefined };
+ fakeThis.patchConnectionState = (p) => patched.push(p);
+ fakeThis.agentConnection = {
+ getSessionStats: async () => {
+ // User switches sessions while the stats call is in flight.
+ fakeThis.connectionState = { sessionId: "session-B", contextUsage: undefined };
+ return { contextUsage: { contextWindow: 100_000, tokens: 50_000, percent: 50 } };
+ },
+ };
+
+ await refresh.call(fakeThis);
+
+ // Stats belonged to session-A; must not overwrite session-B.
+ expect(patched).toHaveLength(0);
+ });
+});
+
describe("InteractiveMode.handleGoalStatusCommand", () => {
test("prints current goal details without queuing through the agent", () => {
type GoalStatusCommandHarness = {