ollama tool calling issues #1998

Closed
opened 2026-02-16 17:33:40 -05:00 by yindo · 7 comments
Owner

Originally created by @SkybuckFlying on GitHub (Oct 8, 2025).

Originally assigned to: @rekram1-node on GitHub.

┃ # New session - 2025-10-08T06:46:14.387Z ┃
┃ /share to create a shareable link 3.2K/0% ┃

┃ ┃
┃ hello ┃
┃ skybu (08:46 AM) ┃
┃ ┃

 Hey there! How can I help you today?
 Build gpt-oss:20b (08:46 AM)

┃ ┃
┃ write "hello world" to test.txt ┃
┃ skybu (08:46 AM) ┃
┃ ┃

┃ ┃
┃ Repo_browser.read_file ┃
┃ ┃
┃ The arguments provided to the tool are invalid: Model tried to call unavailable tool 'repo_browser.read_file'. Available tools: ┃
┃ invalid, bash, edit, webfetch, glob, grep, list, read, write, todowrite, todoread, task. ┃
┃ ┃

┃ ┃
┃ Assistant ┃
┃ ┃
┃ The arguments provided to the tool are invalid: Model tried to call unavailable tool 'assistant'. Available tools: invalid, bash, ┃
┃ edit, webfetch, glob, grep, list, read, write, todowrite, todoread, task. ┃
┃ ┃

┃ ┃
┃ List %!s(float64=2) (path=) ┃
┃ ┃
┃ G:\Junk\testopencode/ ┃
┃ ┃
┃ ┃

┃ ┃
┃ Assistant ┃
┃ ┃
┃ The arguments provided to the tool are invalid: Model tried to call unavailable tool 'assistant'. Available tools: invalid, bash, ┃
┃ edit, webfetch, glob, grep, list, read, write, todowrite, todoread, task. ┃
┃ ┃

┃ ┃
┃ Task ┃
┃ ┃
┃ ┃
Hey! I’m not sure what you’re trying to do. Could you let me know the details or what you’d like me to work on?
Build gpt-oss:20b (08:47 AM)


{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "http://localhost:11434/v1"
      },
      "models": {
        "granite4:micro": { "tools": true },
        "gpt-oss:20b": { "tools": true },
        "QWEN14B40KContextWindow:latest": { "tools": true },
        "gemma3:4b": { "tools": true },
        "AI0002:latest": { "tools": true },
        "AI0001:latest": { "tools": true },
        "qwen3:1.7b": { "tools": true },
        "qwen3:14b": { "tools": true },
        "gemma3:12b": { "tools": true },
        "hf.co/bartowski/mistralai_Devstral-Small-2505-GGUF:IQ2_M": { "tools": true },
        "hf.co/bartowski/mistralai_Devstral-Small-2505-GGUF:IQ3_M": { "tools": true },
        "devstral-q3kl:latest": { "tools": true },
        "nomic-embed-text:v1.5": { "tools": true },
        "devstral:latest": { "tools": true },
        "JollyLlama/GLM-4-32B-0414-Q4_K_M:latest": { "tools": true },
        "gemma3:12b-it-qat": { "tools": true },
        "cogito:14b": { "tools": true },
        "deepcoder:latest": { "tools": true },
        "deepseek-r1:671b": { "tools": true },
        "deepseek-r1:1.5b": { "tools": true },
        "deepseek-r1:70b": { "tools": true },
        "deepseek-r1:14b": { "tools": true },
        "deepseek-r1:8b": { "tools": true },
        "deepseek-r1:7b": { "tools": true },
        "deepseek-r1:32b": { "tools": true },
        "llama3.3:latest": { "tools": true },
        "nemotron:latest": { "tools": true },
        "deepseek-coder-v2:16b": { "tools": true },
        "granite3-dense:8b": { "tools": true },
        "starcoder2:15b": { "tools": true },
        "codellama:code": { "tools": true },
        "codellama:latest": { "tools": true },
        "qwen2.5:7b": { "tools": true },
        "gemma2:27b": { "tools": true },
        "phi3:14b": { "tools": true },
        "llama3.2:latest": { "tools": true },
        "llama3.1:latest": { "tools": true },
        "reflection:latest": { "tools": true },
        "codellama:7b-code": { "tools": true }
      }
    }
  }
}

Tried simple version too:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "http://localhost:11434/v1"
      },
      "models": {
        "granite4:micro": {
          "tools": true
        },
        "gpt-oss:20b": {
          "tools": true
        }
      }
    }
  }
}

