Skip to content

Integration with Ollama Local #19948

Closed as not planned
Closed as not planned

Description

@TheTwinEsper

Description

Bug Report: Ollama local model not working in OpenCode Desktop

Description

When using OpenCode Desktop application (Windows), after configuring a local Ollama model, the model appears in the list but returns invalid JSON responses ({ "name": "skill", "arguments": { "name": "build" } }) instead of actual text responses.

Environment

  • OpenCode version: 1.2.27
  • Operating System: Windows
  • Ollama version: Running locally on port 11434
  • Model: DanyaVoredom/DanyAI-qwen2.5-coder-3b-instruct:latest

Steps to Reproduce

  1. Install OpenCode Desktop for Windows
  2. Download a model in Ollama (e.g., ollama run DanyaVoredom/DanyAI-qwen2.5-coder-3b-instruct)
  3. Configure opencode.json with Ollama provider:
    {
      "provider": {
        "ollama": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "Ollama (local)",
          "options": {
            "baseURL": "http://localhost:11434/v1"
          },
          "models": {
            "DanyaVoredom/DanyAI-qwen2.5-coder-3b-instruct:latest": {
              "name": "DanyAI Coder 3B",
              "_launch": true
            }
          }
        }
      }
    }
  4. Open OpenCode Desktop
  5. Select the Ollama model from the model list
  6. Send a prompt

Expected Behavior

The model should return a normal text response.

Actual Behavior

The model returns invalid JSON: { "name": "skill", "arguments": { "name": "build" } }

Verification

  • Ollama API works correctly (tested via curl)
  • The same configuration works with OpenCode CLI (terminal version)
  • This appears to be a bug specific to the OpenCode Desktop application

Additional Information

Screenshots

