[GH-ISSUE #7910] tool parsing issues with "'" #5062

Open
opened 2026-04-12 16:09:13 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @fce2 on GitHub (Dec 2, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/7910

What is the issue?

difficult to see in the title: ' is the problem.
when i ask my ai to "execute a python example" it generates something like "print('...')" but truncates at the 1st ':

    "model": "llama3.1:8b-instruct-fp16",
    "created_at": "2024-12-02T13:26:55.1045197Z",
    "message": {
        "role": "assistant",
        "content": "",
        "tool_calls": [
            {
                "function": {
                    "name": "execute_python",
                    "arguments": {
                        "code": "print("
                    }
                }
            }
        ]
    },
    "done_reason": "stop",
    "done": true,
    "total_duration": 574508000,
    "load_duration": 10134500,
    "prompt_eval_count": 1371,
    "prompt_eval_duration": 3000000,
    "eval_count": 18,
    "eval_duration": 559000000

OS

No response

GPU

No response

CPU

No response

Ollama version

No response

Originally created by @fce2 on GitHub (Dec 2, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/7910 ### What is the issue? difficult to see in the title: ' is the problem. when i ask my ai to "execute a python example" it generates something like "print('...')" but truncates at the 1st ': "model": "llama3.1:8b-instruct-fp16", "created_at": "2024-12-02T13:26:55.1045197Z", "message": { "role": "assistant", "content": "", "tool_calls": [ { "function": { "name": "execute_python", "arguments": { "code": "print(" } } } ] }, "done_reason": "stop", "done": true, "total_duration": 574508000, "load_duration": 10134500, "prompt_eval_count": 1371, "prompt_eval_duration": 3000000, "eval_count": 18, "eval_duration": 559000000 ### OS _No response_ ### GPU _No response_ ### CPU _No response_ ### Ollama version _No response_
GiteaMirror added the bug label 2026-04-12 16:09:13 -05:00
Author
Owner

@fce2 commented on GitHub (Dec 2, 2024):

maybe its not the ',my js executor works:

    "model": "llama3.1:8b-instruct-fp16",
    "created_at": "2024-12-02T13:32:11.9342824Z",
    "message": {
        "role": "assistant",
        "content": "",
        "tool_calls": [
            {
                "function": {
                    "name": "execute_javascript",
                    "arguments": {
                        "code": "console.log('Hello World!');"
                    }
                }
            }
        ]
    },
    "done_reason": "stop",
    "done": true,
    "total_duration": 720423100,
    "load_duration": 11974700,
    "prompt_eval_count": 1371,
    "prompt_eval_duration": 242000000,
    "eval_count": 24,
    "eval_duration": 464000000
<!-- gh-comment-id:2511558991 --> @fce2 commented on GitHub (Dec 2, 2024): maybe its not the ',my js executor works: "model": "llama3.1:8b-instruct-fp16", "created_at": "2024-12-02T13:32:11.9342824Z", "message": { "role": "assistant", "content": "", "tool_calls": [ { "function": { "name": "execute_javascript", "arguments": { "code": "console.log('Hello World!');" } } } ] }, "done_reason": "stop", "done": true, "total_duration": 720423100, "load_duration": 11974700, "prompt_eval_count": 1371, "prompt_eval_duration": 242000000, "eval_count": 24, "eval_duration": 464000000
Author
Owner

@fce2 commented on GitHub (Dec 2, 2024):

sorry, looks like its no issue with ollama but with the model i use.
if i rephrade my query it works:

        "role": "assistant",
        "content": "",
        "tool_calls": [
            {
                "function": {
                    "name": "execute_python",
                    "arguments": {
                        "code": "print('Hello World!')"
                    }
                }
            }
        ]
    },
<!-- gh-comment-id:2511571280 --> @fce2 commented on GitHub (Dec 2, 2024): sorry, looks like its no issue with ollama but with the model i use. if i rephrade my query it works: "role": "assistant", "content": "", "tool_calls": [ { "function": { "name": "execute_python", "arguments": { "code": "print('Hello World!')" } } } ] },
Author
Owner

@fce2 commented on GitHub (Dec 2, 2024):

closed

<!-- gh-comment-id:2511618554 --> @fce2 commented on GitHub (Dec 2, 2024): closed
Author
Owner

@fce2 commented on GitHub (Dec 9, 2024):

I have to reopen this issue.
Sometimes (?) the anser is cut when a ' should come

here again:
"model": "llama3.1:8b-instruct-q8_0-32768",
"created_at": "2024-12-09T21:17:54.0578108Z",
"message": {
"role": "assistant",
"content": "",
"tool_calls": [
{
"function": {
"name": "direct_answer",
"arguments": {
"answer": "I don"
}
}
}
]
},

<!-- gh-comment-id:2529506529 --> @fce2 commented on GitHub (Dec 9, 2024): I have to reopen this issue. Sometimes (?) the anser is cut when a ' should come here again: "model": "llama3.1:8b-instruct-q8_0-32768", "created_at": "2024-12-09T21:17:54.0578108Z", "message": { "role": "assistant", "content": "", "tool_calls": [ { "function": { "name": "direct_answer", "arguments": { "answer": "I don" } } } ] },
Author
Owner

@scionaltera commented on GitHub (Apr 19, 2025):

I'm seeing this too, running latest ollama in Docker on Windows 11 with llama 3.2. Every time the model's response to the tool call would contain an apostrophe the response is cut off there. Seems like a JSON parsing issue but I'm not anywhere close to familiar enough with the ollama code yet to identify where. It only happens with tool calls, not regular chat messages.

As an example, I have a tool for storing a "memory" to a database. If the model wanted to store something like "Remember to take Ben's bike to Cub Scouts next Wednesday." the result would just be "Remember to take Ben".

<!-- gh-comment-id:2816905388 --> @scionaltera commented on GitHub (Apr 19, 2025): I'm seeing this too, running latest ollama in Docker on Windows 11 with llama 3.2. Every time the model's response to the tool call would contain an apostrophe the response is cut off there. Seems like a JSON parsing issue but I'm not anywhere close to familiar enough with the ollama code yet to identify where. It only happens with tool calls, not regular chat messages. As an example, I have a tool for storing a "memory" to a database. If the model wanted to store something like "Remember to take Ben's bike to Cub Scouts next Wednesday." the result would just be "Remember to take Ben".
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#5062