Originally created by @SkybuckFlying on GitHub (Oct 8, 2025). Originally assigned to: @rekram1-node on GitHub. ┃ # New session - 2025-10-08T06:46:14.387Z ┃ ┃ /share to create a shareable link 3.2K/0% ┃ ┃ ┃ ┃ hello ┃ ┃ skybu (08:46 AM) ┃ ┃ ┃ Hey there! How can I help you today? Build gpt-oss:20b (08:46 AM) ┃ ┃ ┃ write "hello world" to test.txt ┃ ┃ skybu (08:46 AM) ┃ ┃ ┃ ┃ ┃ ┃ Repo_browser.read_file ┃ ┃ ┃ ┃ The arguments provided to the tool are invalid: Model tried to call unavailable tool 'repo_browser.read_file'. Available tools: ┃ ┃ invalid, bash, edit, webfetch, glob, grep, list, read, write, todowrite, todoread, task. ┃ ┃ ┃ ┃ ┃ ┃ Assistant ┃ ┃ ┃ ┃ The arguments provided to the tool are invalid: Model tried to call unavailable tool 'assistant'. Available tools: invalid, bash, ┃ ┃ edit, webfetch, glob, grep, list, read, write, todowrite, todoread, task. ┃ ┃ ┃ ┃ ┃ ┃ List %!s(float64=2) (path=) ┃ ┃ ┃ ┃ G:\Junk\testopencode/ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ Assistant ┃ ┃ ┃ ┃ The arguments provided to the tool are invalid: Model tried to call unavailable tool 'assistant'. Available tools: invalid, bash, ┃ ┃ edit, webfetch, glob, grep, list, read, write, todowrite, todoread, task. ┃ ┃ ┃ ┃ ┃ ┃ Task ┃ ┃ ┃ ┃ ┃ Hey! I’m not sure what you’re trying to do. Could you let me know the details or what you’d like me to work on? Build gpt-oss:20b (08:47 AM) ``` { "$schema": "https://opencode.ai/config.json", "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "http://localhost:11434/v1" }, "models": { "granite4:micro": { "tools": true }, "gpt-oss:20b": { "tools": true }, "QWEN14B40KContextWindow:latest": { "tools": true }, "gemma3:4b": { "tools": true }, "AI0002:latest": { "tools": true }, "AI0001:latest": { "tools": true }, "qwen3:1.7b": { "tools": true }, "qwen3:14b": { "tools": true }, "gemma3:12b": { "tools": true }, "hf.co/bartowski/mistralai_Devstral-Small-2505-GGUF:IQ2_M": { "tools": true }, "hf.co/bartowski/mistralai_Devstral-Small-2505-GGUF:IQ3_M": { "tools": true }, "devstral-q3kl:latest": { "tools": true }, "nomic-embed-text:v1.5": { "tools": true }, "devstral:latest": { "tools": true }, "JollyLlama/GLM-4-32B-0414-Q4_K_M:latest": { "tools": true }, "gemma3:12b-it-qat": { "tools": true }, "cogito:14b": { "tools": true }, "deepcoder:latest": { "tools": true }, "deepseek-r1:671b": { "tools": true }, "deepseek-r1:1.5b": { "tools": true }, "deepseek-r1:70b": { "tools": true }, "deepseek-r1:14b": { "tools": true }, "deepseek-r1:8b": { "tools": true }, "deepseek-r1:7b": { "tools": true }, "deepseek-r1:32b": { "tools": true }, "llama3.3:latest": { "tools": true }, "nemotron:latest": { "tools": true }, "deepseek-coder-v2:16b": { "tools": true }, "granite3-dense:8b": { "tools": true }, "starcoder2:15b": { "tools": true }, "codellama:code": { "tools": true }, "codellama:latest": { "tools": true }, "qwen2.5:7b": { "tools": true }, "gemma2:27b": { "tools": true }, "phi3:14b": { "tools": true }, "llama3.2:latest": { "tools": true }, "llama3.1:latest": { "tools": true }, "reflection:latest": { "tools": true }, "codellama:7b-code": { "tools": true } } } } } Tried simple version too: { "$schema": "https://opencode.ai/config.json", "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "http://localhost:11434/v1" }, "models": { "granite4:micro": { "tools": true }, "gpt-oss:20b": { "tools": true } } } } } ```
yindo closed this issue 2026-02-16 17:33:40 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 8, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #590: Similar issue with write tool not working when using local models (Ollama) - the model returns JSON tool calls but files are not actually written
  • #2144: OpenCode hangs/times out when trying to write files with local models
  • #234: General tool calling issues with open source models, including problems with tool name capitalization and execution failures
  • #1357: Constant failures to use Write/Edit tools with various models, showing invalid tool input errors
  • #1498: Invalid input for tool write errors with missing required parameters

