diff --git a/apps/supercode-cli/server/package.json b/apps/supercode-cli/server/package.json index 6a80b34..d1e8c39 100644 --- a/apps/supercode-cli/server/package.json +++ b/apps/supercode-cli/server/package.json @@ -1,6 +1,6 @@ { "name": "supercode-cli", - "version": "0.1.48", + "version": "0.1.49", "description": "AI-powered coding agent CLI", "main": "dist/main.js", "bin": { diff --git a/apps/supercode-cli/server/src/cli/ai/concentrate-service.ts b/apps/supercode-cli/server/src/cli/ai/concentrate-service.ts index 10001ca..14197e3 100644 --- a/apps/supercode-cli/server/src/cli/ai/concentrate-service.ts +++ b/apps/supercode-cli/server/src/cli/ai/concentrate-service.ts @@ -117,6 +117,7 @@ export class ConcentrateService { model: this.model, messages: nonSystemMessages, system, + maxOutputTokens: 8192, abortSignal: streamAbortController.signal, }) @@ -208,6 +209,7 @@ export class ConcentrateService { messages: nonSystemMessages, system, tools, + maxOutputTokens: 8192, stopWhen: stepCountIs(8), abortSignal: streamAbortController.signal, prepareStep: async ({ messages }) => { diff --git a/apps/supercode-cli/server/src/index.ts b/apps/supercode-cli/server/src/index.ts index 91a1403..2831dc3 100644 --- a/apps/supercode-cli/server/src/index.ts +++ b/apps/supercode-cli/server/src/index.ts @@ -13,6 +13,11 @@ import { join } from "path" import { writeFileSync, unlinkSync } from "fs" import { randomUUID } from "crypto" +function toolParams(fn: any): object { + const raw = fn.inputSchema ?? fn.parameters ?? {} + return raw && typeof raw === "object" && "_def" in raw ? {} : raw +} + loadEnvOnce() const port = process.env.PORT || 10000 @@ -33,7 +38,7 @@ const MODEL_MAX_TOKENS: Record = { "glm-5.2": 4096, "glm-5.1": 4096, "minimax-m3": 8192, - "anthropic/claude-opus-4-8": 128000, + "anthropic/claude-opus-4-8": 8192, } function getModelMaxTokens(model: string): number { const exact = MODEL_MAX_TOKENS[model] @@ -278,17 +283,10 @@ app.post("/api/ai/chat", async (req, res) => { bodyObj.messages = [{ role: "system", content: system }, ...bodyObj.messages] } if (tools) { - bodyObj.tools = Object.entries(tools).map(([name, fn]: [string, any]) => { - // AI SDK 6 tools expose their schema as `inputSchema`; fall back - // to the legacy `parameters` key for tools that haven't been - // wrapped yet. The schema object is already a JSON-Schema-shaped - // value (or a Zod schema) — OpenRouter accepts the JSON Schema. - const schema = fn.inputSchema ?? fn.parameters ?? {} - return { - type: "function", - function: { name, description: fn.description || "", parameters: schema }, - } - }) + bodyObj.tools = Object.entries(tools).map(([name, fn]: [string, any]) => ({ + type: "function", + function: { name, description: fn.description || "", parameters: toolParams(fn) }, + })) } const response = await fetch("https://openrouter.ai/api/v1/chat/completions", { method: "POST", @@ -430,7 +428,7 @@ app.post("/api/ai/chat", async (req, res) => { if (tools) { bodyObj.tools = Object.entries(tools).map(([name, fn]: [string, any]) => ({ type: "function", - function: { name, description: fn.description || "", parameters: fn.inputSchema ?? fn.parameters ?? {} }, + function: { name, description: fn.description || "", parameters: toolParams(fn) }, })) } const response = await fetch(`${baseUrl}/chat/completions`, { @@ -538,7 +536,7 @@ app.post("/api/ai/chat", async (req, res) => { if (tools) { bodyObj.tools = Object.entries(tools).map(([name, fn]: [string, any]) => ({ type: "function", - function: { name, description: fn.description || "", parameters: fn.inputSchema ?? fn.parameters ?? {} }, + function: { name, description: fn.description || "", parameters: toolParams(fn) }, })) } const response = await fetch("https://api.concentrate.ai/v1/chat/completions", {