How to Run a Free AI Coding Agent on Your Laptop With MiniCPM5

On 3 December 2026, OpenBMB released a model that sounds impossible on paper. MiniCPM5-15B-A2.5B carries 15 billion parameters of expert capacity, yet only 2.5 billion of them wake up for any single token. It claims gold medal level maths reasoning. It is built to be an agent, which means it plans, calls tools, and works step by step until a task is done, all on the device in front of you. And it is Apache 2.0, which means it is free to download and free to use, including for commercial work.

This post is the hands-on guide. You will install it on a 16 GB laptop, run it with Ollama, give it a real agent job, and plug it into a coding harness so it can edit files and run commands for you. There is one trap at the start, and this post leads with it, because it is the trap that stops most people on day one: older versions of Ollama cannot load this model at all. The fix is now simple, and you will see it before you download a single gigabyte.

What is MiniCPM5, and why should a laptop owner care?

Most models make you choose between size and speed. A big dense model reasons well and runs slowly. A small model runs fast and reasons poorly. Mixture of Experts, or MoE, is the design that breaks that trade off. The model keeps a large library of specialist sub-networks, called experts, and a small router picks a few of them for each token. The rest stay asleep.

MiniCPM5 is an MoE with 15 billion parameters in total and 2.5 billion active per token. Artificial Analysis lists about 2.8 billion active per token, so treat the exact figure as roughly two and a half to three billion. Either way, the work your laptop does per token is the work of a small model, while the knowledge available to the router is the knowledge of a much larger one. That is why OpenBMB calls it an on-device agent model rather than a chatbot.

The headline numbers are striking. It has 28 layers, 160 routed experts with 16 routed plus one shared expert active at a time, and a 524,288 token context window. It is built on the MiniCPM5MoEForCausalLM architecture, which Hugging Face Transformers supports natively, so there is no trust_remote_code step and no custom code to run. It works with Codex, Claude Code, DeepSeek Harness and WorkBuddy, and OpenBMB verified those connections through the CC Switch manager for Claude Code, the Codex CLI and Desktop apps, DeepSeek Harness and WorkBuddy.

Why does this matter on a laptop? Because the whole point of a local agent is privacy and price. Your code, your files and your prompts never leave the machine. There is no per-token bill, no API key, and no rate limit. The model is the free brain, and Ollama is the free engine. The catch, as always with free local AI, is that you do the setup yourself. That is what the rest of this post is for.

The trap first: will stock Ollama actually run it?

Here is the trap, and the good news about it. The MiniCPM5 GGUF file uses a brand new architecture string, minicpm5_moe. That architecture landed in llama.cpp in pull request 32644, merged on 29 November 2026. Ollama bundles llama.cpp inside itself, so an Ollama release only understands minicpm5_moe if its bundled llama.cpp is new enough.

If your Ollama is 0.40.19 or older, the model will not load. You will see this error:

error loading model: unknown model architecture: 'minicpm5_moe'

If that is you, do not panic and do not re-download the model. The file is fine. The engine is old.

The good news is that the fix has already shipped. Ollama 0.40.20, released on 3 December 2026, bundles llama.cpp build b12910, which includes the merge. Ollama 0.40.21, released on 4 December 2026, bundles b12973, which is newer still. So the first step of this tutorial is a one line update, and for most readers the trap is already gone.

If you are stuck on an older Ollama and cannot update, there are two escapes. One is to build llama.cpp from commit e18d1b21 or later and swap the llama-server binary inside your Ollama install, backing up the original first. The full commands are in the step by step section below. The other is to skip Ollama entirely and load the same GGUF file in LM Studio or straight llama.cpp, both of which already understand the architecture. Either way, try the simple path first: update, then run, and only reach for the swap if you see the error above.

What do you need before you start?

A 16 GB machine is the floor, and it is a real floor, not a suggestion. The Q4_K_M quantised file is 8.49 GiB on disk, and the weights plus the KV cache plus the runtime buffers need to fit in memory alongside your operating system. The cookbook recommends the Q4_K_M file and a context of 8,192 tokens on 16 GB machines, with flash attention on and the KV cache type set to q8_0. Bigger files exist, and they need bigger machines: the Q8_0 file is 14.87 GiB and wants 24 GB or more, and the full BF16 file is 27.97 GiB and wants 32 GB or more.

