Opencode in linux cannot access tools or create files #527

Open
opened 2026-02-16 17:27:10 -05:00 by yindo · 31 comments
Owner

Originally created by @codyseally on GitHub (Jul 6, 2025).

Originally assigned to: @thdxr on GitHub.

I am using opencode with devstral / ollama in ubuntu. Devstral keeps telling me it has no access to files on my computer, and keeps giving me "advice" on how to implement stuff myself. Am I missing some config?

Originally created by @codyseally on GitHub (Jul 6, 2025). Originally assigned to: @thdxr on GitHub. I am using opencode with devstral / ollama in ubuntu. Devstral keeps telling me it has no access to files on my computer, and keeps giving me "advice" on how to implement stuff myself. Am I missing some config?
yindo added the model-problem label 2026-02-16 17:27:10 -05:00
Author
Owner

@JonBoyleCoding commented on GitHub (Jul 6, 2025):

I had the same issue with many ollama models. I wonder whether it's an issue with the models being trained in such a way to not expect file manipulation - but it seemed so commonplace that I wondered otherwise. GPT4 through copilot also had the same issue for me - it wouldn't want to run commands or do anything and then just throw it back to me.

@JonBoyleCoding commented on GitHub (Jul 6, 2025): I had the same issue with many ollama models. I wonder whether it's an issue with the models being trained in such a way to not expect file manipulation - but it seemed so commonplace that I wondered otherwise. GPT4 through copilot also had the same issue for me - it wouldn't want to run commands or do anything and then just throw it back to me.
Author
Owner

@codyseally commented on GitHub (Jul 6, 2025):

No idea, but I was watching THIS GUY showing how he used Devstral with opencode, so I said to give it a try. I get this:

Image

I see that he is not using ollama but Unsloth for getting devstral. The whole point to me was to use local models, otherwise I'm not really interested in another API client.

LE: Tried the exact devstral + ollama setup with aider, works with no problems. The issue is clearly in opencode.

