Skip to content

ollama tool calling issues #3029

Closed
Closed

Description

@SkybuckFlying

┃ # 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
        }
      }
    }
  }
}

Activity

  1. github-actions commented on Oct 8, 2025

    @github-actions
    Contributor

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

    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.

  2. SkybuckFlying commented on Oct 8, 2025

    @SkybuckFlying
    Author

    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.

  3. SkybuckFlying commented on Oct 8, 2025

    @SkybuckFlying
    Author

    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 ?!

  4. rekram1-node commented on Oct 8, 2025

    @rekram1-node
    Contributor

    @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

  5. changed the title [-]write "hello world" to test.txt not working on windows 11. (is in build mode, file manipulation in plan mode would be usefull too !!!!!!!!!!!!!!!)[/-] [+]ollama tool calling issues[/+] on Oct 8, 2025
  6. rekram1-node commented on Oct 8, 2025

    @rekram1-node
    Contributor

    this issue may be useful: #2362

  7. self-assigned this
    on Oct 8, 2025
  8. rekram1-node commented on Oct 12, 2025

    @rekram1-node
    Contributor

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

  9. DoubleDensity commented on Nov 19, 2025

    @DoubleDensity

    @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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions