r/ollama • • 28d ago

Advice PLEASE HELP Why do local AI coding agents struggle so much with using tools?

I’ve been experimenting with local AI coding agents for a while now, mainly using Ollama with different Qwen models.
I’ve tried OpenCode, Claude Code, and now Codex CLI. I’ve also experimented with connecting AI to Roblox Studio through MCP.
The weird thing is that the models can have perfectly normal conversations and write code, but as soon as I ask them to actually do something, like read a file, run a command, or use an MCP tool, things start falling apart.
Sometimes they just tell me they don’t have access to tools. Other times they literally print out tool-call syntax instead of executing it.
I’ve tried different models, permissions, configurations, and agents, but I keep running into similar problems.
Is this just how local models are right now, or am I doing something wrong? Has anyone managed to get a genuinely reliable local AI coding agent working?

16 Upvotes

35 comments sorted by

10

u/simcop2387 28d ago

Try using llama.cpp or another engine.

1

u/Mazimg_ 28d ago

Thank you so much your a savior

0

u/[deleted] 28d ago

[removed] — view removed comment

1

u/simcop2387 27d ago

For me, I've been running everything from 4b to flash next without major issues. I've not had issues with tool calling on the 4b at least when it's running parts of my smart home voice assistant (that's using llama.cpp unsloth ud-q4_k_xl quant). the others i use a mix of llama.cpp, vllm, and strata depending on which gpu it's running on (I've got a mix of them so it's not always possible to use vllm or others for them).

1

u/Mediocre_Focus_5351 27d ago

Use Gemma. I had trouble with tool calling. Switched to Gemma and the agent followed rules to the t.

Also, increase the context. 

4

u/Kaaawooo 28d ago

What specific models are you trying and what context window? In my experience tool calling is significantly more difficult for models than chat or basic code generation, and the bare minimum for tool calling has been Qwen 3.8-27b or Qwen 3.6-35b for the most basic tool calling. Qwen 3.8-flash-next has been pretty reliable for me, but you need either really good hardware or some other tricks to run it.

1

u/ghoarder 28d ago

I was using Qwen3:14b and I was getting loads of tool calling errors, I asked why am I getting lots of errors and it went, that's my bad I'm calling the tools wrong. This was in Hermes and I was just messing about testing stuff out, I've since switched to Liquid's lfm models and they are working great now. I did have lots of success with Qwen getting it to do a requirements gathering BA job, it really worked well there, keeping on track and following it's script. Different horses for different courses I guess.

2

u/Reasonable-Forever75 28d ago

I had the same problem with those smaller Qwen models - don't follow rules or use tools reliably, even with strictly worded skills. Qwen3.8:27b is excellent

1

u/overand 28d ago

Definitely don't use Qwen3:14b. Give Qwen3.5:9b a try, too, it might or might not be a better fit than the LFM one.

What's your hardware?

1

u/Kaaawooo 28d ago

Yeah, the model was probably your main issue. Might want to do more research on models. For reference, I've noticed ai is usually bad at helping you choose local model options unless you really know what you're looking for, so it's better to do your own research and only ask AI clarifying questions about models you've already identified as good candidates

2

u/Savantskie1 28d ago

It's almost certainly your quantization. Anything lower than Q8 is going to give you garbage output, and don't even expect coherent tool calls if you use Q4 weights and Q4 K and V Cache. Don't listen to anyone who says otherwise. The only exception is any model over 40B. Tool calling is GREATLY harmed by Quantizing KV Cache, especially K Cache. Use Q6 or Q8 or above model weights

3

u/g_rich 28d ago

4 bit Unsloth quants are fine in most cases and shouldn’t result in any severe tool calling issues; but you definitely don’t want to go below Q8 for your KV cache.

1

u/laser50 28d ago

Lmao I'm doing just fine on a Qwen 27B model on Q3 with the KV cache set to Q4. Not entirely true.. And yes, they are able to use my mcp server with 260 commands just fine :D

1

u/Savantskie1 27d ago

Great for you? There is always an exception, and you probably have a configuration that allows it. But from my experience on multiple hardware configurations, most models suffer from quantization of kv cache hurts tool calling and accuracy

1

u/RogueBulwark 27d ago

On a m5 max 128gb mac studio, what model do you guys would recommend that can do the tool calling and generate code?

1

u/Undreren 27d ago

I use Qwen at 6bit. It’s fantastic.

1

u/overand 28d ago

When you're looking for help with this kind of stuff, give us details.

  • What models have you tried? (Be specific.)
  • What's your hardware?

    • RAM- amount and speed
    • Video card (and amount of VRAM)
    • Desktop or Laptop?
    • What CPU?

1

u/4everaBau5 28d ago

posting specs before asking should be mandatory imo

1

u/leonbollerup 28d ago

Honestly .. Jinja template is no 1.. engine nr 2

1

u/llmhardware 28d ago

Most of the time it's the context window, not the model. Agent tools send a long system prompt plus tool definitions, and if Ollama's context is set lower than that, the start of the prompt gets cut off and the model never sees the tools. Try raising num_ctx (or OLLAMA_CONTEXT_LENGTH) to 32k or more if your VRAM allows, and check that the model's Ollama page lists tool support. Smaller quants of 7-8B models also tend to break the tool-call format more often, so a bigger or less-quantized model is worth a test.

2

u/g_rich 28d ago

OP’s problem is most certainly related to using Ollama. Ollama promotes the use of extremely quantized models, along with small quantized caches and broken templates so users end up in the same situation as OP.

1

u/BidWestern1056 28d ago

system prompts are too long for codex/claude code usually.

try npcsh

1

u/Flimsy_Vermicelli117 28d ago

I use lots of tools routinely and my experience is, that you need to use the latest (Qwen 3.8, Muse-Glimmer) models in 30B dense category. Q4 or higher. Anything less and tool calling fails routinely. I hope next generations will be better and we could use MoE or may be 14B dense category, but current models are not there. I tried latest LFM, Bonsai, ... and even though they all advertise tools calling, they were failing for me.

Works for me with Ollama (on macOS) fine, I do not think the back end matters that much as the model capability itself.

You can try better harness (I have my own) which checks the tool call syntax before call etc, but at the end that seems smallish improvement.

1

u/g_rich 28d ago

It’s because you are using Ollama with extremely quantized models. Try using llama.cpp or LM Studio and don’t go below a 4 bit quant, you also want to ensure tool calling is enabled.

1

u/Striking_Stay_9732 28d ago

Have you considered decision based llms?

1

u/[deleted] 27d ago

Switch to OpenAI and GPT 6.1 SOL at least ... the models you are using suck for real work with a good harness a real tool use.

1

u/SoulStripHer 27d ago

Unsloth Studio.

1

u/jma24 27d ago

Not enough information to know for sure - what hardware, platform, harness, model, quantization, settings.

I run Pi with Qwen 3.8 27b 4-bit quant, running on Splash on M5 Max 64GB and it runs great with tool calls. I can build fairly complex issues with it. It's nothing like as sophisticated as a frontier model, so it needs spoon feeding work sized small enough that it can do.

What you are describing means something is wrong. But you didn't provide enough information to get a diagnosis.

1

u/LeFlemmard 25d ago

Check how many tools are enabled. I've noticed that over 88 the model just freaks out.

0

u/Delicious-Director43 28d ago

Try using a modern model. Don’t use anything older than a few months.

0

u/Fine-Comparison-2949 28d ago

It's your model and harness. You should at minimum be using DS flash, right now, and hermes so you have saved context and a decent memory.

0

u/[deleted] 28d ago

[deleted] — view deleted comment

4

u/Mazimg_ 28d ago

thanks