Your issue appears to be related to the common problem of write tool functionality not working properly with local/Ollama models in build mode. The JSON tool call output you're seeing suggests the model is generating tool calls but OpenCode isn't executing them properly.

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Oct 8, 2025): This issue might be a duplicate of existing issues. Please check: - #590: Similar issue with write tool not working when using local models (Ollama) - the model returns JSON tool calls but files are not actually written - #2144: OpenCode hangs/times out when trying to write files with local models - #234: General tool calling issues with open source models, including problems with tool name capitalization and execution failures - #1357: Constant failures to use Write/Edit tools with various models, showing invalid tool input errors - #1498: Invalid input for tool write errors with missing required parameters Your issue appears to be related to the common problem of write tool functionality not working properly with local/Ollama models in build mode. The JSON tool call output you're seeing suggests the model is generating tool calls but OpenCode isn't executing them properly. Feel free to ignore if none of these address your specific case.
Author
Owner

@SkybuckFlying commented on GitHub (Oct 8, 2025):

To reproduce:

  1. Step 1:

ollama list

  1. Step 2:

exit ollama via system tray

  1. step3:

ollama serve

  1. step 4:
    ollama run

  2. step 5:
    opencode

  3. step 6:
    /models

Make sure to setup
config.json
ollama settings in environment variables and settings.

@SkybuckFlying commented on GitHub (Oct 8, 2025): To reproduce: 1. Step 1: ollama list 2. Step 2: exit ollama via system tray 3. step3: ollama serve 4. step 4: ollama run <model name> 5. step 5: opencode 6. step 6: /models <model name> Make sure to setup config.json ollama settings in environment variables and settings.
Author
Owner

@SkybuckFlying commented on GitHub (Oct 8, 2025):

yes
cmd1.exe: ollama list
cmd2.exe ollama serve
cmd3.exe ollama run qwen3etc
cmd4.exe opencode
opencode interacts with ollama http

┃ ┃
┃ write "Hello World" to a textfile called: test.txt in the current folder ┃
┃ skybu (09:32 AM) ┃
┃ ┃

 Okay, the user wants me to write "Hello World" to a text file named test.txt in the current folder. Let me think about how to
 approach this.
 First, I need to check if the current directory is correct. The user mentioned the current folder, so I should make sure that the
 file will be created there. Since the environment is a Windows system (win32), I need to ensure that the path is handled
 correctly, but since it's the current directory, it should be straightforward.

 Next, I should use the write function. The parameters required are filePath and content. The filePath should be "test.txt" in the
 current directory. The content is "Hello World".

 Wait, but the write function requires an absolute path. The current working directory is G:\Junk\testopencode. So the absolute
 path would be G:\Junk\testopencode\test.txt. I need to make sure to use that.

 But the user might not have specified the full path, but since the instruction is to write in the current folder, I can construct
 the absolute path based on the working directory provided in the environment. The working directory is G:\Junk\testopencode, so
 the file path should be G:\Junk\testopencode\test.txt.

 I should use the write function with filePath set to that absolute path and content as "Hello World".

 I need to make sure there's no existing file named test.txt that might cause an overwrite, but the user didn't mention any
 concerns about that, so proceed as instructed.

 So the correct tool call is to use the write function with the absolute file path and the content provided.

┃ ┃
┃ Write G:\Junk\testopencode\test.txt
Okay, the user asked to write "Hello World" to a file called test.txt in the current folder. I need to use the write tool for this.
Let me check the parameters required for the write function. The filePath must be an absolute path. The current working directory
is G:\Junk\testopencode, so the file path should be G:\Junk\testopencode\test.txt. The content is "Hello World". I should make
sure to use the correct parameters. No other tools are needed here since it's a straightforward write operation. Let me construct
the tool call accordingly. Build QWEN14B40KContextWindow:latest (09:35 AM)

I made this model a while ago:

QWEN14B40KContextWindow:latest

Increase it's context window... I used it today and it worked !

I am not sure how I created this model, but maybe this link will help:

