Local models, all the way down.
ctxfile pairs with models running on your own machine through Ollama. There are two directions, and knowing which is which saves confusion:
- ctxfile calls the model (summaries, consult): plain HTTP to localhost. Works with ANY model, no tool support needed.
- The model drives ctxfile (a local agent calling MCP tools): the model needs tool-calling support and an agent harness such as OpenCode. Ollama is a model server, not an agent;
ollama runalone cannot call tools.
Setup (macOS)
brew install ollama && brew services start ollamaPull a model. Two good starting points:
ollama pull gemma3:4bollama pull qwen3:8bgemma3:4b is small and quick for summaries. qwen3:8b supports tool calling, which you need for agent use. Check any model's abilities with ollama show <model>; look for tools under capabilities. 16GB of RAM runs the 4B and 8B classes comfortably; 32GB handles 12B and up.
Local session summaries (free core)
In your project's .ctxfile.json:
{
"ollama": { "summarize": true, "model": "gemma3:4b" }
}Snapshots now include a working-session summary written by the local model. It appears in get_context and in exports under the full or custom profiles; the default repo-safe profile excludes it by design. If Ollama is not running, the connector skips quietly; nothing breaks.
Local consult (Pro)
Ask a second opinion from a local model, from inside any agent:
{
"consult": {
"providers": [
{ "type": "ollama", "model": "qwen3:8b" }
]
}
}The consult tool sends your question plus context to each configured provider and returns the answers side by side. An Ollama provider means the consult never leaves your machine, and costs nothing per call.
A fully local agent (OpenCode + Ollama)
Local brain, local harness, local context: OpenCode uses an Ollama model as the agent and loads ctxfile over MCP. In the project's 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": "Qwen 3 8B (local)" } }
}
},
"model": "ollama/qwen3:8b",
"mcp": {
"ctxfile": {
"type": "local",
"command": ["ctxfile", "--root", "."],
"enabled": true
}
}
}Then:
opencode run "Use the ctxfile get_context tool, then summarize this project's plan."The model decides to call get_context, reads your working state, and answers from it. Zero bytes leave the machine.
Traps we hit so you do not have to
- gemma3 cannot be the agent. It lacks tool support in Ollama; the call is rejected with "does not support tools". It still works everywhere ctxfile calls the model (summarize, consult). Tool-capable picks: qwen3, llama3.1 and newer, mistral.
- Thinking models are slow to first token. qwen3 reasons before answering; under an agent's large tool prompt the first response can take minutes on laptop hardware. Prefix prompts with
/no_thinkto skip reasoning, and expect the first call to be the slowest. - Raise the context window for tool calls. OpenCode recommends an Ollama
num_ctxof 16k or more; agents carry large tool schemas. - Small models embellish. A 4B summary is useful but may guess at project names and details. Step up to 12B and beyond when accuracy matters more than speed.