bug: Qwen2.5 tool calling broken in oa-compat provider — tools not properly formatted in toOaCompatibleRequest #7971

Open
opened 2026-02-16 18:08:48 -05:00 by yindo · 2 comments
Owner

Originally created by @Almoosawi on GitHub (Jan 29, 2026).

Originally assigned to: @thdxr on GitHub.

Description

Description

Qwen2.5 models fail to perform tool calls when using the oa-compat provider format. The same model works correctly in Open WebUI.

Root Cause

In packages/console/app/src/routes/zen/util/provider/openai-compatible.ts, the toOaCompatibleRequest function has two issues:

  1. Assumes flat tool format only — The tools mapping does tool.name, tool.description, tool.parameters directly, but CommonTool objects arriving from other format converters may already be in the nested OpenAI format { type: "function", function: { name, description, parameters } }. When tools arrive nested, tool.name is undefined and the tool definition sent to the model is empty.

  2. Missing strict field — The CommonTool interface in provider.ts defines strict?: boolean, but toOaCompatibleRequest drops it during tool mapping. Some models (including Qwen2.5) rely on this field.

Current code (line 189)

const tools = Array.isArray(body.tools)
  ? body.tools.map((tool: any) => ({
      type: "function",
      function: {
        name: tool.name,
        description: tool.description,
        parameters: tool.parameters,
      },
    }))
  : undefined


### Plugins

_No response_

### OpenCode version

_No response_

### Steps to reproduce

_No response_

### Screenshot and/or share link

_No response_

### Operating System

_No response_

### Terminal

_No response_
Originally created by @Almoosawi on GitHub (Jan 29, 2026). Originally assigned to: @thdxr on GitHub. ### Description ## Description Qwen2.5 models fail to perform tool calls when using the `oa-compat` provider format. The same model works correctly in Open WebUI. ## Root Cause In `packages/console/app/src/routes/zen/util/provider/openai-compatible.ts`, the `toOaCompatibleRequest` function has two issues: 1. **Assumes flat tool format only** — The tools mapping does `tool.name`, `tool.description`, `tool.parameters` directly, but `CommonTool` objects arriving from other format converters may already be in the nested OpenAI format `{ type: "function", function: { name, description, parameters } }`. When tools arrive nested, `tool.name` is `undefined` and the tool definition sent to the model is empty. 2. **Missing `strict` field** — The `CommonTool` interface in `provider.ts` defines `strict?: boolean`, but `toOaCompatibleRequest` drops it during tool mapping. Some models (including Qwen2.5) rely on this field. ## Current code (line 189) ```typescript const tools = Array.isArray(body.tools) ? body.tools.map((tool: any) => ({ type: "function", function: { name: tool.name, description: tool.description, parameters: tool.parameters, }, })) : undefined ### Plugins _No response_ ### OpenCode version _No response_ ### Steps to reproduce _No response_ ### Screenshot and/or share link _No response_ ### Operating System _No response_ ### Terminal _No response_
yindo added the bugzen labels 2026-02-16 18:08:48 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 29, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #7030: Ollama (qwen2.5-coder): tool calls (edit/write) show as executed but no files are created/modified
  • #6918: qwen3-coder fails to call edit tool
  • #4255: OpenCode v1.0.25 Hangs Indefinitely with LM Studio + Qwen Models Due to Empty tool_calls Array
  • #5187: Ollama: User message content arrives as empty array - model cannot see user input
  • #7185: When use gpt-oss-120B by vLLM locally, opencode doesn't call the tools

These issues all relate to tool calling failures with Qwen and OpenAI-compatible providers. Your detailed analysis of the root cause (nested tool format handling and missing strict field) might help resolve these related issues as well.

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 29, 2026): This issue might be a duplicate of existing issues. Please check: - #7030: Ollama (qwen2.5-coder): tool calls (edit/write) show as executed but no files are created/modified - #6918: qwen3-coder fails to call edit tool - #4255: OpenCode v1.0.25 Hangs Indefinitely with LM Studio + Qwen Models Due to Empty tool_calls Array - #5187: Ollama: User message content arrives as empty array - model cannot see user input - #7185: When use gpt-oss-120B by vLLM locally, opencode doesn't call the tools These issues all relate to tool calling failures with Qwen and OpenAI-compatible providers. Your detailed analysis of the root cause (nested tool format handling and missing strict field) might help resolve these related issues as well. Feel free to ignore if none of these address your specific case.
Author
Owner

@Almoosawi commented on GitHub (Jan 29, 2026):

can you check this fix and implement if it's correct please:
const tools = Array.isArray(body.tools)
? body.tools.map((tool: any) => {
const t = tool.function ? tool.function : tool // <-- KEY FIX #1
return {
type: "function",
function: {
name: t.name,
description: t.description,
parameters: t.parameters,
strict: t.strict, // <-- KEY FIX #2
},
}
})
: undefined

@Almoosawi commented on GitHub (Jan 29, 2026): can you check this fix and implement if it's correct please: const tools = Array.isArray(body.tools) ? body.tools.map((tool: any) => { const t = tool.function ? tool.function : tool // <-- KEY FIX #1 return { type: "function", function: { name: t.name, description: t.description, parameters: t.parameters, strict: t.strict, // <-- KEY FIX #2 }, } }) : undefined
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7971