Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

Merge remote-tracking branch 'origin/release/v3.8.0' into fix/combo-context-length-auto-calc

diegosouzapwf8812b95c7ce
diff --cc tests/unit/models-catalog-route.test.ts
index 8ee3ed4704,432a45f966..b6045efe90
--- a/tests/unit/models-catalog-route.test.ts
+++ b/tests/unit/models-catalog-route.test.ts
@@@ -926,63 -956,6 +956,64 @@@ test("v1 models catalog auto-calculate
);
});
+test("v1 models catalog includes context_length for individual chat models", async () => {
+ await seedConnection("openai", { name: "openai-context" });
+ await seedConnection("claude", {
+ authType: "oauth",
+ name: "claude-context",
+ apiKey: null,
+ accessToken: "claude-access",
+ });
+
+ const response = await v1ModelsCatalog.getUnifiedModelsResponse(
+ new Request("http://localhost/api/v1/models")
+ );
+ const body = (await response.json()) as any;
+ const chatModels = body.data.filter((item) => !item.type || item.type === "chat");
+
+ assert.equal(response.status, 200);
+ assert.ok(chatModels.length > 0, "should have at least one chat model");
+
+ for (const model of chatModels) {
+ assert.ok(
+ typeof model.context_length === "number" && model.context_length > 0,
+ `chat model ${model.id} should have a positive context_length, got ${model.context_length}`
+ );
+ }
+});
+
+test("v1 models catalog falls back to getTokenLimit for models without registry defaultContextLength", async () => {
+ // opencode-go has defaultContextLength in REGISTRY, but we test the fallback
+ // path by verifying models from the synced path still get context_length
+ const connection = await seedConnection("opencode-go", {
+ name: "opencode-go-context-fallback",
+ apiKey: "go-key",
+ });
+
+ await modelsDb.replaceSyncedAvailableModelsForConnection("opencode-go", (connection as any).id, [
+ {
+ id: "test-model-no-context",
+ name: "Test Model No Context",
+ source: "imported",
+ supportedEndpoints: ["chat"],
+ },
+ ]);
+
+ const response = await v1ModelsCatalog.getUnifiedModelsResponse(
+ new Request("http://localhost/api/v1/models")
+ );
+ const body = (await response.json()) as any;
+ const model = body.data.find((item) => item.id === "opencode-go/test-model-no-context");
+
+ assert.equal(response.status, 200);
+ assert.ok(model, "synced model should appear");
+ assert.ok(
+ typeof model.context_length === "number" && model.context_length > 0,
+ `synced model without inputTokenLimit should get context_length via getTokenLimit fallback, got ${model.context_length}`
+ );
+});
+
++
test("v1 models catalog prefers manual combo context_length over auto-calculated", async () => {
await seedConnection("openai", { name: "openai-manual-context" });