You also need about 10 GB of free disk for the download and the model, a terminal, and Ollama installed. If Ollama is not installed yet, get it from ollama.com, or use your package manager. On a Mac, brew install ollama does it. On Linux, the install script on the Ollama site does it. Windows users can use the installer from the same site.

One more honest note before the steps. The 524,288 token context is real, but it is not free. Every token of context costs memory in the KV cache. On a 16 GB laptop you will run with 8,192 tokens of context, which is plenty for an agent task, a few files, and a conversation. The half million token window is for bigger machines. Do not raise num_ctx until you have watched the model run comfortably at 8,192.

Step 1: update Ollama and check the version

Open a terminal and check what you have. Then update if you need to.

ollama --version

You want 0.40.20 or newer. On a Mac with Homebrew, the update is:

brew upgrade ollama
ollama --version

On Linux, re-run the install script from ollama.com, which replaces the binary in place. On Windows, download the new installer and run it. After the update, confirm the version number before you go any further. If the number starts with 0.40.20 or 0.40.21, or anything higher, you are ready, and the engine swap below is not needed.

If you cannot update, for example because you are on a managed machine, keep reading. Step 1b below is the engine swap, and it is the only extra work. Everyone else can skip it.

Step 1b, only for Ollama 0.40.19 and older: swap the engine

This builds llama.cpp from the commit that added minicpm5_moe, then replaces the llama-server binary inside your Ollama install. Back up the original first, because the restore command is just moving the backup back. The build takes about ten minutes on Apple Silicon. The paths below are for Homebrew on a Mac; adjust the engine directory for other installs.

git clone https://github.com/ggml-org/llama.cpp llama.cpp-minicpm5
cd llama.cpp-minicpm5
git checkout e18d1b21
cmake -S . -B build-static -DBUILD_SHARED_LIBS=OFF -DGGML_METAL_EMBED_LIBRARY=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build-static --config Release --target llama-server -j
ENGINE_DIR="$(brew --prefix ollama)/libexec/lib/ollama"
cp "$ENGINE_DIR/llama-server" "$ENGINE_DIR/llama-server.orig"
cp build-static/bin/llama-server "$ENGINE_DIR/llama-server"

Restart the server and confirm the new binary is in place:

pkill -f "ollama serve"; sleep 1
OLLAMA_FLASH_ATTENTION=1 OLLAMA_KV_CACHE_TYPE=q8_0 ollama serve &
$(brew --prefix ollama)/libexec/lib/ollama/llama-server --version

The version output must show commit e18d1b21 or a later main commit. To undo the swap at any time, move the backup back: mv "$ENGINE_DIR/llama-server.orig" "$ENGINE_DIR/llama-server". One warning: brew upgrade ollama installs a fresh versioned directory, which discards the swap. After any upgrade, check whether the new release already bundles minicpm5_moe. From 0.40.20 onward, it does, so the swap becomes a one-time fix for an old install, not a permanent ritual.

Step 2: download the model file

The GGUF files live in the openbmb/MiniCPM5-15B-A2.5B-GGUF repository on Hugging Face. The file you want is the Q4_K_M quant, 8.49 GiB, which is the default for laptops. Download it with the Hugging Face command line tool, into a folder of its own:

mkdir -p ~/minicpm5-15b-a2.5b && cd ~/minicpm5-15b-a2.5b
huggingface-cli download openbmb/MiniCPM5-15B-A2.5B-GGUF MiniCPM5-15B-A2.5B-Q4_K_M.gguf --local-dir .

If huggingface-cli is not installed, pip install huggingface_hub gives it to you. The download is the slow part of this tutorial, and it depends on your connection. While it runs, read the next step, because the Modelfile is where the model learns how to talk.

There are other formats if your setup is different. MLX 4-bit builds exist for Apple Silicon, GPTQ 4-bit builds exist for GPU servers, and vLLM can serve the BF16 checkpoint if you have a machine with enough VRAM and a recent vLLM main build or nightly wheel. The Ollama route below is the one this tutorial follows, because it is the route that ends with a local API your coding tools can call.

Step 3: write the Modelfile and create the model

Ollama does not run a GGUF file directly. It needs a Modelfile, which is a short recipe that says which file to use, which chat template to apply, which stop tokens to respect, and which sampling settings to start with. Create one in the same folder as the download:

