[GH-ISSUE #11805] Tool call arguments structure inconsistent — extra nesting added in certain cases #54345

Open
opened 2026-04-29 05:47:03 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @ocivo on GitHub (Aug 8, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/11805

What is the issue?

When using Ollama's /api/chat (and likely /v1/chat/completions) with function calling, the tool_calls[].function.arguments field sometimes contains an extra nested arguments and name property, instead of returning only the function parameters object.

This makes the structure inconsistent and breaks OpenAI-compatible clients, which expect arguments to contain only the parameters defined in the tool schema.

Relevant log output

Steps to Reproduce:

Working case:
POST /api/chat
{
  "messages": [
    { "role": "user", "content": "I love Hongkong" }
  ],
  "model": "qwen2.5:14b",
  "stream": false,
  "tool_choice": "auto",
  "tools": [
    {
      "function": {
        "type": "function",
        "name": "ExtractCity",
        "description": "Extract the city name",
        "parameters": {
          "type": "object",
          "properties": { "city": { "type": "string" } },
          "required": ["city"]
        }
      }
    }
  ]
}
Response:
"arguments": { "city": "Hongkong" }

Broken case:
POST /api/chat
{
  "messages": [
    { "role": "user", "content": "My name is John" }
  ],
  "model": "qwen2.5:14b",
  "stream": false,
  "tool_choice": "auto",
  "tools": [
    {
      "function": {
        "type": "function",
        "name": "ExtractName",
        "description": "Extract the name",
        "parameters": {
          "type": "object",
          "properties": { "name": { "type": "string" } },
          "required": ["name"]
        }
      }
    }
  ]
}
"arguments": {
  "arguments": { "name": "John" },
  "name": "ExtractName"
}

OS

No response

GPU

No response

CPU

No response

Ollama version

No response

Originally created by @ocivo on GitHub (Aug 8, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/11805 ### What is the issue? When using Ollama's /api/chat (and likely /v1/chat/completions) with function calling, the tool_calls[].function.arguments field sometimes contains an extra nested arguments and name property, instead of returning only the function parameters object. This makes the structure inconsistent and breaks OpenAI-compatible clients, which expect arguments to contain only the parameters defined in the tool schema. ### Relevant log output ```shell Steps to Reproduce: Working case: POST /api/chat { "messages": [ { "role": "user", "content": "I love Hongkong" } ], "model": "qwen2.5:14b", "stream": false, "tool_choice": "auto", "tools": [ { "function": { "type": "function", "name": "ExtractCity", "description": "Extract the city name", "parameters": { "type": "object", "properties": { "city": { "type": "string" } }, "required": ["city"] } } } ] } Response: "arguments": { "city": "Hongkong" } Broken case: POST /api/chat { "messages": [ { "role": "user", "content": "My name is John" } ], "model": "qwen2.5:14b", "stream": false, "tool_choice": "auto", "tools": [ { "function": { "type": "function", "name": "ExtractName", "description": "Extract the name", "parameters": { "type": "object", "properties": { "name": { "type": "string" } }, "required": ["name"] } } } ] } "arguments": { "arguments": { "name": "John" }, "name": "ExtractName" } ``` ### OS _No response_ ### GPU _No response_ ### CPU _No response_ ### Ollama version _No response_
GiteaMirror added the bug label 2026-04-29 05:47:03 -05:00
Author
Owner

@mcr-ksh commented on GitHub (Oct 10, 2025):

evtl related to https://github.com/ollama/ollama/issues/12187

<!-- gh-comment-id:3389263415 --> @mcr-ksh commented on GitHub (Oct 10, 2025): evtl related to https://github.com/ollama/ollama/issues/12187
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#54345