https://github.com/p-lemonish/ollama-x-opencode

Maybe ollama now has a new feature to increase context windows without creating new models ?!

@SkybuckFlying commented on GitHub (Oct 8, 2025): yes cmd1.exe: ollama list cmd2.exe ollama serve cmd3.exe ollama run qwen3etc cmd4.exe opencode opencode interacts with ollama http ┃ ┃ ┃ write "Hello World" to a textfile called: test.txt in the current folder ┃ ┃ skybu (09:32 AM) ┃ ┃ ┃ Okay, the user wants me to write "Hello World" to a text file named test.txt in the current folder. Let me think about how to approach this. First, I need to check if the current directory is correct. The user mentioned the current folder, so I should make sure that the file will be created there. Since the environment is a Windows system (win32), I need to ensure that the path is handled correctly, but since it's the current directory, it should be straightforward. Next, I should use the write function. The parameters required are filePath and content. The filePath should be "test.txt" in the current directory. The content is "Hello World". Wait, but the write function requires an absolute path. The current working directory is G:\Junk\testopencode. So the absolute path would be G:\Junk\testopencode\test.txt. I need to make sure to use that. But the user might not have specified the full path, but since the instruction is to write in the current folder, I can construct the absolute path based on the working directory provided in the environment. The working directory is G:\Junk\testopencode, so the file path should be G:\Junk\testopencode\test.txt. I should use the write function with filePath set to that absolute path and content as "Hello World". I need to make sure there's no existing file named test.txt that might cause an overwrite, but the user didn't mention any concerns about that, so proceed as instructed. So the correct tool call is to use the write function with the absolute file path and the content provided. ┃ ┃ ┃ Write G:\Junk\testopencode\test.txt Okay, the user asked to write "Hello World" to a file called test.txt in the current folder. I need to use the write tool for this. Let me check the parameters required for the write function. The filePath must be an absolute path. The current working directory is G:\Junk\testopencode, so the file path should be G:\Junk\testopencode\test.txt. The content is "Hello World". I should make sure to use the correct parameters. No other tools are needed here since it's a straightforward write operation. Let me construct the tool call accordingly. Build QWEN14B40KContextWindow:latest (09:35 AM) I made this model a while ago: QWEN14B40KContextWindow:latest Increase it's context window... I used it today and it worked ! I am not sure how I created this model, but maybe this link will help: https://github.com/p-lemonish/ollama-x-opencode Maybe ollama now has a new feature to increase context windows without creating new models ?!
Author
Owner

@rekram1-node commented on GitHub (Oct 8, 2025):

@SkybuckFlying this is an ollama configuration issue not opencode, either the model is too dumb or it doesn't have enough context.

I can point you in direction of resources for that but this: https://github.com/p-lemonish/ollama-x-opencode generally solved it for most people I've talked with

@rekram1-node commented on GitHub (Oct 8, 2025): @SkybuckFlying this is an ollama configuration issue not opencode, either the model is too dumb or it doesn't have enough context. I can point you in direction of resources for that but this: https://github.com/p-lemonish/ollama-x-opencode generally solved it for most people I've talked with
Author
Owner

@rekram1-node commented on GitHub (Oct 8, 2025):

this issue may be useful: #2362

@rekram1-node commented on GitHub (Oct 8, 2025): this issue may be useful: #2362
Author
Owner

@rekram1-node commented on GitHub (Oct 12, 2025):

closing since this isn't an opencode issue, If you need more help getting your ollama setup for agentic development let me know

@rekram1-node commented on GitHub (Oct 12, 2025): closing since this isn't an opencode issue, If you need more help getting your ollama setup for agentic development let me know
Author
Owner

@DoubleDensity commented on GitHub (Nov 19, 2025):

@SkybuckFlying this is an ollama configuration issue not opencode, either the model is too dumb or it doesn't have enough context.

I can point you in direction of resources for that but this: https://github.com/p-lemonish/ollama-x-opencode generally solved it for most people I've talked with

Thank you! this was very helpful and got me off the ground with tool calling

@DoubleDensity commented on GitHub (Nov 19, 2025): > [@SkybuckFlying](https://github.com/SkybuckFlying) this is an ollama configuration issue not opencode, either the model is too dumb or it doesn't have enough context. > > I can point you in direction of resources for that but this: https://github.com/p-lemonish/ollama-x-opencode generally solved it for most people I've talked with Thank you! this was very helpful and got me off the ground with tool calling
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1998