QUANT=Q4_K_M
cat > Modelfile <<EOF
FROM ./MiniCPM5-15B-A2.5B-${QUANT}.gguf

# MiniCPM5 basic chat template
TEMPLATE """{{- if .Messages -}}
{{- range .Messages -}}
<|im_start|>{{ .Role }}
{{ .Content }}<|im_end|>
{{ end -}}
<|im_start|>assistant
{{ end -}}"""

# Stop on either EOS or the chat-template terminator
PARAMETER stop "<|im_end|>"
PARAMETER stop "</s>"

# Defaults are tuned for think mode
PARAMETER temperature 1.0
PARAMETER top_p 0.95
PARAMETER num_ctx 8192
EOF

ollama create minicpm5-15b-a2.5b -f Modelfile
ollama run minicpm5-15b-a2.5b

Three details in that file deserve a sentence each. The template is ChatML, with im_start and im_end markers, which is the format MiniCPM5 was trained with. The two stop tokens tell the model where its turn ends, so it does not keep writing fake user messages after its answer. And num_ctx 8192 is the 16 GB friendly context size from the cookbook. If you are on a machine with more memory, you can raise it later, but start here.

Start the server with the memory friendly settings from the cookbook before the first run:

OLLAMA_FLASH_ATTENTION=1 OLLAMA_KV_CACHE_TYPE=q8_0 ollama serve &

Then run the create and run commands above. The first load takes a while as the model is read into memory. After that, you should see a prompt. You are talking to a 15 billion parameter agent on your own laptop, for free.

Step 4: your first run, and why the first token is slow

Type a small question first, not a big task. Something like "Explain what a Mixture of Experts model is in two sentences." Then watch what happens. Thinking mode is on by default, so the model reasons in a think block before it answers. That is normal, and it is also the reason the first token can feel slow.

Be honest with yourself about the wait. On OpenBMB's own hosted endpoint, an independent check measured 28 seconds to the first answer token, against a 6 second median for other models. Your local run will vary with your hardware, but the pattern is the same: a visible pause, then a fast stream of tokens once the thinking is done. The pause is the model doing the work. If you want a quick answer with no reasoning, you can ask for no-think mode, which is covered below. For agent work, leave thinking on. The thinking is the point.

If the model answers in a loop, repeats itself, or talks past the stop tokens, two things are worth checking. First, confirm the Modelfile was created from the template above, because a wrong template is the usual cause of runaway output. Second, add a repetition penalty of 1.05, which the model card itself suggests for repetitive output. Both are cheap fixes, and both are in the sampling section below.

Step 5: give it a real agent job

A chatbot answers a question. An agent does a task. To see the difference, give MiniCPM5 a small job with a verifiable result, and watch it plan. A good first task is a tiny coding job in an empty folder: write a Python script that reads a CSV file of expenses, totals each category, and prints the three biggest categories. Then ask it to run the script, read the error if there is one, fix it, and run it again.

In the Ollama chat, that looks like a conversation where you paste the task, the model writes the code, and you run it yourself. That is the honest limit of the chat window: Ollama on its own does not give the model a file system or a shell. The model can plan and write, but you are still the hands. The next section removes that limit by plugging the model into a harness, which is where it becomes a real agent.

Before that, one practical tip. Agent tasks work best when the goal is concrete and the success check is obvious. "Write a script that totals a CSV and prints the top three categories" is a good task. "Make my code better" is not, because there is no way to tell when it is done. Give the model a finish line, and it will run toward it. Give it a vague wish, and it will wander.

How do you plug MiniCPM5 into a coding harness?

This is the step that turns a local model into a local coding agent. Ollama serves an OpenAI compatible API at http://localhost:11434/v1, and the coding harnesses speak to that endpoint as if it were a cloud provider. OpenBMB verified MiniCPM5 with Codex, Claude Code, DeepSeek Harness and WorkBuddy, and the connections use the CC Switch manager for Claude Code and the Codex CLI or Desktop app for Codex.

The shape of the setup is the same in every harness: point the tool at your local endpoint, pick the model name you created, and let the harness do the file and shell work. A minimal check that the endpoint is alive looks like this:

curl http://localhost:11434/v1/chat/completions \
    -H "Content-Type: application/json" \
    -d '{
        "model": "minicpm5-15b-a2.5b",
        "messages": [{"role": "user", "content": "Say hello in one sentence."}],
        "temperature": 1.0, "top_p": 0.95, "max_tokens": 1024
    }'