N/A

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. github-actions commented on Mar 29, 2026

    @github-actions
    Contributor

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

    If your issue is distinct from the above, please clarify how it differs. Otherwise, consider adding your details there instead.

  2. cdvankammen commented on Apr 29, 2026

    @cdvankammen

    Again I am confused.....why is there not a "Ollama local" and or an "Custom OpenAI" option in opencode? during the provider setup there are no local options that allow for confignureing a local ip addresss form what i have been able to find

  3. removed
    bugSomething isn't working
    webRelates to opencode on web / desktop
    on May 3, 2026
  4. Hello-World-Traveler commented on May 3, 2026

    @Hello-World-Traveler

    I have had same issue { "name": "skill", "arguments": { "name": "build" } } it's something to do with the model however I haven't got this working with Ollama, only using the free models, Opencode started to work.

    Recommended by Ollama                                                           
        gemma4                                                                        
          Reasoning and code generation locally, ~12GB           
        qwen3.5                                                                       
          Reasoning, coding, and visual understanding locally, ~14GB
    

    Integration with Ollama Locally would be nice.

  5. kunningKing11 commented on May 4, 2026

    @kunningKing11

    @Brendonovich will Ollama Local be added as a model provider option? LM Studio already is.

  6. marekmalczewski commented on May 19, 2026

    @marekmalczewski

    I confirm. For Ollama na LM Studio provider result is simillar. Models are not able to run tools:
    Image

  7. jclsn commented on May 20, 2026

    @jclsn

    I don't see the issue here. My local ollama connection works just fine. Problem is that the local models cannot run tools, but the ollama cloud models can for some reason.

    My local gemma4 model is not able to use tools and repeatedly asks me what to do. The cloud models works. I also have to add that the cloud model is served via an ollama instance on the same host (my server) and the local gemma runs on my desktop's larger GPU.

    Image

    Both are configured the same way

    {
      "$schema": "https://opencode.ai/config.json",
      "permission": {
        "edit": "allow",
        "bash": "allow",
        "webfetch": "allow",
        "question": "allow",
        "read": "allow",
        "glob": "allow",
        "write": "allow",
        "task": "allow",
        "todowrite": "allow",
      },
      "provider": {
        "ollama-nas": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "NAS",
          "options": {
            "baseURL": "http://127.0.0.1:11434/v1"
          },
          "models": {
            "gemma4:31b-cloud": {
              "name": "gemma4:31b-cloud",
              "tools": true
            },
          }
        },
        "ollama-desktop": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "Desktop",
          "options": {
            "baseURL": "http://192.168.184.117:11434/v1"
          },
          "models": {
            "gemma4:latest": {
              "name": "gemma4:latest",
              "tools": true
            },
          }
        }
    
      }
    }
  8. kunningKing11 commented on May 20, 2026

    @kunningKing11

    I don't see the issue here. My local ollama connection works just fine. Problem is that the local models cannot run tools, but the ollama cloud models can for some reason.

    My local gemma4 model is not able to use tools and repeatedly asks me what to do. The cloud models works. I also have to add that the cloud model is served via an ollama instance on the same host (my server) and the local gemma runs on my desktop's larger GPU.

    Image

    The problem is that it is less user-friendly to have to edit the json config file and also the secondary issue is the tool calls.

  9. jclsn commented on May 20, 2026

    @jclsn

    @kunningKing11 Yeah, it's really weird with the tools calls. I mean why would the cloud models run and not the local ones. They are served by the same API.

    I tried verifying if the problem lies in the ollama instance on another machine by adding a cloud model. Again, the cloud model on my desktop works, the local one doesn't

    Image
  10. 2 remaining items

  11. jaredmontoya commented on Jun 20, 2026

    @jaredmontoya

    It seems to me that because of the official opencode docs everyone is trying to use the OpenAI compatible API with ollama.
    Unfortunately the Ollama OpenAI compatible api does not support setting context via a parameter like num_ctx that is available on the official Ollama API.
    So if you use opencode with the openai compatible api and don't want to set a global context size value that is not model specific or don't want to wrap every model with a modelfile to set proper context size for each model, you will get the default ollama value that for most people will be 4096 tokens.

    I personally use ollama-ai-provider-v2 currently:

    {
      "$schema": "https://opencode.ai/config.json",
    
      "provider": {
        "ollama": {
          "models": {
            "gemma4:12b-it-qat": {
              "id": "gemma4:12b-it-qat",
              "limit": {
                "context": 194560,
                "output": 32768
              },
              "name": "gemma4:12b-it-qat",
              "options": {
                "options": {
                  "keep_alive": "10m",
                  "num_ctx": 194560
                },
                "think": true
              },
              "tool_call": true
            }
          },
          "name": "Ollama",
          "npm": "ollama-ai-provider-v2",
          "options": {
            "baseURL": "http://localhost:11434/api"
          }
        }
      }
    }

    because it lets me set the model context size, without this feature local models are useless in opencode.
    I did not test this idea but I assume the default value for cloud ollama models is full context and not just measly 4096 so that's probably why @jclsn experienced the difference between them.

    While ollama-ai-provider-v2 is kind of working, I noticed some quirks so it might not be the best solution and I assume that https://github.com/jagreehal/ai-sdk-ollama would probably be better, but I can't use it because I was not able to figure out how to make it send num_ctx by configuring it through opencode. If anyone figures out how to, please post the config here too.

  12. jclsn commented on Jun 21, 2026

    @jclsn

    @jaredmontoya Tried that, but with local models I am only getting one token as response, whereas remote models work well. Tried your settings on and no context settings. Always the same thing.

  13. zejjnt commented on Jul 6, 2026

    @zejjnt

    It's unfathomable to me that this issue has been brought up multiple times over more than a year, issues are closed because of duplicate other issues that have not been addressed. Do the devs not care at all about their repo or what is even going on here?
    Every other thing, no matter what it is, works flawlessly with http://localhost:11434 but not opencode - which is the most commonly recommended IDE for vibe coding. What.

  14. nextgenthemes commented on Jul 6, 2026

    @nextgenthemes

    Apparently not, it's a shame that this thing calls it "opencode" is extremely popular but only cares to send all your shit to the big datacenters and does not let you do it the most open source and private way of running open source models locally.

    However, opencode is not an IDE.

  15. jaredmontoya commented on Jul 6, 2026

    @jaredmontoya

    To be fair, Ollama also isn't perfect, they don't seem to want to add support for Ollama specific options in their OpenAI compatible API. It would be way easier for everyone if the OpenAI API was the default for inference and the Ollama model management API was either a separate thing or an extension to the OpenAI API. Anytime something that is good for most people isn't merged into a project without a sane justification I assume that it's either incompetence/ignorance or malice and both are bad. This is why I am currently evaluating whether it is worth it for me to move from Ollama to llama.cpp + llama-swap which unlike Ollama are both excellent open source citizens.

  16. nextgenthemes commented on Jul 6, 2026

    @nextgenthemes

    Why cares if Ollama is perfect? How is this an excuse? Opencode supports Ollama cloud but not local? It can be THAT complicated to get some basics going it does not have to be the most perfect integration possible. It just needs to work, and then it can go from there.

    And yes its always easy to complain, we should get on it to fix it, but would a PR even get pulled. The people who make this finance it by getting paid by companies who want specific things. CLEARLY this is not on the list.

  17. jaredmontoya commented on Jul 6, 2026

    @jaredmontoya

    Didn't know they supported Ollama Cloud 😂. This does make it worse indeed.

  18. jaredmontoya commented on Jul 6, 2026

    @jaredmontoya
  19. zejjnt commented on Jul 6, 2026

    @zejjnt

    But I still think Ollama is just bad actually, this post kind of opened my eyes on ollama, I did notice those things before but didn't know that I could get rid of Ollama until I found out about llama-swap: https://sleepingrobots.com/dreams/stop-using-ollama/ Especially this section and this one

    I mean... Every single model is bad if you want to get really anal about it because it is simply immoral to train off of other people's work. IMO, of course.

    Apparently not, it's a shame that this thing calls it "opencode" is extremely popular but only cares to send all your shit to the big datacenters and does not let you do it the most open source and private way of running open source models locally.

    However, opencode is not an IDE.

    Heh, you're absolutely correct, I wasn't even remotely using that term properly. Thanks for making me laugh for some reason.

  20. jaredmontoya commented on Jul 6, 2026

    @jaredmontoya

    I mean... Every single model is bad if you want to get really anal about it because it is simply immoral to train off of other people's work. IMO, of course.

    I think you are misunderstanding something, I dgaf if the model was trained on baby cries. Also we are talking about Ollama vs Llama.cpp which are inference engines and not models so what you said is completely irrelevant. Go and actually read the The Modelfile: Reinventing a Solved Problem and The Registry Bottleneck sections and if you like them then might as well read The Fork That Made Things Worse, Misleading Model Naming and The Cloud Pivot. The rest of the arguments in the post also hold some weight but these are about "design decisions" and manifestations of conflicts of interest that directly and tangibly affect users of Ollama.

  21. zejjnt commented on Jul 6, 2026

    @zejjnt

    I mean... Every single model is bad if you want to get really anal about it because it is simply immoral to train off of other people's work. IMO, of course.

    I think you are misunderstanding something, I dgaf if the model was trained on baby cries. Also we are talking about Ollama vs Llama.cpp which are inference engines and not models so what you said is completely irrelevant. Go and actually read the The Modelfile: Reinventing a Solved Problem and The Registry Bottleneck sections and if you like them then might as well read The Fork That Made Things Worse, Misleading Model Naming and The Cloud Pivot. The rest of the arguments in the post also hold some weight but these are about "design decisions" and manifestations of conflicts of interest that directly and tangibly affect users of Ollama.

    I read it, I was just pointing out a similar issue from the broader perspective. If you want to have an internet slapfight you can find someone else to partner with.

  22. jaredmontoya commented on Jul 6, 2026

    @jaredmontoya

    I read it, I was just pointing out a similar issue from the broader perspective. If you want to have an internet slapfight you can find someone else to partner with.

    I don't know where you see a slapfight, I just couldn't understand why your response seems to not be about what I said at all. Your first message was about model training ethical issues which were not mentioned at all in the post that I linked, so I said that it was irrelevant to what I linked and told you to read it again because I assumed that you didn't read the exact sections I mentioned because how could you not see that it is not about ethical issues of model training.

    If you just wanted to comment on how people are mad about AI then you shouldn't have quoted my comment as if you are replying to it because your message seems like a response to me saying: "I think X model is bad because it was trained on other peoples's work" which is obviously far from what I said.

  23. github-actions commented on Sep 5, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  24. nextgenthemes commented on Sep 5, 2026

    @nextgenthemes

    OK I not remember what was the exact issue but I think it may be just down the model you use. I think this may come down to just using a model that support tool calls correctly. Qwen3.6 does.

    I use ramalama now instead of ollama and it works fine with opencode

    		"ramalama": {
    			"npm": "@ai-sdk/openai-compatible",
    			"name": "Ramalama (local)",
    			"options": {
    				"baseURL": "http://localhost:8088/v1"
    			},
    			"models": {
    				"unsloth/Qwen3.6-35B-A3B-GGUF/Qwen3.6-35B-A3B-UD-Q3_K_S": {
    					"name": "unsloth Qwen3.6-35B-A3B-UD-Q3_K_S",
    					"limit": {
    						"context": 131072,
    						"output": 32768
    					}
    				},
    			}
    		}
    

    however, even though on paper this model I can run on my 9070 XT seems pretty great, I have not tried but using the actual full context would slow it down too much. Free models like Big Pickle are already better than the best coding model I can run. Spend (wasted) a lot of time optimizing all kinds of parameters before I realized how good free models are in comparison.

    If course you always pay with your data if you use a remote model. Its kind of sad that we are at a point that free models get you better results then what you can run locally on a pretty expensive consumer GPU but I guess that is where we are.

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