@codyseally commented on GitHub (Jul 6, 2025): No idea, but I was watching [THIS GUY](https://www.youtube.com/watch?v=oSRdjwtKI3E) showing how he used Devstral with opencode, so I said to give it a try. I get this: <img width="1195" height="1507" alt="Image" src="https://github.com/user-attachments/assets/98df540c-99d3-4619-a820-745864191150" /> I see that he is not using ollama but Unsloth for getting devstral. The whole point to me was to use local models, otherwise I'm not really interested in another API client. LE: Tried the exact devstral + ollama setup with aider, works with no problems. The issue is clearly in opencode.
Author
Owner

@JonBoyleCoding commented on GitHub (Jul 6, 2025):

Intriguing - I presume then this is explicitly an ollama issue with opencode. I have been using opencode on some of my open repositories that I don't care about with claude and github copilot and it works fine.

@JonBoyleCoding commented on GitHub (Jul 6, 2025): Intriguing - I presume then this is explicitly an ollama issue with opencode. I have been using opencode on some of my open repositories that I don't care about with claude and github copilot and it works fine.
Author
Owner

@codyseally commented on GitHub (Jul 6, 2025):

It most likely has to do with the way opencode formats tool use. Probably it is incompatible with ollama's tools use api, the same way aider is. I guess the json format in which the llm served with ollama calls a tool is not the expected json for opencode.

Sadly I have to stick to aider, although I really like opencode's interface, but it's useless to me if it does not work with ollama.

@codyseally commented on GitHub (Jul 6, 2025): It most likely has to do with the way opencode formats tool use. Probably it is incompatible with ollama's tools use api, the same way aider is. I guess the json format in which the llm served with ollama calls a tool is not the expected json for opencode. Sadly I have to stick to aider, although I really like opencode's interface, but it's useless to me if it does not work with ollama.
Author
Owner

@KodeMunkie commented on GitHub (Jul 7, 2025):

I'm having the same issue. Qwen 30B (MoE) seems to work well in the likes of Codename Goose, but sadly on opencode (which tbh is much nicer to use) it "thinks" it's unable to write or create any files, which also affects /init

@KodeMunkie commented on GitHub (Jul 7, 2025): I'm having the same issue. Qwen 30B (MoE) seems to work well in the likes of Codename Goose, but sadly on opencode (which tbh is much nicer to use) it "thinks" it's unable to write or create any files, which also affects /init
Author
Owner

@ajunca commented on GitHub (Jul 8, 2025):

I can confirm with the same issue. I will attach an screenshot of running Devstral small 24b Q8 with a context window of 90k.

I also have to say, that in the configuration, the "limit" part is not working, as it defaults to 4k context window ignoring this parameters. I had to create an ollama model with devstral an default 90k context length. This is the config is ignoring the context:

 "models": {
        "devstral-24b-q8-90k:latest": {
          "name": "Devstral small 24b",
          "attachment": true,
          "reasoning": false,
          "temperature": true,
          "tool_call": true,
          "cost": {
            "input": 0,
            "output": 0
          },
          "limit": {
            "context": 32768,
            "output": 8192
          }
        }
      }

So with a 90k window, all input can fit on the LLM, this is the results I'm getting. Devstral knows about the tools, and "calls them", but nothing happens. And in the example, "test.txt" file is not created (nor AGENTS.md).

Image
@ajunca commented on GitHub (Jul 8, 2025): I can confirm with the same issue. I will attach an screenshot of running Devstral small 24b Q8 with a context window of 90k. I also have to say, that in the configuration, the "limit" part is not working, as it defaults to 4k context window ignoring this parameters. I had to create an ollama model with devstral an default 90k context length. This is the config is ignoring the context: ``` "models": { "devstral-24b-q8-90k:latest": { "name": "Devstral small 24b", "attachment": true, "reasoning": false, "temperature": true, "tool_call": true, "cost": { "input": 0, "output": 0 }, "limit": { "context": 32768, "output": 8192 } } } ``` So with a 90k window, all input can fit on the LLM, this is the results I'm getting. Devstral knows about the tools, and "calls them", but nothing happens. And in the example, "test.txt" file is not created (nor AGENTS.md). <img width="765" height="1275" alt="Image" src="https://github.com/user-attachments/assets/fe26c9cf-d5aa-469c-a2f5-3ae2ee39cf0a" />
Author
Owner

@abate commented on GitHub (Jul 9, 2025):

Same same, I've tried with qwen3:8b . I'm not able to run /init successfully and to generate the AGENTS.md file

Also some models out there like gemme3n:latest do not support tools . Maybe we can compile a list of local models compatible with opencode ?

@abate commented on GitHub (Jul 9, 2025): Same same, I've tried with qwen3:8b . I'm not able to run `/init` successfully and to generate the AGENTS.md file Also some models out there like gemme3n:latest do not support `tools` . Maybe we can compile a list of local models compatible with opencode ?
Author
Owner

@adamdotdevin commented on GitHub (Jul 9, 2025):

this is likely an issue with the default system prompt we use. dax is working on custom system prompts per model (and configurable) today.

@adamdotdevin commented on GitHub (Jul 9, 2025): this is likely an issue with the default system prompt we use. dax is working on custom system prompts per model (and configurable) today.
Author
Owner

@codyseally commented on GitHub (Jul 9, 2025):

this is likely an issue with the default system prompt we use. dax is working on custom system prompts per model (and configurable) today.

But would you need a custom prompt per model or a tool-calling prompt that works with Ollama ? My guess is that Ollama has a fixed way in which all models call tools and that just needs to be made compatible with Opencode. Otherwise you would need to design new prompts every time a new model comes out.

@codyseally commented on GitHub (Jul 9, 2025): > this is likely an issue with the default system prompt we use. dax is working on custom system prompts per model (and configurable) today. But would you need a custom prompt per model or a tool-calling prompt that works with Ollama ? My guess is that Ollama has a fixed way in which all models call tools and that just needs to be made compatible with Opencode. Otherwise you would need to design new prompts every time a new model comes out.
Author
Owner

@KodeMunkie commented on GitHub (Jul 9, 2025):

Whatever it is, please avoid if you can, whatever Codename Goose uses.
Goose is hit and miss whether in any one session tooling works without telling it (and reminding) and the massive prompts it have fill up the context (it's 3.6K tokens by default it seems, based on a simple hello prompt and viewing the Ollama logs).

@KodeMunkie commented on GitHub (Jul 9, 2025): Whatever it is, please avoid if you can, whatever Codename Goose uses. Goose is hit and miss whether in any one session tooling works without telling it (and reminding) and the massive prompts it have fill up the context (it's 3.6K tokens by default it seems, based on a simple hello prompt and viewing the Ollama logs).
Author
Owner

@skirmish commented on GitHub (Jul 9, 2025):

Same same, I've tried with qwen3:8b . I'm not able to run /init successfully and to generate the AGENTS.md file

Also some models out there like gemme3n:latest do not support tools . Maybe we can compile a list of local models compatible with opencode ?

I have a short list of ollama models that support tools calls that I have tried to use: mistral:7b, qwen2.5-coder:3b, llama3.2:1b and devstral:24b. When you're looking at the ollama models, you can see which models support tools on the model listing page.

But all of these do not appear to work with opencode with ollama. Looking at the logs from ollama, it does appear to be trying to use tools, but I haven't parsed the logs in any depth to troubleshoot yet.

@skirmish commented on GitHub (Jul 9, 2025): > Same same, I've tried with qwen3:8b . I'm not able to run `/init` successfully and to generate the AGENTS.md file > > Also some models out there like gemme3n:latest do not support `tools` . Maybe we can compile a list of local models compatible with opencode ? I have a short list of ollama models that support tools calls that I have tried to use: `mistral:7b`, `qwen2.5-coder:3b`, `llama3.2:1b` and `devstral:24b`. When you're looking at the ollama models, you can see which models support tools on the model listing page. But all of these do not appear to work with opencode with ollama. Looking at the logs from ollama, it does appear to be trying to use tools, but I haven't parsed the logs in any depth to troubleshoot yet.
Author
Owner

@ahmed-bekhet commented on GitHub (Jul 9, 2025):

I am also facing the same issue, but I noticed something that is not the main issue but may trip people in the future and they wouldn't notice what's happening.

The default context size of ollama is 4096, the context size that you may set in opencode.json doesn't affect that.

I suspect this could also cause the model to not be aware of the tools available to it, if the tool description is part of the system prompt.

When I increased the context size, I started noticing that the model actually attempts to use the tools, before that it was just trying to give me instruction on how to do the things I requested myself.

Here is an example of ollama logs when it received requests from opencode

time=2025-07-07T21:20:16.525Z level=INFO source=server.go:637 msg="llama runner started in 26.06 seconds"
time=2025-07-07T21:20:16.577Z level=WARN source=runner.go:128 msg="truncating input prompt" limit=4096 prompt=9928 keep=5 new=4096
[GIN] 2025/07/07 - 21:20:18 | 200 | 28.558789481s | 172.17.0.3 | POST "/v1/chat/completions"
[GIN] 2025/07/07 - 21:20:21 | 200 | 31.097274311s | 172.17.0.3 | POST "/v1/chat/completions"
time=2025-07-07T21:21:43.390Z level=WARN source=runner.go:128 msg="truncating input prompt" limit=4096 prompt=9954 keep=5 new=4096
[GIN] 2025/07/07 - 21:21:46 | 200 | 2.755439948s | 172.17.0.3 | POST "/v1/chat/completions"
time=2025-07-07T21:21:54.068Z level=WARN source=runner.go:128 msg="truncating input prompt" limit=4096 prompt=9928 keep=5 new=4096
[GIN] 2025/07/07 - 21:21:54 | 200 | 434.072425ms | 172.17.0.3 | POST "/v1/chat/completions"
[GIN] 2025/07/07 - 21:22:02 | 200 | 8.145161783s | 172.17.0.3 | POST "/v1/chat/completions"
time=2025-07-07T21:23:16.578Z level=WARN source=runner.go:128 msg="truncating input prompt" limit=4096 prompt=9789 keep=5 new=4096
[GIN] 2025/07/07 - 21:23:16 | 200 | 105.434536ms | 172.17.0.3 | POST "/v1/chat/completions"
[GIN] 2025/07/07 - 21:23:18 | 200 | 2.352566149s | 172.17.0.3 | POST "/v1/chat/completions"
time=2025-07-07T21:23:59.664Z level=WARN source=runner.go:128 msg="truncating input prompt" limit=4096 prompt=9928 keep=5 new=4096
[GIN] 2025/07/07 - 21:24:00 | 200 | 1.208387214s | 172.17.0.3 | POST "/v1/chat/completions"
[GIN] 2025/07/07 - 21:24:15 | 200 | 15.747611753s | 172.17.0.3 | POST "/v1/chat/completions"
time=2025-07-07T21:28:33.421Z level=WARN source=runner.go:128 msg="truncating input prompt" limit=4096 prompt=9928 keep=5 new=4096
[GIN] 2025/07/07 - 21:28:34 | 200 | 992.314849ms | 172.17.0.3 | POST "/v1/chat/completions"
[GIN] 2025/07/07 - 21:28:42 | 200 | 8.904389371s | 172.17.0.3 | POST "/v1/chat/completions"

The solution I found for that was to create another model in ollama from my main model, you can find instructions for that here:
https://github.com/ollama/ollama/blob/main/docs/modelfile.md

Here is how I setup mine:

Create a file with any name

FROM devstral:24b
PARAMETER num_ctx 131072

Then add these configuration to ollama:

ollama create <new-model-name> -f <path-to-model-file>

Now when you use that new model name in opencode it will no longer run into the issue where it has to truncate the context as easily.

The context size can also be set in the request to ollama and it would be nice if opencode can support that as it will give more flexibility.

@ahmed-bekhet commented on GitHub (Jul 9, 2025): I am also facing the same issue, but I noticed something that is not the main issue but may trip people in the future and they wouldn't notice what's happening. The default context size of ollama is 4096, the context size that you may set in opencode.json doesn't affect that. I suspect this could also cause the model to not be aware of the tools available to it, if the tool description is part of the system prompt. When I increased the context size, I started noticing that the model actually attempts to use the tools, before that it was just trying to give me instruction on how to do the things I requested myself. Here is an example of ollama logs when it received requests from opencode > > time=2025-07-07T21:20:16.525Z level=INFO source=server.go:637 msg="llama runner started in 26.06 seconds" > time=2025-07-07T21:20:16.577Z level=WARN source=runner.go:128 msg="truncating input prompt" limit=4096 prompt=9928 keep=5 new=4096 > [GIN] 2025/07/07 - 21:20:18 | 200 | 28.558789481s | 172.17.0.3 | POST "/v1/chat/completions" > [GIN] 2025/07/07 - 21:20:21 | 200 | 31.097274311s | 172.17.0.3 | POST "/v1/chat/completions" > time=2025-07-07T21:21:43.390Z level=WARN source=runner.go:128 msg="truncating input prompt" limit=4096 prompt=9954 keep=5 new=4096 > [GIN] 2025/07/07 - 21:21:46 | 200 | 2.755439948s | 172.17.0.3 | POST "/v1/chat/completions" > time=2025-07-07T21:21:54.068Z level=WARN source=runner.go:128 msg="truncating input prompt" limit=4096 prompt=9928 keep=5 new=4096 > [GIN] 2025/07/07 - 21:21:54 | 200 | 434.072425ms | 172.17.0.3 | POST "/v1/chat/completions" > [GIN] 2025/07/07 - 21:22:02 | 200 | 8.145161783s | 172.17.0.3 | POST "/v1/chat/completions" > time=2025-07-07T21:23:16.578Z level=WARN source=runner.go:128 msg="truncating input prompt" limit=4096 prompt=9789 keep=5 new=4096 > [GIN] 2025/07/07 - 21:23:16 | 200 | 105.434536ms | 172.17.0.3 | POST "/v1/chat/completions" > [GIN] 2025/07/07 - 21:23:18 | 200 | 2.352566149s | 172.17.0.3 | POST "/v1/chat/completions" > time=2025-07-07T21:23:59.664Z level=WARN source=runner.go:128 msg="truncating input prompt" limit=4096 prompt=9928 keep=5 new=4096 > [GIN] 2025/07/07 - 21:24:00 | 200 | 1.208387214s | 172.17.0.3 | POST "/v1/chat/completions" > [GIN] 2025/07/07 - 21:24:15 | 200 | 15.747611753s | 172.17.0.3 | POST "/v1/chat/completions" > time=2025-07-07T21:28:33.421Z level=WARN source=runner.go:128 msg="truncating input prompt" limit=4096 prompt=9928 keep=5 new=4096 > [GIN] 2025/07/07 - 21:28:34 | 200 | 992.314849ms | 172.17.0.3 | POST "/v1/chat/completions" > [GIN] 2025/07/07 - 21:28:42 | 200 | 8.904389371s | 172.17.0.3 | POST "/v1/chat/completions" The solution I found for that was to create another model in ollama from my main model, you can find instructions for that here: https://github.com/ollama/ollama/blob/main/docs/modelfile.md Here is how I setup mine: Create a file with any name <your-model-file> > FROM devstral:24b > PARAMETER num_ctx 131072 Then add these configuration to ollama: ` ollama create <new-model-name> -f <path-to-model-file> ` Now when you use that new model name in opencode it will no longer run into the issue where it has to truncate the context as easily. The context size can also be set in the request to ollama and it would be nice if opencode can support that as it will give more flexibility.
Author
Owner

@JonBoyleCoding commented on GitHub (Jul 10, 2025):

I had thought the solution would be more technical than just the custom prompts as I've seen people use other backends for similar models and have largely different responses. I hadn't thought to try what @ahmed-bekhet tried. When I have a chance I'll see if I can confirm it works for me.

@JonBoyleCoding commented on GitHub (Jul 10, 2025): I had thought the solution would be more technical than just the custom prompts as I've seen people use other backends for similar models and have largely different responses. I hadn't thought to try what @ahmed-bekhet tried. When I have a chance I'll see if I can confirm it works for me.
Author
Owner

@ahmed-bekhet commented on GitHub (Jul 10, 2025):

I had thought the solution would be more technical than just the custom prompts as I've seen people use other backends for similar models and have largely different responses. I hadn't thought to try what @ahmed-bekhet tried. When I have a chance I'll see if I can confirm it works for me.

Oh, I didn't mean to imply that this fixed the issue, it didn't. It just allows the full context of the "/Init" to be passed on to the model.

Even after receiving the full context and the tools' details it still doesn't really call tools with any consistency. I checked the http traffic and the tool calls weren't there, I played around a little with temperature and with context length and max output tokens, but it didn't really help.

I ended up switching to LM Studio with the exact same LLM and it's working and calling the tools correctly.

@ahmed-bekhet commented on GitHub (Jul 10, 2025): > I had thought the solution would be more technical than just the custom prompts as I've seen people use other backends for similar models and have largely different responses. I hadn't thought to try what [@ahmed-bekhet](https://github.com/ahmed-bekhet) tried. When I have a chance I'll see if I can confirm it works for me. Oh, I didn't mean to imply that this fixed the issue, it didn't. It just allows the full context of the "/Init" to be passed on to the model. Even after receiving the full context and the tools' details it still doesn't really call tools with any consistency. I checked the http traffic and the tool calls weren't there, I played around a little with temperature and with context length and max output tokens, but it didn't really help. I ended up switching to LM Studio with the exact same LLM and it's working and calling the tools correctly.
Author
Owner

@abate commented on GitHub (Jul 14, 2025):

I've tried as well to play around with the suggestions in this thread, but still I can't get it to work with a local ollama model. It's a bit sad. This project looks awesome !

@abate commented on GitHub (Jul 14, 2025): I've tried as well to play around with the suggestions in this thread, but still I can't get it to work with a local ollama model. It's a bit sad. This project looks awesome !
Author
Owner

@jsguy commented on GitHub (Jul 14, 2025):

Yeah same issue here - please fix if you can!

@jsguy commented on GitHub (Jul 14, 2025): Yeah same issue here - please fix if you can!
Author
Owner

@ajunca commented on GitHub (Jul 15, 2025):

I just want to summarize the main points discussed in this issue to make it easier to follow:

  • Configuring the context size for Ollama using the opencode config file doesn’t work — the limit/context field is ignored.
  • The /Init context length is large (or at least larger than Ollama’s default 4k). To pass the full /Init context, you need to create a custom Ollama model with an extended context length (as demonstrated by @ahmed-bekhet).
  • When the model can read the full context, it correctly detects the available tools.
  • However, the model fails to actually call the tools — this appears to be the main issue.
  • As @ahmed-bekhet also pointed out, LM Studio seems to handle this correctly.
@ajunca commented on GitHub (Jul 15, 2025): I just want to summarize the main points discussed in this issue to make it easier to follow: - Configuring the context size for Ollama using the `opencode` config file doesn’t work — the `limit/context` field is ignored. - The `/Init` context length is large (or at least larger than Ollama’s default 4k). To pass the full `/Init` context, you need to create a custom Ollama model with an extended context length (as demonstrated by @ahmed-bekhet). - When the model can read the full context, **it correctly detects the available tools**. - However, **the model fails to actually call the tools** — this appears to be the main issue. - As @ahmed-bekhet also pointed out, LM Studio seems to handle this correctly.
Author
Owner

@pomazanbohdan commented on GitHub (Jul 16, 2025):

Usually, default models in ollama that are supposed to work with tools do not work with them, since their default configuration does not support correct execution.
Therefore, users add models separately where there is a description of how to work with tools
https://ollama.com/search?o=newest&c=tools&q=devstral
https://ollama.com/fomenks/devstral-small_cline_roocode-64k:latest

@pomazanbohdan commented on GitHub (Jul 16, 2025): Usually, default models in ollama that are supposed to work with tools do not work with them, since their default configuration does not support correct execution. Therefore, users add models separately where there is a description of how to work with tools https://ollama.com/search?o=newest&c=tools&q=devstral https://ollama.com/fomenks/devstral-small_cline_roocode-64k:latest
Author
Owner

@ajunca commented on GitHub (Jul 16, 2025):

Tried with:

https://ollama.com/fomenks/devstral-small_cline_roocode-64k:latest
https://ollama.com/antony66/gemma3-tools

With no luck neither. Gemma3-tools is successfully calling tools on another app (browser use).

Devstral-small_cline_rootcode-64k is doing as it calls, but nothing happens:

Image
@ajunca commented on GitHub (Jul 16, 2025): Tried with: [https://ollama.com/fomenks/devstral-small_cline_roocode-64k:latest](https://ollama.com/fomenks/devstral-small_cline_roocode-64k:latest) [https://ollama.com/antony66/gemma3-tools](https://ollama.com/antony66/gemma3-tools) With no luck neither. Gemma3-tools is successfully calling tools on another app (browser use). Devstral-small_cline_rootcode-64k is doing as it calls, but nothing happens: <img width="831" height="483" alt="Image" src="https://github.com/user-attachments/assets/d6aa8c48-9452-4187-8217-3c102961c591" />
Author
Owner

@codyseally commented on GitHub (Jul 16, 2025):

I changed the title of the issue a bit to "cannot access tools or create files" as I see tool calling is clearly the issue. I also have not been able to make any local model work with opencode, either hosted with ollama or lmstudio. They all tell you what to do instead of doing it themselves.

@codyseally commented on GitHub (Jul 16, 2025): I changed the title of the issue a bit to "cannot access tools or create files" as I see tool calling is clearly the issue. I also have not been able to make any local model work with opencode, either hosted with ollama or lmstudio. They all tell you what to do instead of doing it themselves.
Author
Owner

@ajunca commented on GitHub (Jul 17, 2025):

@codyseally Devstral Small 2507 with enough context length is working for me in LMStudio, so the issue here is with Ollama. Check that you have enough context length. If you don't have, you will see on the LMStudio logs something on the line that had to cut the input because was bigger than the context.

Check also the config is okey, for reference, this is mine for LMStudio provider/model:

"lmstudio": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "LM Studio (local)",
      "options": {
        "baseURL": "http://127.0.0.1:1234/v1"
      },
      "models": {
        "mistralai/devstral-small-2507": {
          "name": "Devstral small (LMStudio)"
        }
      }
    }

Also for reference, I've configured the model in LMStudio with this parameters:

  • Model Quantization: Q8_0
  • Context Length: 128000
  • Flash Attention: ON
  • K Cache Quantization Type: Q8_0
  • V Cache Quantization Type: Q8_0

PD: I have 48GB VRAM (two 3090), so if you have 24GB VRAM probably can stretch it to 64000 context length.

@ajunca commented on GitHub (Jul 17, 2025): @codyseally Devstral Small 2507 with enough context length is working for me in LMStudio, so the issue here is with Ollama. Check that you have enough context length. If you don't have, you will see on the LMStudio logs something on the line that had to cut the input because was bigger than the context. Check also the config is okey, for reference, this is mine for LMStudio provider/model: ``` "lmstudio": { "npm": "@ai-sdk/openai-compatible", "name": "LM Studio (local)", "options": { "baseURL": "http://127.0.0.1:1234/v1" }, "models": { "mistralai/devstral-small-2507": { "name": "Devstral small (LMStudio)" } } } ``` Also for reference, I've configured the model in LMStudio with this parameters: - Model Quantization: Q8_0 - Context Length: 128000 - Flash Attention: ON - K Cache Quantization Type: Q8_0 - V Cache Quantization Type: Q8_0 PD: I have 48GB VRAM (two 3090), so if you have 24GB VRAM probably can stretch it to 64000 context length.
Author
Owner

@renich commented on GitHub (Jul 18, 2025):

OK. ollama user here in Fedora 42.

I was looking for this solution for a while. This is why I'm posting it here (and all issues) for all to know:

@p-lemonish discovered why and the fix is easy: https://github.com/p-lemonish/ollama-x-opencode

In short, download a model that has tool capabilities:

$ ollama show granite3.3:8b
  Model
    architecture        granite    
    parameters          8.2B       
    context length      131072     
    embedding length    4096       
    quantization        Q4_K_M     

  Capabilities
    completion    
    tools         

  License
    Apache License               
    Version 2.0, January 2004    
    ...                          

And edit it so that it has a fixed num_ctx:

```terminal
$ ollama run qwen3:latest
>>> /set parameter num_ctx 16384
Set parameter 'num_ctx' to '16384'
>>> /save qwen3:latest
Created new model 'qwen3:latest'
>>> /bye

After that, you're good to go. Just try it out:

opencode run "generate a todo.md file with the contents 'hello world, from me' in it" --model ollama/qwen3:latest

With a bit of luck, your file will be there.

Credits:

Pre-requisites

  • Your model must be downloaded and functional in ollama.
  • You need to configure your model in opencode.json

My configuration looks like this:

{
    "$schema": "https://opencode.ai/config.json",
    "provider": {
        "ollama": {
            "npm": "@ai-sdk/openai-compatible",
            "options": {
                "baseURL": "http://localhost:11434/v1"
            },
            "models": {
                "granite3.3:8b": {
                    "tools": true
                },
                "mistral-small3.2:24b": {
                    "tools": true
                },
                "qwen3:latest": {
                    "tools": true,
                    "reasoning": true
                }
            }
        }
    }
}

Notes

  • granite3.3 still doesn't work.
@renich commented on GitHub (Jul 18, 2025): OK. ollama user here in Fedora 42. I was looking for this solution for a while. This is why I'm posting it here (and all issues) for all to know: @p-lemonish discovered why and the fix is easy: https://github.com/p-lemonish/ollama-x-opencode In short, download a model that has tool capabilities: ```terminal $ ollama show granite3.3:8b Model architecture granite parameters 8.2B context length 131072 embedding length 4096 quantization Q4_K_M Capabilities completion tools License Apache License Version 2.0, January 2004 ... And edit it so that it has a fixed num_ctx: ```terminal $ ollama run qwen3:latest >>> /set parameter num_ctx 16384 Set parameter 'num_ctx' to '16384' >>> /save qwen3:latest Created new model 'qwen3:latest' >>> /bye ``` After that, you're good to go. Just try it out: ``` opencode run "generate a todo.md file with the contents 'hello world, from me' in it" --model ollama/qwen3:latest ``` With a bit of luck, your file will be there. ## Credits: * https://github.com/p-lemonish/ollama-x-opencode ## Pre-requisites * Your model must be downloaded and functional in ollama. * You need to configure your model in opencode.json My configuration looks like this: ```json { "$schema": "https://opencode.ai/config.json", "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "http://localhost:11434/v1" }, "models": { "granite3.3:8b": { "tools": true }, "mistral-small3.2:24b": { "tools": true }, "qwen3:latest": { "tools": true, "reasoning": true } } } } } ``` ## Notes * granite3.3 still doesn't work.
Author
Owner

@renich commented on GitHub (Jul 18, 2025):

Odd, I adjust the num_ctx from openwebui (no need for a config file) and I
still have a problem with a 16384 context length

Try what p-lemonish suggests. Just save the model with the num_ctx set and you'll succeed.

@renich commented on GitHub (Jul 18, 2025): > Odd, I adjust the num_ctx from openwebui (no need for a config file) and I > still have a problem with a 16384 context length > […](#) Try what p-lemonish suggests. Just save the model with the `num_ctx` set and you'll succeed.
Author
Owner

@abate commented on GitHub (Jul 21, 2025):

I confirm that this works !

I noticed this in the ollama logs :

llama_context: n_ctx_per_seq (16384) < n_ctx_train (40960) -- the full capacity of the model will not be utilized

using Qwen3 8B

@abate commented on GitHub (Jul 21, 2025): I confirm that this works ! I noticed this in the ollama logs : ``` llama_context: n_ctx_per_seq (16384) < n_ctx_train (40960) -- the full capacity of the model will not be utilized ``` using Qwen3 8B
Author
Owner

@Sntx626 commented on GitHub (Jul 25, 2025):

I'm replying here, since this is issue has seen the most activity on what I suspect is opencode not properly interpreting ollama tool call responses.

These are issues that seem to share the problem: #234 #526 #590 #1034 #1068
I recommend continuing the discussion here.


$ ollama --version
ollama version is 0.9.6

$ opencode --version
0.3.43
Example Session

Conversation History


User (2025-07-25 11:58:48)

Summarize the project.


Assistant (2025-07-25 11:58:48)

This project is a Rust-based simulation with separate crates for physics and simulator components. The main crate appears to be the executor, which calls into the physics library. The structure suggests that any code running on the GPU should go in the executor crate rather than the physics crate, since this will allow it to remain platform agnostic while still being able to use platform specific optimizations.


User (2025-07-25 12:00:15)

Can you add a README.md?


Assistant (2025-07-25 12:00:15)

[TOOL_CALLS]todowrite[ARGS]{"todos":[{"content":"Add initial README.md file with project overview", "status":"pending", "priority":"high"}]}


User (2025-07-25 12:01:23)

Please analyze this codebase and create an AGENTS.md file containing:

  1. Build/lint/test commands - especially for running a single test
  2. Code style guidelines including imports, formatting, types, naming conventions, error handling, etc.

The file you create will be given to agentic coding agents (such as yourself) that operate in this repository. Make it about 20 lines long.
If there are Cursor rules (in .cursor/rules/ or .cursorrules) or Copilot rules (in .github/copilot-instructions.md), make sure to include them.

If there's already an AGENTS.md, improve it if it's located in /home/sntx/Documents/projects/2025-07-23_stars


Assistant (2025-07-25 12:01:23)

I'll help you create the AGENTS.md file. First, let me search for any existing build/lint/test commands or style guidelines in the repository:[TOOL_CALLS]bash[ARGS]{"command": "cd /home/sntx/Documents/projects/2025-07-23_stars && find . -name "Cargo.toml" -o -name ".cursorrules" -o -name "Makefile" -o -name "*.md" | grep -i -E "(build|lint|test|style|copilot|cursor)"", "description": "Find configuration files that might contain build, lint, test commands or style guidelines"}


User (2025-07-25 12:02:52)

What tools can you call?


Assistant (2025-07-25 12:02:52)

I can use a variety of tools to assist with software engineering tasks, including:

  1. Code Editing and File Operations:

    • Edit: Make precise changes to files
    • Read: View file contents
    • Write: Create new files or overwrite existing ones
  2. Search and Analysis:

    • Grep/Sgrep: Search for specific patterns in the codebase
    • Glob/Rglob/Agrep: Find files by name or pattern
    • Task: Search tool that is useful if you cannot find a match quickly with other tools or are working with an unknown codebase structure
  3. Version Control:

    • Git operations for handling branches, commits, and PRs
    • Bash access for git commands (status, diff, log)
  4. Project Management:

    • TodoWrite/TodoRead: Create and manage task lists
    • Agent: Launch new agents for parallel or complex search tasks
  5. Build and Test Operations:

    • Bash access to run project-specific build/test commands
    • Cargo operations for Rust projects
  6. Documentation and Reference:

    • WebFetch: Retrieve information from URLs if needed for understanding contexts/patterns
    • NotebookRead/Edit (if applicable): Work with code notebooks

User (2025-07-25 12:04:29)

Display the project structure.


Assistant (2025-07-25 12:04:29)

[TOOL_CALLS]bash[ARGS]{"command": "cd /home/sntx/Documents/projects/2025-07-23_stars && ls -la", "description": "List all files and directories in the root folder"}


User (2025-07-25 12:05:26)

Can you also list all relevant subdirs?


Assistant (2025-07-25 12:05:26)

[TOOL_CALLS]bash[ARGS]{"command": "cd /home/sntx/Documents/projects/2025-07-23_stars && find . -type d | grep -v "\.git"", "description": "Find all directories in the repository, excluding .git"}

Devstral Modelfile

I slightly adapted the system prompt to include opencode instead of openhands and reduced the dependence on GitHub.

FROM hf.co/mistralai/Devstral-Small-2507_gguf:Q4_K_M

LICENSE Apache-2.0

PARAMETER num_ctx 131072

SYSTEM """You are Devstral, a helpful agentic model trained by Mistral AI and using the opencode cli and tool calling. You can interact with a computer to solve tasks.

<ROLE>
Your primary role is to assist users by executing commands, modifying code, and solving technical problems effectively. You should be thorough, methodical, and prioritize quality over speed.
* If the user asks a question, like "why is X happening", don't try to fix the problem. Just give an answer to the question.
</ROLE>

<EFFICIENCY>
* Each action you take is somewhat expensive. Wherever possible, combine multiple actions into a single action, e.g. combine multiple bash commands into one, using sed and grep to edit/view multiple files at once.
* When exploring the codebase, use efficient tools like find, grep, and git commands with appropriate filters to minimize unnecessary operations.
</EFFICIENCY>

<FILE_SYSTEM_GUIDELINES>
* When a user provides a file path, do NOT assume it's relative to the current working directory. First explore the file system to locate the file before working on it.
* If asked to edit a file, edit the file directly, rather than creating a new file with a different filename.
* For global search-and-replace operations, consider using `sed` instead of opening file editors multiple times.
</FILE_SYSTEM_GUIDELINES>

<CODE_QUALITY>
* Write clean, efficient code with minimal comments. Avoid redundancy in comments: Do not repeat information that can be easily inferred from the code itself.
* When implementing solutions, focus on making the minimal changes needed to solve the problem.
* Before implementing any changes, first thoroughly understand the codebase through exploration.
* If you are adding a lot of code to a function or file, consider splitting the function or file into smaller pieces when appropriate.
</CODE_QUALITY>

<VERSION_CONTROL>
* Exercise caution with git operations. Do NOT make potentially dangerous changes (e.g., pushing to main, deleting repositories) unless explicitly asked to do so.
* When committing changes, use `git status` to see all modified files, and stage all files necessary for the commit. Use `git commit -a` whenever possible.
* Do NOT commit files that typically shouldn't go into version control (e.g., node_modules/, .env files, build directories, cache files, large binaries) unless explicitly instructed by the user.
* If unsure about committing certain files, check for the presence of .gitignore files or ask the user for clarification.
</VERSION_CONTROL>

<PROBLEM_SOLVING_WORKFLOW>
1. EXPLORATION: Thoroughly explore relevant files and understand the context before proposing solutions
2. ANALYSIS: Consider multiple approaches and select the most promising one
3. TESTING:
   * For bug fixes: Create tests to verify issues before implementing fixes
   * For new features: Consider test-driven development when appropriate
   * If the repository lacks testing infrastructure and implementing tests would require extensive setup, consult with the user before investing time in building testing infrastructure
   * If the environment is not set up to run tests, consult with the user first before investing time to install all dependencies
4. IMPLEMENTATION: Make focused, minimal changes to address the problem
5. VERIFICATION: If the environment is set up to run tests, test your implementation thoroughly, including edge cases. If the environment is not set up to run tests, consult with the user first before investing time to run tests.
</PROBLEM_SOLVING_WORKFLOW>

<SECURITY>
* Only use credentials in ways the user has explicitly requested and would expect.
* Use APIs to work with platforms, unless the user asks otherwise or your task requires browsing.
</SECURITY>

<ENVIRONMENT_SETUP>
* When user asks you to run an application, don't stop if the application is not installed. Instead, add the application to the projects nix-shell, and run the command again through that nix-shell.
* Similarly, if you encounter missing dependencies for essential tools requested by the user, install them when possible.
</ENVIRONMENT_SETUP>

<TROUBLESHOOTING>
* If you've made repeated attempts to solve a problem but tests still fail or the user reports it's still broken:
  1. Step back and reflect on 5-7 different possible sources of the problem
  2. Assess the likelihood of each possible cause
  3. Methodically address the most likely causes, starting with the highest probability
  4. Document your reasoning process
* When you run into any major issue while executing a plan from the user, please don't try to directly work around it. Instead, propose a new plan and confirm with the user before proceeding.
</TROUBLESHOOTING>"""

TEMPLATE """{{- $lastUserIndex := -1 }}
{{- range $index, $_ := .Messages }}
{{- if eq .Role "user" }}{{ $lastUserIndex = $index }}{{ end }}
{{- end }}
{{- range $index, $_ := .Messages }}
{{- if eq .Role "system" }}[SYSTEM_PROMPT]{{ .Content }}[/SYSTEM_PROMPT]
{{- else if eq .Role "user" }}
{{- if and (eq $lastUserIndex $index) $.Tools }}[AVAILABLE_TOOLS]{{ $.Tools }}[/AVAILABLE_TOOLS]
{{- end }}[INST]{{ .Content }}[/INST]
{{- else if eq .Role "assistant" }}
{{- if .Content }}{{ .Content }}
{{- if not (eq (len (slice $.Messages $index)) 1) }}</s>
{{- end }}
{{- else if .ToolCalls }}[TOOL_CALLS][
{{- range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}
{{- end }}]</s>
{{- end }}
{{- else if eq .Role "tool" }}[TOOL_RESULTS]{"content": {{ .Content }}}[/TOOL_RESULTS]
{{- end }}
{{- end }}"""
$XDG_CONFIG_DIR/opencode/config.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "http://10.0.1.1:11434/v1"
      },
      "models": {
        "devstral:24b-small-2507-q4_K_M": {
          "tool_call": true
        },
        "mistral-small3.2:24b": {
          "tool_call": true
        }
      }
    }
  }
}

As we can see from multiple user reports in this issue, the llm often try to call tools1 2 , however I assume opencode fails to parse the tool calls.

@thdxr Does my assumption hold?


Another thing of note is that specifially mistral models follow this cool_calls specification, is that supported by opencode?

@Sntx626 commented on GitHub (Jul 25, 2025): I'm replying here, since this is issue has seen the most activity on what I suspect is opencode not properly interpreting ollama tool call responses. These are issues that seem to share the problem: #234 #526 #590 #1034 #1068 I recommend continuing the discussion here. --- ```sh $ ollama --version ollama version is 0.9.6 $ opencode --version 0.3.43 ``` </details> <details> <summary>Example Session</summary> # Conversation History --- **User** (*2025-07-25 11:58:48*) Summarize the project. --- **Assistant** (*2025-07-25 11:58:48*) This project is a Rust-based simulation with separate crates for physics and simulator components. The main crate appears to be the executor, which calls into the physics library. The structure suggests that any code running on the GPU should go in the `executor` crate rather than the `physics` crate, since this will allow it to remain platform agnostic while still being able to use platform specific optimizations. --- **User** (*2025-07-25 12:00:15*) Can you add a README.md? --- **Assistant** (*2025-07-25 12:00:15*) [TOOL_CALLS]todowrite[ARGS]{"todos":[{"content":"Add initial README.md file with project overview", "status":"pending", "priority":"high"}]} --- **User** (*2025-07-25 12:01:23*) Please analyze this codebase and create an AGENTS.md file containing: 1. Build/lint/test commands - especially for running a single test 2. Code style guidelines including imports, formatting, types, naming conventions, error handling, etc. The file you create will be given to agentic coding agents (such as yourself) that operate in this repository. Make it about 20 lines long. If there are Cursor rules (in .cursor/rules/ or .cursorrules) or Copilot rules (in .github/copilot-instructions.md), make sure to include them. If there's already an AGENTS.md, improve it if it's located in /home/sntx/Documents/projects/2025-07-23_stars --- **Assistant** (*2025-07-25 12:01:23*) I'll help you create the AGENTS.md file. First, let me search for any existing build/lint/test commands or style guidelines in the repository:[TOOL_CALLS]bash[ARGS]{"command": "cd /home/sntx/Documents/projects/2025-07-23_stars && find . -name \"Cargo.toml\" -o -name \".cursorrules\" -o -name \"Makefile\" -o -name \"*.md\" | grep -i -E \"(build|lint|test|style|copilot|cursor)\"", "description": "Find configuration files that might contain build, lint, test commands or style guidelines"} --- **User** (*2025-07-25 12:02:52*) What tools can you call? --- **Assistant** (*2025-07-25 12:02:52*) I can use a variety of tools to assist with software engineering tasks, including: 1. **Code Editing and File Operations**: - Edit: Make precise changes to files - Read: View file contents - Write: Create new files or overwrite existing ones 2. **Search and Analysis**: - Grep/Sgrep: Search for specific patterns in the codebase - Glob/Rglob/Agrep: Find files by name or pattern - Task: Search tool that is useful if you cannot find a match quickly with other tools or are working with an unknown codebase structure 3. **Version Control**: - Git operations for handling branches, commits, and PRs - Bash access for git commands (status, diff, log) 4. **Project Management**: - TodoWrite/TodoRead: Create and manage task lists - Agent: Launch new agents for parallel or complex search tasks 5. **Build and Test Operations**: - Bash access to run project-specific build/test commands - Cargo operations for Rust projects 6. **Documentation and Reference**: - WebFetch: Retrieve information from URLs if needed for understanding contexts/patterns - NotebookRead/Edit (if applicable): Work with code notebooks --- **User** (*2025-07-25 12:04:29*) Display the project structure. --- **Assistant** (*2025-07-25 12:04:29*) [TOOL_CALLS]bash[ARGS]{"command": "cd /home/sntx/Documents/projects/2025-07-23_stars && ls -la", "description": "List all files and directories in the root folder"} --- **User** (*2025-07-25 12:05:26*) Can you also list all relevant subdirs? --- **Assistant** (*2025-07-25 12:05:26*) [TOOL_CALLS]bash[ARGS]{"command": "cd /home/sntx/Documents/projects/2025-07-23_stars && find . -type d | grep -v \"\\.git\"", "description": "Find all directories in the repository, excluding .git"} </details> <details> <summary>Devstral Modelfile</summary> I slightly adapted the system prompt to include opencode instead of openhands and reduced the dependence on GitHub. ```modelfile FROM hf.co/mistralai/Devstral-Small-2507_gguf:Q4_K_M LICENSE Apache-2.0 PARAMETER num_ctx 131072 SYSTEM """You are Devstral, a helpful agentic model trained by Mistral AI and using the opencode cli and tool calling. You can interact with a computer to solve tasks. <ROLE> Your primary role is to assist users by executing commands, modifying code, and solving technical problems effectively. You should be thorough, methodical, and prioritize quality over speed. * If the user asks a question, like "why is X happening", don't try to fix the problem. Just give an answer to the question. </ROLE> <EFFICIENCY> * Each action you take is somewhat expensive. Wherever possible, combine multiple actions into a single action, e.g. combine multiple bash commands into one, using sed and grep to edit/view multiple files at once. * When exploring the codebase, use efficient tools like find, grep, and git commands with appropriate filters to minimize unnecessary operations. </EFFICIENCY> <FILE_SYSTEM_GUIDELINES> * When a user provides a file path, do NOT assume it's relative to the current working directory. First explore the file system to locate the file before working on it. * If asked to edit a file, edit the file directly, rather than creating a new file with a different filename. * For global search-and-replace operations, consider using `sed` instead of opening file editors multiple times. </FILE_SYSTEM_GUIDELINES> <CODE_QUALITY> * Write clean, efficient code with minimal comments. Avoid redundancy in comments: Do not repeat information that can be easily inferred from the code itself. * When implementing solutions, focus on making the minimal changes needed to solve the problem. * Before implementing any changes, first thoroughly understand the codebase through exploration. * If you are adding a lot of code to a function or file, consider splitting the function or file into smaller pieces when appropriate. </CODE_QUALITY> <VERSION_CONTROL> * Exercise caution with git operations. Do NOT make potentially dangerous changes (e.g., pushing to main, deleting repositories) unless explicitly asked to do so. * When committing changes, use `git status` to see all modified files, and stage all files necessary for the commit. Use `git commit -a` whenever possible. * Do NOT commit files that typically shouldn't go into version control (e.g., node_modules/, .env files, build directories, cache files, large binaries) unless explicitly instructed by the user. * If unsure about committing certain files, check for the presence of .gitignore files or ask the user for clarification. </VERSION_CONTROL> <PROBLEM_SOLVING_WORKFLOW> 1. EXPLORATION: Thoroughly explore relevant files and understand the context before proposing solutions 2. ANALYSIS: Consider multiple approaches and select the most promising one 3. TESTING: * For bug fixes: Create tests to verify issues before implementing fixes * For new features: Consider test-driven development when appropriate * If the repository lacks testing infrastructure and implementing tests would require extensive setup, consult with the user before investing time in building testing infrastructure * If the environment is not set up to run tests, consult with the user first before investing time to install all dependencies 4. IMPLEMENTATION: Make focused, minimal changes to address the problem 5. VERIFICATION: If the environment is set up to run tests, test your implementation thoroughly, including edge cases. If the environment is not set up to run tests, consult with the user first before investing time to run tests. </PROBLEM_SOLVING_WORKFLOW> <SECURITY> * Only use credentials in ways the user has explicitly requested and would expect. * Use APIs to work with platforms, unless the user asks otherwise or your task requires browsing. </SECURITY> <ENVIRONMENT_SETUP> * When user asks you to run an application, don't stop if the application is not installed. Instead, add the application to the projects nix-shell, and run the command again through that nix-shell. * Similarly, if you encounter missing dependencies for essential tools requested by the user, install them when possible. </ENVIRONMENT_SETUP> <TROUBLESHOOTING> * If you've made repeated attempts to solve a problem but tests still fail or the user reports it's still broken: 1. Step back and reflect on 5-7 different possible sources of the problem 2. Assess the likelihood of each possible cause 3. Methodically address the most likely causes, starting with the highest probability 4. Document your reasoning process * When you run into any major issue while executing a plan from the user, please don't try to directly work around it. Instead, propose a new plan and confirm with the user before proceeding. </TROUBLESHOOTING>""" TEMPLATE """{{- $lastUserIndex := -1 }} {{- range $index, $_ := .Messages }} {{- if eq .Role "user" }}{{ $lastUserIndex = $index }}{{ end }} {{- end }} {{- range $index, $_ := .Messages }} {{- if eq .Role "system" }}[SYSTEM_PROMPT]{{ .Content }}[/SYSTEM_PROMPT] {{- else if eq .Role "user" }} {{- if and (eq $lastUserIndex $index) $.Tools }}[AVAILABLE_TOOLS]{{ $.Tools }}[/AVAILABLE_TOOLS] {{- end }}[INST]{{ .Content }}[/INST] {{- else if eq .Role "assistant" }} {{- if .Content }}{{ .Content }} {{- if not (eq (len (slice $.Messages $index)) 1) }}</s> {{- end }} {{- else if .ToolCalls }}[TOOL_CALLS][ {{- range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}} {{- end }}]</s> {{- end }} {{- else if eq .Role "tool" }}[TOOL_RESULTS]{"content": {{ .Content }}}[/TOOL_RESULTS] {{- end }} {{- end }}""" ``` </details> <details> <summary>$XDG_CONFIG_DIR/opencode/config.json</summary> ```json { "$schema": "https://opencode.ai/config.json", "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "http://10.0.1.1:11434/v1" }, "models": { "devstral:24b-small-2507-q4_K_M": { "tool_call": true }, "mistral-small3.2:24b": { "tool_call": true } } } } } ``` </details> --- As we can see from multiple user reports in this issue, the llm often try to call tools[^1][^2], however I assume opencode fails to parse the tool calls. @thdxr Does my assumption hold? --- Another thing of note is that specifially mistral models follow [this cool_calls specification](https://mistralai.github.io/mistral-common/code_reference/mistral_common/protocol/instruct/tool_calls/#mistral_common.protocol.instruct.tool_calls.Tool), is that supported by opencode? [^1]: [Example 1](https://private-user-images.githubusercontent.com/7230103/463892520-fe26c9cf-d5aa-469c-a2f5-3ae2ee39cf0a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTM0NDA0MTgsIm5iZiI6MTc1MzQ0MDExOCwicGF0aCI6Ii83MjMwMTAzLzQ2Mzg5MjUyMC1mZTI2YzljZi1kNWFhLTQ2OWMtYTJmNS0zYWUyZWUzOWNmMGEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDcyNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTA3MjVUMTA0MTU4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ODMzMmUxODIwNDhjOTI2MjIwMTA1NTNmYmRjYTc2MDM1NDhmODViMjA0MTU1M2Q2NmQyYmJjZGRjOGVjYTkxMSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.Ldzr6Uq5mBOrUv8dgl6qwnU0I0pxNsqhUsgkvzMNtd8) [^2]: [Example 2](https://private-user-images.githubusercontent.com/7230103/467136427-d6aa8c48-9452-4187-8217-3c102961c591.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTM0NDAzODQsIm5iZiI6MTc1MzQ0MDA4NCwicGF0aCI6Ii83MjMwMTAzLzQ2NzEzNjQyNy1kNmFhOGM0OC05NDUyLTQxODctODIxNy0zYzEwMjk2MWM1OTEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDcyNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTA3MjVUMTA0MTI0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ODFhYWQ2MjE0YmEwNWIyMDRlY2YzZTk0MWM1YWQ2NGU0ZWE1MTA1Y2MxNjExZTFlMWEwYjQ1ZjM3NWIxN2VjYSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.ll37o8GHsLUpoGauInFnYXNadfLNZwfcTad8ZZHcBqI)
Author
Owner

@jaswdr commented on GitHub (Jul 25, 2025):

I had thought the solution would be more technical than just the custom prompts as I've seen people use other backends for similar models and have largely different responses. I hadn't thought to try what @ahmed-bekhet tried. When I have a chance I'll see if I can confirm it works for me.

Oh, I didn't mean to imply that this fixed the issue, it didn't. It just allows the full context of the "/Init" to be passed on to the model.

Even after receiving the full context and the tools' details it still doesn't really call tools with any consistency. I checked the http traffic and the tool calls weren't there, I played around a little with temperature and with context length and max output tokens, but it didn't really help.

I ended up switching to LM Studio with the exact same LLM and it's working and calling the tools correctly.

which models in the end you used with LM Studio that worked?

@jaswdr commented on GitHub (Jul 25, 2025): > > I had thought the solution would be more technical than just the custom prompts as I've seen people use other backends for similar models and have largely different responses. I hadn't thought to try what [@ahmed-bekhet](https://github.com/ahmed-bekhet) tried. When I have a chance I'll see if I can confirm it works for me. > > Oh, I didn't mean to imply that this fixed the issue, it didn't. It just allows the full context of the "/Init" to be passed on to the model. > > Even after receiving the full context and the tools' details it still doesn't really call tools with any consistency. I checked the http traffic and the tool calls weren't there, I played around a little with temperature and with context length and max output tokens, but it didn't really help. > > I ended up switching to LM Studio with the exact same LLM and it's working and calling the tools correctly. which models in the end you used with LM Studio that worked?
Author
Owner

@KodeMunkie commented on GitHub (Jul 27, 2025):

I just wanted to add I'd be interested in knowing what was used in LM Studio that worked.
I've been using hunyuan-a13b-instruct, with a 32768 context length, but it still doesn't work, so the context length is only part of the problem.
It's quite intelligent - it does attempt to call tools (saying it does), no errors are shown, but actually gets confused when it tries to check the directory - for example where it's saved AGENTS.md - and then doesn't find anything, reasoning in so far as suggesting there's a tool bug (if only we could get it to fix it 😆 )

@KodeMunkie commented on GitHub (Jul 27, 2025): I just wanted to add I'd be interested in knowing what was used in LM Studio that worked. I've been using hunyuan-a13b-instruct, with a 32768 context length, but it still doesn't work, so the context length is only part of the problem. It's quite intelligent - it does attempt to call tools (saying it does), no errors are shown, but actually gets confused when it tries to check the directory - for example where it's saved AGENTS.md - and then doesn't find anything, reasoning in so far as suggesting there's a tool bug (if only we could get it to fix it 😆 )
Author
Owner

@ajunca commented on GitHub (Jul 27, 2025):

@KodeMunkie you will find what worked for me in LM Studio in my last entry:

@codyseally Devstral Small 2507 with enough context length is working for me in LMStudio, so the issue here is with Ollama. Check that you have enough context length. If you don't have, you will see on the LMStudio logs something on the line that had to cut the input because was bigger than the context.

Check also the config is okey, for reference, this is mine for LMStudio provider/model:

"lmstudio": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "LM Studio (local)",
      "options": {
        "baseURL": "http://127.0.0.1:1234/v1"
      },
      "models": {
        "mistralai/devstral-small-2507": {
          "name": "Devstral small (LMStudio)"
        }
      }
    }

Also for reference, I've configured the model in LMStudio with this parameters:

* Model Quantization: Q8_0

* Context Length: 128000

* Flash Attention: ON

* K Cache Quantization Type: Q8_0

* V Cache Quantization Type: Q8_0

PD: I have 48GB VRAM (two 3090), so if you have 24GB VRAM probably can stretch it to 64000 context length.

@ajunca commented on GitHub (Jul 27, 2025): @KodeMunkie you will find what worked for me in LM Studio in my last entry: > [@codyseally](https://github.com/codyseally) Devstral Small 2507 with enough context length is working for me in LMStudio, so the issue here is with Ollama. Check that you have enough context length. If you don't have, you will see on the LMStudio logs something on the line that had to cut the input because was bigger than the context. > > Check also the config is okey, for reference, this is mine for LMStudio provider/model: > > ``` > "lmstudio": { > "npm": "@ai-sdk/openai-compatible", > "name": "LM Studio (local)", > "options": { > "baseURL": "http://127.0.0.1:1234/v1" > }, > "models": { > "mistralai/devstral-small-2507": { > "name": "Devstral small (LMStudio)" > } > } > } > ``` > > Also for reference, I've configured the model in LMStudio with this parameters: > > * Model Quantization: Q8_0 > > * Context Length: 128000 > > * Flash Attention: ON > > * K Cache Quantization Type: Q8_0 > > * V Cache Quantization Type: Q8_0 > > > PD: I have 48GB VRAM (two 3090), so if you have 24GB VRAM probably can stretch it to 64000 context length.
Author
Owner

@PilotDevo commented on GitHub (Aug 19, 2025):

The below also worked for me... I still think im going to move away from Ollama and leverage vLLM or something similar and spread across multiple gpu's for better performance/higher context.... just doesn't perform as well for heavier lifting.

OK. ollama user here in Fedora 42.

I was looking for this solution for a while. This is why I'm posting it here (and all issues) for all to know:

@p-lemonish discovered why and the fix is easy: https://github.com/p-lemonish/ollama-x-opencode

In short, download a model that has tool capabilities:

$ ollama show granite3.3:8b
  Model
    architecture        granite    
    parameters          8.2B       
    context length      131072     
    embedding length    4096       
    quantization        Q4_K_M     

  Capabilities
    completion    
    tools         

  License
    Apache License               
    Version 2.0, January 2004    
    ...                          

And edit it so that it has a fixed num_ctx:

```terminal
$ ollama run qwen3:latest
>>> /set parameter num_ctx 16384
Set parameter 'num_ctx' to '16384'
>>> /save qwen3:latest
Created new model 'qwen3:latest'
>>> /bye

After that, you're good to go. Just try it out:

opencode run "generate a todo.md file with the contents 'hello world, from me' in it" --model ollama/qwen3:latest

With a bit of luck, your file will be there.

Credits:

Pre-requisites

  • Your model must be downloaded and functional in ollama.
  • You need to configure your model in opencode.json

My configuration looks like this:

{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ollama": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "http://localhost:11434/v1"
},
"models": {
"granite3.3:8b": {
"tools": true
},
"mistral-small3.2:24b": {
"tools": true
},
"qwen3:latest": {
"tools": true,
"reasoning": true
}
}
}
}
}

Notes

  • granite3.3 still doesn't work.
@PilotDevo commented on GitHub (Aug 19, 2025): The below also worked for me... I still think im going to move away from Ollama and leverage vLLM or something similar and spread across multiple gpu's for better performance/higher context.... just doesn't perform as well for heavier lifting. > OK. ollama user here in Fedora 42. > > I was looking for this solution for a while. This is why I'm posting it here (and all issues) for all to know: > > [@p-lemonish](https://github.com/p-lemonish) discovered why and the fix is easy: https://github.com/p-lemonish/ollama-x-opencode > > In short, download a model that has tool capabilities: > > ``` > $ ollama show granite3.3:8b > Model > architecture granite > parameters 8.2B > context length 131072 > embedding length 4096 > quantization Q4_K_M > > Capabilities > completion > tools > > License > Apache License > Version 2.0, January 2004 > ... > > And edit it so that it has a fixed num_ctx: > > ```terminal > $ ollama run qwen3:latest > >>> /set parameter num_ctx 16384 > Set parameter 'num_ctx' to '16384' > >>> /save qwen3:latest > Created new model 'qwen3:latest' > >>> /bye > ``` > > After that, you're good to go. Just try it out: > > ``` > opencode run "generate a todo.md file with the contents 'hello world, from me' in it" --model ollama/qwen3:latest > ``` > > With a bit of luck, your file will be there. > > ## Credits: > * https://github.com/p-lemonish/ollama-x-opencode > > ## Pre-requisites > * Your model must be downloaded and functional in ollama. > * You need to configure your model in opencode.json > > My configuration looks like this: > > { > "$schema": "https://opencode.ai/config.json", > "provider": { > "ollama": { > "npm": "@ai-sdk/openai-compatible", > "options": { > "baseURL": "http://localhost:11434/v1" > }, > "models": { > "granite3.3:8b": { > "tools": true > }, > "mistral-small3.2:24b": { > "tools": true > }, > "qwen3:latest": { > "tools": true, > "reasoning": true > } > } > } > } > } > ## Notes > * granite3.3 still doesn't work.
Author
Owner

@jasperf commented on GitHub (Nov 17, 2025):

First with Ollama installed qwen3:8B it said it could not write ...Since I can't access the file system.... Then it said the path was not clear though init command gave that. And that with just using basic /init

# New session - 2025-11-17T07:39:36.663Z

**Session ID:** ses_56f3ebaa8ffeTNLrKeKoDE3DP7
**Created:** 11/17/2025, 2:39:36 PM
**Updated:** 11/17/2025, 2:45:40 PM

---

## User

Please analyze this codebase and create an AGENTS.md file containing:
1. Build/lint/test commands - especially for running a single test
2. Code style guidelines including imports, formatting, types, naming conventions, error handling, etc.

The file you create will be given to agentic coding agents (such as yourself) that operate in this repository. Make it about 20 lines long.
If there are Cursor rules (in .cursor/rules/ or .cursorrules) or Copilot rules (in .github/copilot-instructions.md), make sure to include them.

If there's already an AGENTS.md, improve it if it's located in /Users/user/code/site.com

---

## Assistant

.<think>
Okay, the user wants me to analyze the codebase and create an AGENTS.md file. Let me start by understanding the requirements. The file needs to include build, lint, and test commands, especially for running a single test. Also, code style guidelines like imports, formatting, types, naming conventions, error handling, etc. They mentioned including Cursor or Copilot rules if they exist. If there's an existing AGENTS.md in the specified path, I should improve it.

First, I need to check if there's an existing AGENTS.md in /Users/user/code/isite.com. Since I can't access the file system, I'll assume there isn't one or that it's outdated. The user wants me to create or improve it.

Next, build/lint/test commands. Common commands might be npm scripts like build, lint, test. For a single test, maybe a command like npm test -- --file path/to/test.js. I should include those.

Code style guidelines: Imports should be organized, maybe alphabetical. Formatting could be Prettier or ESLint. Types might be TypeScript with @typescript-eslint. Naming conventions: snake_case for variables, camelCase for functions. Error handling with try/catch, specific exceptions.

Check for Cursor rules in .cursor/rules/ or .cursorrules. If there are rules there, include them. Same for Copilot rules in .github/copilot-instructions.md. If those files exist, their content should be added to AGENTS.md.

Now, structure the AGENTS.md. Start with build commands, then lint, test. Then code style sections. Include any existing rules. Keep it around 20 lines. Make sure it's concise but covers all points.

Wait, the user said if there's an existing AGENTS.md, improve it. Since I can't check, maybe include a note about checking for existing files. But since the user provided the path, perhaps they expect the file to be created there. So proceed to create it with the necessary sections.

Also, make sure the file is about 20 lines. Let me outline:

1. Build commands
2. Lint commands
3. Test commands (including single test)
4. Code style guidelines (imports, formatting, types, naming, error handling)
5. Cursor rules
6. Copilot rules

Each section with bullet points. Keep each line concise. Maybe 15-20 lines total.

Check for any specific tools used in the codebase. If it's a Node.js project, npm scripts. If using TypeScript, include TypeScript-specific guidelines. Error handling should mention using specific exceptions and logging.

Include the paths to Cursor and Copilot rules if they exist. If not, maybe mention checking those directories.

Alright, time to put it all together in the AGENTS.md format.
</think>

---

## User

Please analyze this codebase and create an AGENTS.md file containing:
1. Build/lint/test commands - especially for running a single test
2. Code style guidelines including imports, formatting, types, naming conventions, error handling, etc.

The file you create will be given to agentic coding agents (such as yourself) that operate in this repository. Make it about 20 lines long.
If there are Cursor rules (in .cursor/rules/ or .cursorrules) or Copilot rules (in .github/copilot-instructions.md), make sure to include them.

If there's already an AGENTS.md, improve it if it's located in /Users/user/code/site.com

---

## Assistant

Tool: write


---

## Assistant

I need the file path and content to write. Please provide:
1. The specific file path where you want to write
2. The content you want to write to the file

Once I have these details, I can use the write tool properly.

---

my opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama (local)",
      "options": {
        "baseURL": "http://localhost:11434/v1"
      },
      "models": {
        "qwen3:8b": {
          "name": "Qwen3 8B"
        },
        "granite3.1-moe:latest": {
          "name": "Granite 3.1 MoE"
        },
        "qwen3:4b": {
          "name": "Qwen3 4B"
        }
      }
    }
  }
}

