Repository navigation
Description
Overview
During investigation of #1632 (ollama_integration test suite failures), found that mistral:7b via the Ollama provider path reliably fails to emit structured tool_calls once roughly 6 or more tools are offered in the same turn. Instead of using Ollama's structured tool-calling field, the model narrates the intended call as prose or JSON-in-markdown (e.g. "To get the details of a specific node, you can use the get_node function...").
This is not test flakiness — it reproduces deterministically (verified via raw Ollama /api/chat calls that bypass all NodeSpace code, 3-5 repeated runs each, temperature 0.0-0.1).
Relationship to existing decisions
This does not reverse or contradict ADR-038 (skill-mediated tool routing) or ADR-046 (Ministral 8B locked as the native path model). Both ADRs' evidence and agent tool-call matrix (#1370) evaluated only the native llama.cpp/GGUF path (Ministral 8B, Gemma 4 12B, Ornith 1.0 9B). Mistral 7B via Ollama — a separate, real, user-selectable provider path per #1370's own model-picker design (Ollama is auto-detected and its models, including "Mistral 7B", are shown as selectable) — has not been evaluated against either ADR's findings. This issue adds that missing evidence for the Ollama path specifically.
It's still relevant to ADR-038's Stage-2/routing design: GraphToolExecutor::available_tools() (packages/agent/src/local_agent/tools.rs) sends the full unscoped tool set (14 tools) on every turn regardless of provider path — the routing pipeline described in ADR-038 (retrieval-bounded top-K candidates, not full-registry enumeration) is not wired up yet for the Ollama path either (Implementation Notes step 4, "depends on 1" — the engine upgrade — is scoped to the native path only per ADR-046's Related issues). Real mistral:7b-via-Ollama users can hit this narration failure on ordinary requests today, not just in tests.
Evidence
Direct Ollama API testing (http://127.0.0.1:11434/api/chat), varying tool count with the same message ("Show me the full content of node task-abc123", expects a get_node call):
| Tool count | Result |
|---|---|
| 2 | tool_calls returned correctly |
| 3 | tool_calls returned correctly |
| 5 | tool_calls returned correctly |
| 7 | narrated as prose, no tool_calls |
| 10 | narrated as prose, no tool_calls |
Holds regardless of system prompt content — tested with no system prompt, the bare EMERGENCY_FALLBACK_PROMPT, and the full production-assembled prompt (PromptAssembler::assemble_static, 7800 chars). None rescue tool-calling at 7-10 tools.
Adding search_skills itself as one of 11 offered tools does not help — the model doesn't even reach for search_skills; it still narrates a direct call to the target tool.
Model comparison at the same 10-tool case via Ollama (identical tools/prompt/message):
| Model | Params | Result |
|---|---|---|
| ministral-3:3b | 3B | Fails — claims it "cannot access" the tool (worse failure mode) |
| mistral:7b | 7B | Fails — narrates as prose |
| ornith:9b | 9B | Succeeds reliably (3/3) |
| mistral-nemo:12b | 12B | Succeeds reliably (3/3) |
Tool-calling reliability at this tool count scales with model size within the tested range, but neither larger Ollama-hosted model is a clearly better default:
ornith:9bhas the same multi-step ReAct-loop KV-cache slowdown documented for the native path in Re-enable Ornith 1.0 9B in Settings UI once multi-step tool-calling slowdown is addressed #1477 (recurrent/SSM layers can't reuse KV-cache across iterations — a confirmed upstreamggml-org/llama.cpplimitation, not path-specific).mistral-nemo:12bneeds ~12GB and CPU-spills (9%/91% CPU/GPU split) atnum_ctx=32768on a 16GB machine (this project's documented minimum target per the A/B test Gemma 4 12B (Q4_K_M) vs E4B for the local ai-chat agent #1329 A/B trial) — GPU OOM risk under concurrent load. Independently reproduced during this investigation:ggml_metal_synchronize: error... Insufficient Memory (kIOGPUCommandBufferCallbackErrorOutOfMemory)when Ollama allocated a 32768-token KV cache for mistral:7b under memory pressure from concurrent processes on the same machine.
Problem Statement
For the Ollama path, there is currently no mechanism to reduce the tool count the model sees per turn, regardless of which Ollama model the user picks. GraphToolExecutor::available_tools() sends the full unscoped tool list on every iteration; the search_skills retrieval-based routing ADR-038 specifies is not wired into a real scoping path for any provider yet.
Candidate Fixes (not prescribed — for future investigation)
- Extend ADR-038's routing pipeline (retrieval + LLM judgment, bounded top-K, scoped follow-up tool list) to the Ollama path, not just whatever native-path work lands first.
- Reduce the always-offered baseline tool count for the Ollama path specifically, independent of the native-path routing work.
- Document a recommended/tested Ollama model list in Settings (the Lock llama.cpp path to Ministral 8B only; expose Ollama + OpenAI-compatible as open paths #1370 model-picker UI already lists specific Ollama models as examples) informed by this tool-count ceiling finding, so users aren't silently steered toward a model that will narrate instead of calling tools.
Related
- ollama_integration test suite has ~17 failing tests due to empty tool-call responses from mistral:7b #1632 — original test-suite triage that surfaced this (tests there are
#[ignore]d with reasons pointing to this issue) - Re-enable Ornith 1.0 9B in Settings UI once multi-step tool-calling slowdown is addressed #1477 — Ornith 1.0 9B hidden from native model picker (same ReAct-loop KV-cache limitation reproduced here on the Ollama path)
- Lock llama.cpp path to Ministral 8B only; expose Ollama + OpenAI-compatible as open paths #1370 (closed) — model-picker design that established Ollama as an open, model-agnostic path
- A/B test Gemma 4 12B (Q4_K_M) vs E4B for the local ai-chat agent #1329 — 12B model A/B trial (established the 16GB memory constraint this issue's mistral-nemo finding reconfirms)
Acceptance Criteria
- Decide on an approach for the Ollama path (extend ADR-038 routing to Ollama, reduce baseline tool count, document a tested/recommended Ollama model list, or some combination)
- If tool scoping: wire real skill-matched tool narrowing into
agent_loop.rs/GraphToolExecutorfor the Ollama provider path - Re-enable the
#[ignore]d tests inollama_integration.rs(packages/agent/tests/ollama_integration.rs) once the fix is validated against them, or replace them with tests matching the new architecture - Verify fix holds under this project's 16GB memory target (no OOM/CPU-spill regression)
Activity
malibio commentedon Jul 17, 2026
Closing as won't-fix.
Decision: the external (non-native) agent option is the OpenAI protocol — a single BYO-endpoint path that includes Ollama (mode 2b) and any OpenAI-compatible endpoint (mode 2c) per ADR-034. This path is explicitly use-at-your-own-risk: we do not commit to making any particular external model tool-call reliably, and we will not scope/route the tool set specifically for the Ollama path.
That removes this issue's premise:
mistral:7b(or any specific external model) emit structured tool_calls past ~6 tools is not a goal. Model/tool-count ceilings are the user's risk when they BYO an external endpoint.Durable evidence preserved here for the record: within Ollama, tool-calling at ~10 offered tools scales with model size — mistral:7b/ministral-3:3b narrate instead of calling; ornith:9b and mistral-nemo:12b succeed but neither is a viable 16GB default (KV-cache slowdown / GPU OOM respectively). Anyone selecting an external model can consult this.
The
#[ignore]d tests inpackages/agent/tests/ollama_integration.rsstay ignored — they assert reliability guarantees we are not making for the external path.Native local agent remains Gemma 4 E4B (ADR-046).