[PR #11173] fix: handle nested tool format and include strict field in oa-compat provider #13674

Closed
opened 2026-02-16 18:18:30 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/11173

State: closed
Merged: No


Summary

Fixes tool calling for Qwen2.5 and other models when using the oa-compat provider.

Root Cause

The toOaCompatibleRequest function in openai-compatible.ts had two issues:

  1. Assumes flat tool format only — The function was accessing tool.name, tool.description, tool.parameters directly, but CommonTool objects are already in the nested OpenAI format { type: "function", function: { name, description, parameters } }. When tools arrived in the nested format, tool.name was undefined and the tool definition sent to the model was empty.

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

Changes

  • Handle both flat and nested tool formats by checking for tool.function first
  • Include the strict field in the tool mapping

Test Plan

  • Verify Qwen2.5 models can now properly call tools when using the oa-compat provider
  • Confirm the fix doesn't break other provider formats

Fixes #11171

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/11173 **State:** closed **Merged:** No --- ## Summary Fixes tool calling for Qwen2.5 and other models when using the `oa-compat` provider. ## Root Cause The `toOaCompatibleRequest` function in `openai-compatible.ts` had two issues: 1. **Assumes flat tool format only** — The function was accessing `tool.name`, `tool.description`, `tool.parameters` directly, but `CommonTool` objects are already in the nested OpenAI format `{ type: "function", function: { name, description, parameters } }`. When tools arrived in the nested format, `tool.name` was `undefined` and the tool definition sent to the model was empty. 2. **Missing `strict` field** — The `CommonTool` interface defines `strict?: boolean`, but `toOaCompatibleRequest` was dropping it during tool mapping. Some models (including Qwen2.5) rely on this field. ## Changes - Handle both flat and nested tool formats by checking for `tool.function` first - Include the `strict` field in the tool mapping ## Test Plan - Verify Qwen2.5 models can now properly call tools when using the `oa-compat` provider - Confirm the fix doesn't break other provider formats Fixes #11171
yindo added the pull-request label 2026-02-16 18:18:30 -05:00
yindo closed this issue 2026-02-16 18:18:30 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13674