and Ollama list

ollama list
NAME                     ID              SIZE      MODIFIED       
qwen3:8b                 500a1f067a9f    5.2 GB    34 minutes ago    
granite3.1-moe:latest    b43d80d7fca7    2.0 GB    2 hours ago       
qwen3:4b                 e55aed6fe643    2.5 GB    2 months ago  

Ollama server logs look fine:

cat ~/.ollama/logs/server.log
...
time=2025-11-17T17:47:15.136+07:00 level=INFO source=sched.go:443 msg="system memory" total="16.0 GiB" free="5.3 GiB" free_swap="0 B"
time=2025-11-17T17:47:15.136+07:00 level=INFO source=sched.go:450 msg="gpu memory" id=0 library=Metal available="10.2 GiB" free="10.7 GiB" minimum="512.0 MiB" overhead="0 B"
time=2025-11-17T17:47:15.136+07:00 level=INFO source=server.go:702 msg="loading model" "model layers"=37 requested=-1
time=2025-11-17T17:47:15.202+07:00 level=INFO source=runner.go:1398 msg="starting ollama engine"
time=2025-11-17T17:47:15.203+07:00 level=INFO source=runner.go:1433 msg="Server listening on 127.0.0.1:59240"
time=2025-11-17T17:47:15.206+07:00 level=INFO source=runner.go:1271 msg=load request="{Operation:fit LoraPath:[] Parallel:1 BatchSize:512 FlashAttention:true KvSize:4096 KvCacheType: NumThreads:8 GPULayers:37[ID:0 Layers:37(0..36)] MultiUserCache:false ProjectorPath: MainGPU:0 UseMmap:false}"
time=2025-11-17T17:47:15.228+07:00 level=INFO source=ggml.go:136 msg="" architecture=qwen3 file_type=Q4_K_M name="Qwen3 8B" description="" num_tensors=399 num_key_values=29
ggml_metal_library_init: using embedded metal library
ggml_metal_library_init: loaded in 0.025 sec
ggml_metal_device_init: GPU name:   Apple M1 Pro
ggml_metal_device_init: GPU family: MTLGPUFamilyApple7  (1007)
ggml_metal_device_init: GPU family: MTLGPUFamilyCommon3 (3003)
ggml_metal_device_init: GPU family: MTLGPUFamilyMetal3  (5001)
ggml_metal_device_init: simdgroup reduction   = true
ggml_metal_device_init: simdgroup matrix mul. = true
ggml_metal_device_init: has unified memory    = true
ggml_metal_device_init: has bfloat            = true
ggml_metal_device_init: use residency sets    = true
ggml_metal_device_init: use shared buffers    = true
ggml_metal_device_init: recommendedMaxWorkingSetSize  = 11453.25 MB
time=2025-11-17T17:47:15.232+07:00 level=INFO source=ggml.go:104 msg=system Metal.0.EMBED_LIBRARY=1 CPU.0.NEON=1 CPU.0.ARM_FMA=1 CPU.0.FP16_VA=1 CPU.0.DOTPROD=1 CPU.0.LLAMAFILE=1 CPU.0.ACCELERATE=1 compiler=cgo(clang)
ggml_metal_init: allocating
ggml_metal_init: picking default device: Apple M1 Pro
ggml_metal_init: use bfloat         = true
ggml_metal_init: use fusion         = true
ggml_metal_init: use concurrency    = true
ggml_metal_init: use graph optimize = true
time=2025-11-17T17:47:15.397+07:00 level=INFO source=runner.go:1271 msg=load request="{Operation:alloc LoraPath:[] Parallel:1 BatchSize:512 FlashAttention:true KvSize:4096 KvCacheType: NumThreads:8 GPULayers:37[ID:0 Layers:37(0..36)] MultiUserCache:false ProjectorPath: MainGPU:0 UseMmap:false}"
time=2025-11-17T17:47:15.507+07:00 level=INFO source=runner.go:1271 msg=load request="{Operation:commit LoraPath:[] Parallel:1 BatchSize:512 FlashAttention:true KvSize:4096 KvCacheType: NumThreads:8 GPULayers:37[ID:0 Layers:37(0..36)] MultiUserCache:false ProjectorPath: MainGPU:0 UseMmap:false}"
time=2025-11-17T17:47:15.508+07:00 level=INFO source=ggml.go:482 msg="offloading 36 repeating layers to GPU"
time=2025-11-17T17:47:15.508+07:00 level=INFO source=ggml.go:489 msg="offloading output layer to GPU"
time=2025-11-17T17:47:15.508+07:00 level=INFO source=ggml.go:494 msg="offloaded 37/37 layers to GPU"
time=2025-11-17T17:47:15.508+07:00 level=INFO source=device.go:240 msg="model weights" device=Metal size="4.5 GiB"
time=2025-11-17T17:47:15.508+07:00 level=INFO source=device.go:245 msg="model weights" device=CPU size="333.8 MiB"
time=2025-11-17T17:47:15.508+07:00 level=INFO source=device.go:251 msg="kv cache" device=Metal size="576.0 MiB"
time=2025-11-17T17:47:15.508+07:00 level=INFO source=device.go:262 msg="compute graph" device=Metal size="100.0 MiB"
time=2025-11-17T17:47:15.508+07:00 level=INFO source=device.go:267 msg="compute graph" device=CPU size="8.0 MiB"
time=2025-11-17T17:47:15.508+07:00 level=INFO source=device.go:272 msg="total memory" size="5.5 GiB"
time=2025-11-17T17:47:15.508+07:00 level=INFO source=sched.go:517 msg="loaded runners" count=1
time=2025-11-17T17:47:15.508+07:00 level=INFO source=server.go:1294 msg="waiting for llama runner to start responding"
time=2025-11-17T17:47:15.510+07:00 level=INFO source=server.go:1328 msg="waiting for server to become available" status="llm server loading model"
time=2025-11-17T17:47:18.534+07:00 level=INFO source=server.go:1332 msg="llama runner started in 3.40 seconds"
[GIN] 2025/11/17 - 17:47:23 | 200 |  8.220514167s |       127.0.0.1 | POST     "/v1/chat/completions"
time=2025-11-17T17:47:23.201+07:00 level=WARN source=runner.go:186 msg="truncating input prompt" limit=4096 prompt=9962 keep=4 new=4096
[GIN] 2025/11/17 - 17:48:33 | 200 |         1m19s |       127.0.0.1 | POST     "/v1/chat/completions"
time=2025-11-17T17:48:34.251+07:00 level=WARN source=runner.go:186 msg="truncating input prompt" limit=4096 prompt=15582 keep=4 new=4096
[GIN] 2025/11/17 - 17:49:15 | 200 | 41.103371958s |       127.0.0.1 | POST     "/v1/chat/completions"

