[GH-ISSUE #12776] Tool calls not working with huihui_ai/kimi-k2:1026b #54987

Closed
opened 2026-04-29 08:07:10 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @spullara on GitHub (Oct 24, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/12776

What is the issue?

It appears it hasn't been setup for this?

First, let me write the C source file:<|reserved_token_163595|><|reserved_token_163597|>functions.write_file:0<|reserved_token_163598|>{"filename": "test.c", "contents": "#include <stdio.h>\n\nint main() {\n    printf(\"Hello, world!\\n\");\n    return 0;\n}"}<|reserved_token_163599|><|reserved_token_163596|>

Here is the request:

{
  "max_tokens" : 128000,
  "messages" : [ {
    "content" : "Current datetime: Fri Oct 24 22:31:47 UTC 2025\nOperating system: Linux\nCurrent directory:/home/ubuntu/scriptagent\nCurrent user: ubuntu\nYou are an agent that executes tool calls. You do not chat with the user.\nUse the complete tool to communicate with the user when you are finished\n\nWrite Hello, world! in a file called test.c. Compile it. Run it. Delete it.\n",
    "role" : "user"
  } ],
  "tool_choice" : "required",
  "model" : "huihui_ai/kimi-k2:latest",
  "tools" : [ {
    "function" : {
      "name" : "exec",
      "description" : "Executes a shell command and returns its output",
      "parameters" : {
        "type" : "object",
        "properties" : {
          "command" : {
            "description" : "The command to execute appropriate for operating system",
            "type" : "string"
          }
        },
        "required" : [ "command" ]
      }
    },
    "type" : "function"
  }, {
    "function" : {
      "name" : "write_file",
      "description" : "Writes a file with the given contents",
      "parameters" : {
        "type" : "object",
        "properties" : {
          "filename" : {
            "description" : "The filename of the file to write",
            "type" : "string"
          },
          "contents" : {
            "description" : "The contents of the file",
            "type" : "string"
          },
          "append" : {
            "description" : "Whether to append to the file",
            "type" : "boolean"
          }
        },
        "required" : [ "filename", "contents" ]
      }
    },
    "type" : "function"
  }, {
    "function" : {
      "name" : "complete",
      "description" : "Complete the script execution with a result or error. You must do this. This tool is how the user will see any output from the task.",
      "parameters" : {
        "type" : "object",
        "properties" : {
          "result" : {
            "description" : "The final result or error message",
            "type" : "string"
          }
        },
        "required" : [ "result" ]
      }
    },
    "type" : "function"
  } ]
}

Response:

{
  "id" : "chatcmpl-459",
  "object" : "chat.completion",
  "created" : 1761345123,
  "model" : "huihui_ai/kimi-k2:latest",
  "system_fingerprint" : "fp_ollama",
  "choices" : [ {
    "index" : 0,
    "message" : {
      "role" : "assistant",
      "content" : "I'll help you write, compile, run, and delete a C program called test.c. Let me work through this step by step.\n\nFirst, let me write the C source file:<|reserved_token_163595|><|reserved_token_163597|>functions.write_file:0<|reserved_token_163598|>{\"filename\": \"test.c\", \"contents\": \"#include <stdio.h>\\n\\nint main() {\\n    printf(\\\"Hello, world!\\\\n\\\");\\n    return 0;\\n}\"}<|reserved_token_163599|><|reserved_token_163596|>"
    },
    "finish_reason" : "stop"
  } ],
  "usage" : {
    "prompt_tokens" : 321,
    "completion_tokens" : 91,
    "total_tokens" : 412
  }
}

Relevant log output


OS

Linux

GPU

No response

CPU

No response

Ollama version

No response

Originally created by @spullara on GitHub (Oct 24, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/12776 ### What is the issue? It appears it hasn't been setup for this? ``` First, let me write the C source file:<|reserved_token_163595|><|reserved_token_163597|>functions.write_file:0<|reserved_token_163598|>{"filename": "test.c", "contents": "#include <stdio.h>\n\nint main() {\n printf(\"Hello, world!\\n\");\n return 0;\n}"}<|reserved_token_163599|><|reserved_token_163596|> ``` Here is the request: ```json { "max_tokens" : 128000, "messages" : [ { "content" : "Current datetime: Fri Oct 24 22:31:47 UTC 2025\nOperating system: Linux\nCurrent directory:/home/ubuntu/scriptagent\nCurrent user: ubuntu\nYou are an agent that executes tool calls. You do not chat with the user.\nUse the complete tool to communicate with the user when you are finished\n\nWrite Hello, world! in a file called test.c. Compile it. Run it. Delete it.\n", "role" : "user" } ], "tool_choice" : "required", "model" : "huihui_ai/kimi-k2:latest", "tools" : [ { "function" : { "name" : "exec", "description" : "Executes a shell command and returns its output", "parameters" : { "type" : "object", "properties" : { "command" : { "description" : "The command to execute appropriate for operating system", "type" : "string" } }, "required" : [ "command" ] } }, "type" : "function" }, { "function" : { "name" : "write_file", "description" : "Writes a file with the given contents", "parameters" : { "type" : "object", "properties" : { "filename" : { "description" : "The filename of the file to write", "type" : "string" }, "contents" : { "description" : "The contents of the file", "type" : "string" }, "append" : { "description" : "Whether to append to the file", "type" : "boolean" } }, "required" : [ "filename", "contents" ] } }, "type" : "function" }, { "function" : { "name" : "complete", "description" : "Complete the script execution with a result or error. You must do this. This tool is how the user will see any output from the task.", "parameters" : { "type" : "object", "properties" : { "result" : { "description" : "The final result or error message", "type" : "string" } }, "required" : [ "result" ] } }, "type" : "function" } ] } ``` Response: ```json { "id" : "chatcmpl-459", "object" : "chat.completion", "created" : 1761345123, "model" : "huihui_ai/kimi-k2:latest", "system_fingerprint" : "fp_ollama", "choices" : [ { "index" : 0, "message" : { "role" : "assistant", "content" : "I'll help you write, compile, run, and delete a C program called test.c. Let me work through this step by step.\n\nFirst, let me write the C source file:<|reserved_token_163595|><|reserved_token_163597|>functions.write_file:0<|reserved_token_163598|>{\"filename\": \"test.c\", \"contents\": \"#include <stdio.h>\\n\\nint main() {\\n printf(\\\"Hello, world!\\\\n\\\");\\n return 0;\\n}\"}<|reserved_token_163599|><|reserved_token_163596|>" }, "finish_reason" : "stop" } ], "usage" : { "prompt_tokens" : 321, "completion_tokens" : 91, "total_tokens" : 412 } } ``` ### Relevant log output ```shell ``` ### OS Linux ### GPU _No response_ ### CPU _No response_ ### Ollama version _No response_
GiteaMirror added the bug label 2026-04-29 08:07:10 -05:00
Author
Owner

@rick-github commented on GitHub (Oct 24, 2025):

The template doesn't specify how to handle tool calls, so ollama can only return content, not tool_calls.

<!-- gh-comment-id:3445166852 --> @rick-github commented on GitHub (Oct 24, 2025): The [template](https://ollama.com/huihui_ai/kimi-k2:latest/blobs/25445adecbdc) doesn't specify how to handle tool calls, so ollama can only return `content`, not `tool_calls`.
Author
Owner

@pdevine commented on GitHub (Oct 25, 2025):

Unfortunately this model isn't maintained by ollama, so going to close the issue.

<!-- gh-comment-id:3446994567 --> @pdevine commented on GitHub (Oct 25, 2025): Unfortunately this model isn't maintained by ollama, so going to close the issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#54987