memcode docs
Code

Ollama

Run memcode against models served locally by Ollama.

Ollama serves models on your own machine with an OpenAI-compatible API, so memcode can use it. Nothing leaves your machine and no key is needed.

Before you start

Install and start Ollama, then pull a model:

ollama pull qwen2.5-coder

Connect

Point memcode at Ollama and name a model:

memcode ollama qwen2.5-coder

That saves the setting, so later runs just work. Leave the model off to pick one in a session with /model. For a host other than the default, pass --url:

memcode ollama --url http://192.168.1.10:11434 qwen2.5-coder

Give the model enough context

Out of the box, Ollama gives each model a small context window (4K tokens) and silently cuts off anything longer. Memcode's instructions and tools alone are longer than that, so with the default the model never sees most of your request and its answers fall apart.

Make a copy of the model with a bigger window. It reuses the same files, so it takes no extra disk space:

printf 'FROM qwen3:8b\nPARAMETER num_ctx 32768\n' > Modelfile
ollama create qwen3-8b-32k -f Modelfile
memcode ollama qwen3-8b-32k

Then tell memcode the window size so it sizes each request to fit. Add it to ~/.config/memcode/.env, the file where memcode ollama saved your setting:

echo 'MEMCODE_ENDPOINT_CONTEXT_WINDOW=32768' >> ~/.config/memcode/.env

A bigger window uses more memory. 32K suits an 8B model on a 16 GB machine.

Notes

A local model won't match a frontier model on hard tasks, so pick a capable coding model and keep tasks focused. Expect it to be slower too: on a laptop, reading a long request can take a minute or more before the model starts answering.

On this page