Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ export function toOaCompatibleRequest(body: CommonRequest) {
? body.tools.map((tool: any) => ({
type: "function",
function: {
name: tool.name,
description: tool.description,
parameters: tool.parameters,
name: tool.function?.name,
description: tool.function?.description,
parameters: tool.function?.parameters ?? tool.function?.input_schema,
},
}))
: undefined
Expand Down
61 changes: 61 additions & 0 deletions packages/console/app/test/providerConversion.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { describe, expect, test } from "bun:test"
import { fromAnthropicRequest } from "../src/routes/zen/util/provider/anthropic"
import { toOaCompatibleRequest } from "../src/routes/zen/util/provider/openai-compatible"

describe("anthropic to oa-compat tool conversion", () => {
test("preserves tool names from Claude Code style anthropic requests", () => {
const anthropicBody = {
model: "deepseek-v4-flash-free",
max_tokens: 1024,
tools: [
{
name: "Bash",
description: "Run a bash command",
input_schema: {
type: "object",
properties: {
command: { type: "string" },
},
required: ["command"],
},
},
],
messages: [{ role: "user", content: "run echo hello" }],
}

const common = fromAnthropicRequest(anthropicBody)
const oaCompat = toOaCompatibleRequest(common)

expect(oaCompat.tools).toEqual([
{
type: "function",
function: {
name: "Bash",
description: "Run a bash command",
parameters: anthropicBody.tools[0].input_schema,
},
},
])
})

test("passes through already-normalized common request tools", () => {
const common = {
model: "north-mini-code-free",
messages: [{ role: "user" as const, content: "hi" }],
tools: [
{
type: "function" as const,
function: {
name: "Read",
description: "Read a file",
parameters: { type: "object", properties: { path: { type: "string" } } },
},
},
],
}

const oaCompat = toOaCompatibleRequest(common)

expect(oaCompat.tools?.[0]?.function?.name).toBe("Read")
})
})
Loading