Ollama local model support with context preloading
brauliogusmao added Ollama as a provider, routing `ollama/<model>` IDs through a new 309-line streaming adapter. The interesting part isn't the wiring -- it's that document-fetch tools are preloaded into context rather than called reactively, because small local models don't handle reactive tool use reliably.
Backend changes: backend/src/lib/llm/ollama.ts handles streaming, message conversion, and tool-call normalization against Ollama's /api/chat. The dispatcher in llm/index.ts checks for the ollama/ prefix and routes accordingly. models.ts bypasses the static model allowlist for ollama/* IDs. A GET /ollama/models route in routes/ollama.ts proxies the Ollama instance's model list. OLLAMA_URL defaults to http://localhost:11434.
Frontend changes: the model picker gains a "Local (Ollama)" group that populates from fetchOllamaModels(). It only renders when Ollama is reachable and returns models. useSelectedModel and modelAvailability.ts were extended to recognize the new provider.
The CONTEXT_TOOLS set (read_document, fetch_documents) defines which tools get preloaded. When one fires, its result goes into the system prompt and the tool is removed so the model won't call it again. The commit is explicit that this exists to compensate for weaker tool-calling in smaller models -- a pragmatic accommodation. The downside is that this behavior differs from the Anthropic and OpenAI adapters, which rely on the model to call these tools when it needs them.
One thing to flag: the GET /ollama/models endpoint returns whatever the configured Ollama host reports, with no filtering. Fine for localhost, worth auditing if OLLAMA_URL ever points at a shared server.
Spotted something wrong? Or know the PR text has fresher detail than the writeup above?