If that returns a reply, the plumbing works, and the harness can use it. In Claude Code, CC Switch lets you swap the backend to your local Ollama endpoint, so the same agent interface you would use with a cloud model now runs against your laptop. In Codex, the CLI and Desktop app accept an OpenAI compatible base URL, so you point them at localhost:11434/v1 the same way.

Two warnings belong here, and both are about safety, not setup. First, a coding agent with shell access can delete files, overwrite code, and run commands you did not expect. Run it in a throwaway folder or a container first, and never point it at a machine that holds production credentials or irreplaceable files. Second, keep the local endpoint on localhost. Ollama listens on your machine by default, and that is where it should stay. Do not expose port 11434 to the internet, because anyone who finds it can run your model and, through a harness, your shell.

If you want the full harness experience with a frontier model as well, read the RiseMe guide to Microsoft's FreeHand, which is a free agent harness that takes the same kind of local endpoint. MiniCPM5 is the free brain, FreeHand is a free pair of hands, and Ollama is the wire between them.

Thinking mode or no-think mode: which one, when?

MiniCPM5 has a hybrid thinking design, which means it can reason at length before answering, or skip the reasoning and answer directly. Thinking is on by default, and the embedded chat template emits an open think block unless you explicitly turn it off. That default is right for agent work, maths, and anything where a wrong first step wastes the whole task.

The model card gives two sets of sampling parameters, and they are worth copying exactly rather than guessing. For thinking mode, use temperature 1.0 and top_p 0.95, and add a repetition penalty of 1.05 if the output starts looping. For non-thinking mode, use temperature 0.7, top_p 0.80, top_k 20, and presence_penalty 1.5. Those numbers come from OpenBMB, and they are tuned to this model, not generic defaults.

Use thinking mode when the task has steps, when the answer needs a plan, or when you are asking the model to write or fix code. Use no-think mode when you want a quick factual answer, a short rewrite, or a chatty reply, and the extra reasoning would only add latency. In the Ollama API, no-think mode needs a raw request with an empty think block written by hand, because the Modelfile path does not expose the enable_thinking flag. The cookbook shows the exact raw request, and it is linked in the sources. For most readers, the practical rule is simpler: leave thinking on, and accept the pause.

The honest scoreboard: whose numbers do you believe?

This is the part of the post where you need to read carefully, because two sets of numbers disagree, and both are real. They were measured on different benchmarks, with different harnesses, and different scoring, so they are not interchangeable. A post that only shows one side would be misleading.

OpenBMB's own numbers are strong. SWE-Bench Pro 52.2, Terminal-Bench 50.2, and AIME 2026 95.8, each ahead of Qwen3.6-35B-A3B on the same three tests, according to OpenBMB. Artificial Analysis gives the model an Intelligence Index score of 11 in version 5.0.2, first among open weight models under 20 billion total parameters and under 4 billion active. On the maths side, MiniCPM5 officially took part in the 2026 Chinese Mathematical Olympiad finals and earned an official gold medal certification with 123 out of 126, and OpenBMB's self-evaluation on IMO 2026 scored 32, above the gold cutoff of 29, which OpenBMB describes as the first on-device model at IMO gold level.

Now the other side. AlphaSignal ran an independent check and found much weaker results on harder setups: FrontierCode-AA 2.0 at 2.8 percent, Terminal-Bench 4.1 at 0.0 percent, and HLE-Diamond at 8.2 percent. The same check measured 28 seconds to the first answer token on the hosted endpoint, against a 6 second median. Those numbers do not cancel OpenBMB's numbers, because the benchmark versions and harnesses differ. But they do change the story. MiniCPM5 looks like a strong model on the tests its maker chose, and a much weaker one on the harder, independent tests a third party chose. Both facts belong in your decision.

What should you take from that? Run it yourself, on your own tasks, before you trust either scoreboard. The model is free, the download is 8.49 GiB, and a small coding task tells you more in ten minutes than any leaderboard can. If it handles your tasks, the benchmarks do not matter. If it fails your tasks, the gold medal does not matter either.

What MiniCPM5 cannot do (yet)

