OpenAI OSS tool calling #1115

Closed
opened 2026-02-16 17:29:31 -05:00 by yindo · 6 comments
Owner

Originally created by @Syazvinski on GitHub (Aug 5, 2025).

Originally assigned to: @thdxr on GitHub.

When running through LM Studio, it seems the new template for tools that the OpenAI OSS models use is different and causes premature reasoning to end. Not sure if this is an issue for LM Studio to solve or for Opencode to support.

This is my config

        "npm": "@ai-sdk/openai-compatible",
        "options": {
          "baseURL": "url here"
        },
        "models": {
          "openai/gpt-oss-20b": {
          "name": "Local Model LM Studio",
          "tool_call": true,
          "reasoning": true,
          "limit": {
            "context": 128000,
            "output": 128000
          },
           "options": {
            "tools": true,
            "reasoning": true
          }
          }
        }
    },```
Originally created by @Syazvinski on GitHub (Aug 5, 2025). Originally assigned to: @thdxr on GitHub. When running through LM Studio, it seems the new template for tools that the OpenAI OSS models use is different and causes premature reasoning to end. Not sure if this is an issue for LM Studio to solve or for Opencode to support. This is my config ``` "local": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "url here" }, "models": { "openai/gpt-oss-20b": { "name": "Local Model LM Studio", "tool_call": true, "reasoning": true, "limit": { "context": 128000, "output": 128000 }, "options": { "tools": true, "reasoning": true } } } },```
yindo closed this issue 2026-02-16 17:29:31 -05:00
Author
Owner

@cksac commented on GitHub (Aug 6, 2025):

looks like gpt-oss is trained with https://cookbook.openai.com/articles/openai-harmony#function-calling?
the final prompt should follow openai-harmony format to achieve better result.

@cksac commented on GitHub (Aug 6, 2025): looks like gpt-oss is trained with https://cookbook.openai.com/articles/openai-harmony#function-calling? the final prompt should follow openai-harmony format to achieve better result.
Author
Owner

@jgontrum commented on GitHub (Aug 6, 2025):

AFAIK opencode uses AI SDK which handles the final formatting of the prompts for the used mode/provider. Wouldn’t be surprised if they release an update soon, they seem quite active

@jgontrum commented on GitHub (Aug 6, 2025): AFAIK opencode uses AI SDK which handles the final formatting of the prompts for the used mode/provider. Wouldn’t be surprised if they release an update soon, they seem quite active
Author
Owner

@Ronuhz commented on GitHub (Aug 6, 2025):

Yeah either something goes very wrong with tool calls in OpenCode or the AI SDK, or this model sucks at tool calling.

@Ronuhz commented on GitHub (Aug 6, 2025): Yeah either something goes very wrong with tool calls in OpenCode or the AI SDK, or this model sucks at tool calling.
Author
Owner

@thdxr commented on GitHub (Aug 6, 2025):

it's both - the model sucks at tool calling but parsing these harmony formats is up to the provider - in this case LM Studio

i did think they pushed an update for it though?

@thdxr commented on GitHub (Aug 6, 2025): it's both - the model sucks at tool calling but parsing these harmony formats is up to the provider - in this case LM Studio<br><br>i did think they pushed an update for it though?
Author
Owner

@cksac commented on GitHub (Aug 7, 2025):

harmony formats is not only about model output, which is cater by the provider.
but also the application prompt requirements to achive best result when using gpt-oss.
If application required tool call using XML format, it most will failed at first shot as it mostly add <|constrain|>json before message, causing the model response in json format when tool call.

If application expect xml tool call foramt, add following to the prompt will help

1. USE XML format for all tool calls
2. DON'T add <|constrain|>json for tool calls
@cksac commented on GitHub (Aug 7, 2025): harmony formats is not only about model output, which is cater by the provider. but also the application prompt requirements to achive best result when using gpt-oss. If application required tool call using XML format, it most will failed at first shot as it mostly add `<|constrain|>json` before message, causing the model response in json format when tool call. If application expect xml tool call foramt, add following to the prompt will help ``` 1. USE XML format for all tool calls 2. DON'T add <|constrain|>json for tool calls ```
Author
Owner

@rekram1-node commented on GitHub (Dec 27, 2025):

[automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!

@rekram1-node commented on GitHub (Dec 27, 2025): [automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1115