Local LLM Tool Calls Printed, Not Run? Check Context
A local assistant is not reliable because it sounds smart. It is reliable when every write, save, update, and tool call can be validated outside the model.
Jump to 10 sections
- The core rule
- Your agent prints the tool call but nothing happens
- Claude Code shows “API error, retrying” with a local model
- Why small local assistants fail
- The reliable local assistant architecture
- Minimal schema pattern
- Quantization test before you trust the model
- Guardrails that matter more than prompt wording
- Hardware advice for assistants
- Next steps
Trying to run a Telegram, voice, project-management, or life-management assistant locally? Check whether your model can fit at a reliable quant before designing the rails.
Check local assistant setupThe core rule
Do not let the model be the source of truth.
For a local assistant, the model should propose an action. Your application should decide whether that action is valid, execute it, verify it, and then report the result.
If the model says “saved” before the database, filesystem, calendar, or task API proves it, the assistant is lying by architecture.
Your agent prints the tool call but nothing happens
Symptoms: the model writes </tool_call: write_file> or [write: Create hello.txt] as plain text, says a file was created when it was not, or forgets your previous message. Check these in order.
1. Check the context length first. Ollama picks the default from your VRAM. Under 24 GiB you get 4k, 24 to 48 GiB gets 32k, and 48 GiB or more gets 256k. Ollama says coding tools and agents should have at least 64,000 tokens (context length docs). A 16 GB graphics card therefore starts at 4k.
OLLAMA_CONTEXT_LENGTH=64000 ollama serve ollama ps # read the CONTEXT and PROCESSOR columns
If the Ollama app already runs the server, change the context slider in its settings instead. A longer context needs more memory. If PROCESSOR shows a CPU share, the model now spills into system RAM and runs slower. Check the fit at 64K before you pick a model. One CloudYeti viewer on a 32 GB M1 Max reported that OLLAMA_CONTEXT_LENGTH=65536 made file creation work, but very slowly. That is one report, not our test.
2. Test the model without the agent. Send one request with one tool:
curl -s http://localhost:11434/api/chat -d '{
"model": "YOUR_MODEL", "stream": false,
"messages": [{"role": "user", "content": "What is the temperature in New York?"}],
"tools": [{"type": "function", "function": {"name": "get_temperature",
"description": "Get the current temperature for a city",
"parameters": {"type": "object", "required": ["city"],
"properties": {"city": {"type": "string"}}}}}]
}'
A working reply has a message.tool_calls field. If the call arrives as text inside message.content, change the model or its chat template before you debug the agent. If tool_calls is there, test the agent: ask it to create hello.txt, then run cat hello.txt yourself.
3. Set the context in the agent too. OpenCode requires 64k or higher (Ollama’s OpenCode page). In Cline, set the Context Window field to at least 32K (Ollama’s Cline page). So a small model that chats well in ollama run can still fail in OpenCode: a short chat fits in 4k and an agent session does not. ollama launch opencode and ollama launch claude set up the connection.
4. Using llama-server? Tool use needs Jinja templates. Current llama.cpp turns --jinja on by default, so check that nothing passes --no-jinja. If the model’s template has no tool support, pass a correct one with --chat-template-file (function calling docs).
Claude Code shows “API error, retrying” with a local model
Claude Code retries transient failures up to 10 times (error reference), so the retry counter hides the real error. Point it at Ollama like this (Ollama’s Claude Code page):
export ANTHROPIC_AUTH_TOKEN=ollama export ANTHROPIC_API_KEY="" export ANTHROPIC_BASE_URL=http://localhost:11434 claude --model YOUR_MODEL
The base URL has no /v1 at the end. Use the exact model name from ollama list. Then call the endpoint directly:
curl -s http://localhost:11434/v1/messages \
-H "content-type: application/json" -H "anthropic-version: 2023-06-01" \
-d '{"model": "YOUR_MODEL", "max_tokens": 64,
"messages": [{"role": "user", "content": "Say hi"}]}'
If this fails, the message names the server problem; read the Ollama server log. If it works and Claude Code still retries, note your claude --version, ollama --version, model name and the server log line. Ollama supports only part of the Anthropic API, and its compatibility page lists what is missing.
Why small local assistants fail
Small models are attractive because they fit on 8GB VRAM and can run quickly alongside Whisper, a Telegram bot, or a local web UI. The failure mode is not usually raw conversation quality. It is operational correctness.
Common failures:
- drops a tool call
- emits malformed JSON
- picks the wrong task for “mark that one done”
- invents a save confirmation
- truncates arguments after a long prompt
- burns tokens in reasoning mode and returns no usable content
- handles obvious references but fails ambiguous references
The fix is not always “use a bigger model.” Bigger models can spill out of VRAM, run slowly, and still mishandle references without a better control layer.
The reliable local assistant architecture
Use this shape:
- Intent extraction. Convert the user message into a proposed operation.
- Schema validation. Reject malformed or underspecified arguments.
- Clarification gate. Ask a follow-up when the target is ambiguous.
- Write-ahead log. Record the requested mutation before executing it.
- Tool execution. Perform the save/update/delete outside the model.
- Readback verification. Query the target system to prove the result exists.
- Confirmation. Only now tell the user what happened.
This is boring engineering. That is the point.
Minimal schema pattern
For a task assistant, avoid free-form tool payloads. Use constrained objects:
{
"action": "create_task | update_task | complete_task | log_note | ask_clarification",
"target_id": "string or null",
"title": "string or null",
"body": "string or null",
"confidence": 0.0,
"clarification_question": "string or null"
}
Rules:
- If
confidenceis low, do not mutate state. - If
target_idis missing for an update/delete, ask a clarification question. - If the output does not validate, retry once with the validation error.
- If it fails twice, fall back to manual confirmation.
Ollama supports tool calling and structured outputs, but you still need application-level validation. Schema support reduces failure rate; it does not remove the need to verify writes.
Quantization test before you trust the model
For strict JSON, test the exact quant you will run daily.
Small models are more likely to lose formatting reliability at low precision because they have less redundancy. A 4B or 12B model that seems fine in chat can fail structured output at Q4 or Q6.
Test matrix:
| Model size | Test first | Fall back to |
|---|---|---|
| 1B to 4B | Q8 | larger model or stricter scaffolding |
| 7B to 12B | Q8, then Q4/Q5 | schema retry + readback |
| 20B to 35B | Q4/Q5 | Q6/Q8 for tool-heavy flows |
| MoE models | chosen quant plus loop tests | dense model fallback |
Guardrails that matter more than prompt wording
- Idempotency keys: repeated saves should not create duplicates.
- Read-after-write: confirm by querying the database, not by trusting the model.
- Ambiguity thresholds: “that one” should require a recent unique referent.
- Dry-run mode: for deletes, payments, file edits, and external sends.
- Audit log: every model-proposed action, validation error, executed tool call, and final confirmation.
- Tool result injection: the final answer must be based on the tool result, not the original model intent.
Hardware advice for assistants
For an 8GB VRAM assistant, choose speed and reliability over size. A small model with strong rails can beat a larger model that spills into system RAM and makes the interaction feel dead.
Upgrade hardware when:
- your model fails schema tests at Q8
- Whisper plus the LLM leaves too little VRAM headroom
- the assistant needs long context and voice always loaded
- you need a 20B+ model for reliable tool output
The used RTX 3090 remains a practical NVIDIA path because 24GB VRAM buys room for stronger local tool models. A 32GB AMD card buys more VRAM, but the runtime stack can be more variable. Use the R9700 vs RTX 3090 guide before buying.