A fair tutorial ends with the limits, so here they are, plainly. There is no free hosted API, and that is the point of this model: the free route is local. A hosted platform called ModelBest exists, at api.modelbest.cn, but it needs an API key, and this tutorial does not use it. If you want to try the model without downloading anything, check the demo links on the model card, but expect queues and limits.

The 524K context window is real, but on a 16 GB laptop you will use 8,192 tokens of it. The weights, the KV cache, the runtime buffers and the prompt all draw from the same memory, and the cookbook is explicit about that trade off. Do not raise the context and then wonder why the machine slows down.

Thinking mode is slow to start, by design. The model reasons before it answers, so the first token arrives late even when the total task time is competitive. If you need instant replies, this is the wrong model, or the wrong mode.

Finally, the benchmarks are contested, as the scoreboard above shows. Treat every number in this post as a claim with a named source, not as a fact. The strongest claim in this post is the one you can verify yourself in an afternoon: the model runs on a 16 GB laptop, for free, with no API bill, and it can do real agent work. Everything else is a leaderboard, and leaderboards are arguments, not verdicts.

FAQ

Can I run MiniCPM5 on a 16 GB laptop?

Yes. Download the Q4_K_M file, which is 8.49 GiB, keep the context at 8,192 tokens, and set flash attention on with a q8_0 KV cache, as the cookbook recommends. The weights plus the cache fit in the roughly 12 GiB a 16 GB Mac makes available to the GPU. An 8 GB machine will struggle, and the model is not a good fit there.

Do I still need the engine swap?

Only if your Ollama is 0.40.19 or older. Ollama 0.40.20, released 3 December 2026, bundles the llama.cpp build that includes minicpm5_moe, so updating Ollama is the fix. The swap is the fallback for machines that cannot update, and the restore command is in Step 1b above.

Is MiniCPM5 really free?

Yes, under the Apache 2.0 licence. You can download it, run it, and use it commercially, with no API key and no per-token bill. The only costs are your hardware, your electricity, and your time. The hosted ModelBest platform is a separate paid service, not the free route.

Can it replace a cloud coding model?

For small, well defined tasks on your own machine, it is a genuine option, and it keeps your code private. For large, messy, multi-file refactors, a frontier cloud model is still stronger, and the independent benchmark numbers above say so plainly. Use MiniCPM5 where privacy and price matter most, and a cloud model where raw capability matters most.

Does it work with Claude Code and Codex?

Yes. OpenBMB verified it with Codex, Claude Code, DeepSeek Harness and WorkBuddy, using the CC Switch manager for Claude Code and the Codex CLI or Desktop app. All of them talk to Ollama's OpenAI compatible endpoint at http://localhost:11434/v1, with the model name minicpm5-15b-a2.5b.

Why is the first answer so slow?

Thinking mode is on by default, so the model reasons before it answers. An independent check measured 28 seconds to the first token on the hosted endpoint. Once the thinking is done, tokens stream quickly. If you want fast short answers, use no-think mode with the sampling settings in the thinking section above.

What is the difference between MiniCPM5 and the smaller MiniCPM5 models?

The 15B-A2.5B model is the agent flagship of the family. Smaller siblings exist, including a 2B and a 1B GGUF, and they run on lighter hardware. This post covers the 15B model because it is the one with the agent tooling, the 524K context, and the reasoning claims.

Sources

OpenBMB MiniCPM5-15B-A2.5B model card, Hugging Face
OpenBMB, Deploy MiniCPM5-15B-A2.5B with Ollama, MiniCPM cookbook
AlphaSignal, OpenBMB's MiniCPM5 Tops All Open Models Running Under 4B Active Parameters, 3 December 2026
GGUF Architecture Lookup, minicpm5_moe support in llama.cpp and Ollama
Ollama releases, versions 0.40.20 and 0.40.21
OpenBMB MiniCPM5-15B-A2.5B-GGUF, Hugging Face

Keep reading on RiseMe

How to Run Microsoft's FreeHand Free: The AI Coding Agent With One Bash Tool
How to Make a Free AI Agent Use Your Android Phone: Microsoft's Sico-GUI
How to Run Qwen4 Free: 35B, 1M Context, on Your Own Machine
How to Run a 27B AI on Your Laptop for Free With Bonsai 2.5
How to Run a 98-on-MATH-500 AI on Your Laptop for Free With TwIL-8B

Post a Comment