but main issue seems to be

The write tool was called with invalid arguments: [
  {
    "expected": "string",
    "code": "invalid_type",
    "path": [
      "filePath"
    ],
    "message": "Invalid input: expected string, received undefined"
  }
].
Please rewrite the input so it satisfies the expected schema.

and feedback is

The error indicates that the filePath parameter is missing when using the write tool. Please provide both the file path and the content you want to write, like this:

Write to "example.txt":
Hello, world!

Once you provide these details, I'll format the tool call correctly.

Update

Did manage to do do some basic tasks with Qhen 8B 16K context and Open Code. Was able to create a file with basic todo list. The /init command still fails, also when file AGENTS.md existts . Keep on complaining it is a binary file. Added details to https://github.com/imagewize/ollama-opencode-setup . Not done testing yet, but progress

@jasperf commented on GitHub (Nov 17, 2025): First with Ollama installed qwen3:8B it said it could not write `...Since I can't access the file system...`. Then it said the path was not clear though init command gave that. And that with just using basic `/init` ```sh # New session - 2025-11-17T07:39:36.663Z **Session ID:** ses_56f3ebaa8ffeTNLrKeKoDE3DP7 **Created:** 11/17/2025, 2:39:36 PM **Updated:** 11/17/2025, 2:45:40 PM --- ## User Please analyze this codebase and create an AGENTS.md file containing: 1. Build/lint/test commands - especially for running a single test 2. Code style guidelines including imports, formatting, types, naming conventions, error handling, etc. The file you create will be given to agentic coding agents (such as yourself) that operate in this repository. Make it about 20 lines long. If there are Cursor rules (in .cursor/rules/ or .cursorrules) or Copilot rules (in .github/copilot-instructions.md), make sure to include them. If there's already an AGENTS.md, improve it if it's located in /Users/user/code/site.com --- ## Assistant .<think> Okay, the user wants me to analyze the codebase and create an AGENTS.md file. Let me start by understanding the requirements. The file needs to include build, lint, and test commands, especially for running a single test. Also, code style guidelines like imports, formatting, types, naming conventions, error handling, etc. They mentioned including Cursor or Copilot rules if they exist. If there's an existing AGENTS.md in the specified path, I should improve it. First, I need to check if there's an existing AGENTS.md in /Users/user/code/isite.com. Since I can't access the file system, I'll assume there isn't one or that it's outdated. The user wants me to create or improve it. Next, build/lint/test commands. Common commands might be npm scripts like build, lint, test. For a single test, maybe a command like npm test -- --file path/to/test.js. I should include those. Code style guidelines: Imports should be organized, maybe alphabetical. Formatting could be Prettier or ESLint. Types might be TypeScript with @typescript-eslint. Naming conventions: snake_case for variables, camelCase for functions. Error handling with try/catch, specific exceptions. Check for Cursor rules in .cursor/rules/ or .cursorrules. If there are rules there, include them. Same for Copilot rules in .github/copilot-instructions.md. If those files exist, their content should be added to AGENTS.md. Now, structure the AGENTS.md. Start with build commands, then lint, test. Then code style sections. Include any existing rules. Keep it around 20 lines. Make sure it's concise but covers all points. Wait, the user said if there's an existing AGENTS.md, improve it. Since I can't check, maybe include a note about checking for existing files. But since the user provided the path, perhaps they expect the file to be created there. So proceed to create it with the necessary sections. Also, make sure the file is about 20 lines. Let me outline: 1. Build commands 2. Lint commands 3. Test commands (including single test) 4. Code style guidelines (imports, formatting, types, naming, error handling) 5. Cursor rules 6. Copilot rules Each section with bullet points. Keep each line concise. Maybe 15-20 lines total. Check for any specific tools used in the codebase. If it's a Node.js project, npm scripts. If using TypeScript, include TypeScript-specific guidelines. Error handling should mention using specific exceptions and logging. Include the paths to Cursor and Copilot rules if they exist. If not, maybe mention checking those directories. Alright, time to put it all together in the AGENTS.md format. </think> --- ## User Please analyze this codebase and create an AGENTS.md file containing: 1. Build/lint/test commands - especially for running a single test 2. Code style guidelines including imports, formatting, types, naming conventions, error handling, etc. The file you create will be given to agentic coding agents (such as yourself) that operate in this repository. Make it about 20 lines long. If there are Cursor rules (in .cursor/rules/ or .cursorrules) or Copilot rules (in .github/copilot-instructions.md), make sure to include them. If there's already an AGENTS.md, improve it if it's located in /Users/user/code/site.com --- ## Assistant ``` Tool: write ``` --- ## Assistant I need the file path and content to write. Please provide: 1. The specific file path where you want to write 2. The content you want to write to the file Once I have these details, I can use the write tool properly. --- ``` my `opencode.json`: ```json { "$schema": "https://opencode.ai/config.json", "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "name": "Ollama (local)", "options": { "baseURL": "http://localhost:11434/v1" }, "models": { "qwen3:8b": { "name": "Qwen3 8B" }, "granite3.1-moe:latest": { "name": "Granite 3.1 MoE" }, "qwen3:4b": { "name": "Qwen3 4B" } } } } } ``` and Ollama list ```sh ollama list NAME ID SIZE MODIFIED qwen3:8b 500a1f067a9f 5.2 GB 34 minutes ago granite3.1-moe:latest b43d80d7fca7 2.0 GB 2 hours ago qwen3:4b e55aed6fe643 2.5 GB 2 months ago ``` Ollama server logs look fine: ```sh cat ~/.ollama/logs/server.log ... time=2025-11-17T17:47:15.136+07:00 level=INFO source=sched.go:443 msg="system memory" total="16.0 GiB" free="5.3 GiB" free_swap="0 B" time=2025-11-17T17:47:15.136+07:00 level=INFO source=sched.go:450 msg="gpu memory" id=0 library=Metal available="10.2 GiB" free="10.7 GiB" minimum="512.0 MiB" overhead="0 B" time=2025-11-17T17:47:15.136+07:00 level=INFO source=server.go:702 msg="loading model" "model layers"=37 requested=-1 time=2025-11-17T17:47:15.202+07:00 level=INFO source=runner.go:1398 msg="starting ollama engine" time=2025-11-17T17:47:15.203+07:00 level=INFO source=runner.go:1433 msg="Server listening on 127.0.0.1:59240" time=2025-11-17T17:47:15.206+07:00 level=INFO source=runner.go:1271 msg=load request="{Operation:fit LoraPath:[] Parallel:1 BatchSize:512 FlashAttention:true KvSize:4096 KvCacheType: NumThreads:8 GPULayers:37[ID:0 Layers:37(0..36)] MultiUserCache:false ProjectorPath: MainGPU:0 UseMmap:false}" time=2025-11-17T17:47:15.228+07:00 level=INFO source=ggml.go:136 msg="" architecture=qwen3 file_type=Q4_K_M name="Qwen3 8B" description="" num_tensors=399 num_key_values=29 ggml_metal_library_init: using embedded metal library ggml_metal_library_init: loaded in 0.025 sec ggml_metal_device_init: GPU name: Apple M1 Pro ggml_metal_device_init: GPU family: MTLGPUFamilyApple7 (1007) ggml_metal_device_init: GPU family: MTLGPUFamilyCommon3 (3003) ggml_metal_device_init: GPU family: MTLGPUFamilyMetal3 (5001) ggml_metal_device_init: simdgroup reduction = true ggml_metal_device_init: simdgroup matrix mul. = true ggml_metal_device_init: has unified memory = true ggml_metal_device_init: has bfloat = true ggml_metal_device_init: use residency sets = true ggml_metal_device_init: use shared buffers = true ggml_metal_device_init: recommendedMaxWorkingSetSize = 11453.25 MB time=2025-11-17T17:47:15.232+07:00 level=INFO source=ggml.go:104 msg=system Metal.0.EMBED_LIBRARY=1 CPU.0.NEON=1 CPU.0.ARM_FMA=1 CPU.0.FP16_VA=1 CPU.0.DOTPROD=1 CPU.0.LLAMAFILE=1 CPU.0.ACCELERATE=1 compiler=cgo(clang) ggml_metal_init: allocating ggml_metal_init: picking default device: Apple M1 Pro ggml_metal_init: use bfloat = true ggml_metal_init: use fusion = true ggml_metal_init: use concurrency = true ggml_metal_init: use graph optimize = true time=2025-11-17T17:47:15.397+07:00 level=INFO source=runner.go:1271 msg=load request="{Operation:alloc LoraPath:[] Parallel:1 BatchSize:512 FlashAttention:true KvSize:4096 KvCacheType: NumThreads:8 GPULayers:37[ID:0 Layers:37(0..36)] MultiUserCache:false ProjectorPath: MainGPU:0 UseMmap:false}" time=2025-11-17T17:47:15.507+07:00 level=INFO source=runner.go:1271 msg=load request="{Operation:commit LoraPath:[] Parallel:1 BatchSize:512 FlashAttention:true KvSize:4096 KvCacheType: NumThreads:8 GPULayers:37[ID:0 Layers:37(0..36)] MultiUserCache:false ProjectorPath: MainGPU:0 UseMmap:false}" time=2025-11-17T17:47:15.508+07:00 level=INFO source=ggml.go:482 msg="offloading 36 repeating layers to GPU" time=2025-11-17T17:47:15.508+07:00 level=INFO source=ggml.go:489 msg="offloading output layer to GPU" time=2025-11-17T17:47:15.508+07:00 level=INFO source=ggml.go:494 msg="offloaded 37/37 layers to GPU" time=2025-11-17T17:47:15.508+07:00 level=INFO source=device.go:240 msg="model weights" device=Metal size="4.5 GiB" time=2025-11-17T17:47:15.508+07:00 level=INFO source=device.go:245 msg="model weights" device=CPU size="333.8 MiB" time=2025-11-17T17:47:15.508+07:00 level=INFO source=device.go:251 msg="kv cache" device=Metal size="576.0 MiB" time=2025-11-17T17:47:15.508+07:00 level=INFO source=device.go:262 msg="compute graph" device=Metal size="100.0 MiB" time=2025-11-17T17:47:15.508+07:00 level=INFO source=device.go:267 msg="compute graph" device=CPU size="8.0 MiB" time=2025-11-17T17:47:15.508+07:00 level=INFO source=device.go:272 msg="total memory" size="5.5 GiB" time=2025-11-17T17:47:15.508+07:00 level=INFO source=sched.go:517 msg="loaded runners" count=1 time=2025-11-17T17:47:15.508+07:00 level=INFO source=server.go:1294 msg="waiting for llama runner to start responding" time=2025-11-17T17:47:15.510+07:00 level=INFO source=server.go:1328 msg="waiting for server to become available" status="llm server loading model" time=2025-11-17T17:47:18.534+07:00 level=INFO source=server.go:1332 msg="llama runner started in 3.40 seconds" [GIN] 2025/11/17 - 17:47:23 | 200 | 8.220514167s | 127.0.0.1 | POST "/v1/chat/completions" time=2025-11-17T17:47:23.201+07:00 level=WARN source=runner.go:186 msg="truncating input prompt" limit=4096 prompt=9962 keep=4 new=4096 [GIN] 2025/11/17 - 17:48:33 | 200 | 1m19s | 127.0.0.1 | POST "/v1/chat/completions" time=2025-11-17T17:48:34.251+07:00 level=WARN source=runner.go:186 msg="truncating input prompt" limit=4096 prompt=15582 keep=4 new=4096 [GIN] 2025/11/17 - 17:49:15 | 200 | 41.103371958s | 127.0.0.1 | POST "/v1/chat/completions" ``` but main issue seems to be ```json The write tool was called with invalid arguments: [ { "expected": "string", "code": "invalid_type", "path": [ "filePath" ], "message": "Invalid input: expected string, received undefined" } ]. Please rewrite the input so it satisfies the expected schema. ``` and feedback is > The error indicates that the `filePath` parameter is missing when using the write tool. Please provide both the file path and the content you want to write, like this: ``` Write to "example.txt": Hello, world! ``` > Once you provide these details, I'll format the tool call correctly. ### Update Did manage to do do some basic tasks with Qhen 8B 16K context and Open Code. Was able to create a file with basic todo list. The `/init` command still fails, also when file `AGENTS.md` existts . Keep on complaining it is a binary file. Added details to https://github.com/imagewize/ollama-opencode-setup . Not done testing yet, but progress
Author
Owner

@Digital-Yeti commented on GitHub (Jan 16, 2026):

I have successfully gotten devstral-small-2:latest to perform the /init command and create the agents.md file. I set the num_ctx parameter to 40960, using the method discussed earlier, and saved the model. Just increasing the context window seems to have resolved the lack of tool calling for me, at least for this model. I am unsure how much VRAM is required for this but it works on my 24GB 3090.

@Digital-Yeti commented on GitHub (Jan 16, 2026): I have successfully gotten `devstral-small-2:latest` to perform the `/init` command and create the agents.md file. I set the num_ctx parameter to 40960, using the method discussed earlier, and saved the model. Just increasing the context window seems to have resolved the lack of tool calling for me, at least for this model. I am unsure how much VRAM is required for this but it works on my 24GB 3090.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#527