All pages
Guides
How do I hand Claude Code subagents to a local model?
Run Claude Code's Explore subagents on a local model through Ollama: measure it, let the agent send it lookups, or let it answer every subagent that passes Golem's checks.
When Claude Code needs to find something in a codebase, it often starts an Explore subagent: a second Claude session that reads files and reports back. Golem can run that same brief on a model on the machine, through Ollama, instead of on Anthropic's models. The setting has four values:
| Setting | What happens |
|---|---|
| Off | Nothing. Every subagent runs on Claude. |
| Shadow | The real subagent answers, and Golem runs the same brief locally to measure how often the two agree. |
| Offer | The agent gets a run_local tool and sends the lookups it judges a local model can do. Golem takes over nothing. |
| Substitute | Golem answers every Explore subagent locally when the answer passes its checks, so work that fans out subagents runs locally without asking. run_local is offered too. |
Measure in Shadow first. Then choose Offer to let the agent decide, or Substitute to decide for it.
Every run is signed in the ledger with the model that did the work, so you can always tell which answers came from the local model.
What you need#
- Claude Code on the machine, at a version with
--restricted, such as 2.1.326. Golem only runs a brief with file reads confined to the working tree, and an older Claude Code cannot confine them, so those runs are skipped. - Ollama running on the machine, with
qwen3-coder:30bpulled (ollama pull qwen3-coder:30b, about 18 GB; it runs comfortably on a 32 GB or larger Mac). - The Golem agent on the machine, at the release that carries subagent handoff, with the Claude Code client wired (
golem setup-client).
Golem loads the model with a 32K context. Ollama's default context is too small to hold a brief, so a model loaded with it answers a question it never saw.
Step 1: measure in Shadow#
In the console, open Profiles, pick the profile your machines use, and find Hand subagents to a local model on its page. Choose Shadow, then pick the model under Local model for subagents:
- Auto, the default, uses
qwen3-coder:30b(orqwen3-coder) where a machine has it installed. Auto only picks models measured to work for this; the general qwen3 models did not use their tools in Golem's tests. A machine with neither skips its runs under Auto. - Below Auto, the list shows the Ollama models this profile's machines have reported, with their sizes. Choosing one runs that model on every machine that has it. A machine without it skips the run.
- Another model… names a model no machine has reported yet.
Every entry records the model that actually ran.
From then on, each Explore subagent a machine on that profile starts also runs on the local model, in the background. The agent only ever sees the real subagent's answer. When the real answer arrives, Golem compares the two by the files each one names:
| Result | What it means |
|---|---|
| Agreed | The local answer named no file that is not there, and at least half of the files it named were in the real answer |
| Disagreed | The local answer named files the real answer did not, or a file that does not exist |
| Not judged | Neither answer named a file |
The panel How the local model did, under the same setting, shows each subagent type and model: how often it agreed, how many runs named a file that is not there, how long each side took, and runs that timed out, failed or were skipped. The same numbers are available to agents through the get_subagent_handoff_measurement tool on golem-admin.
Leave it in Shadow until the agreement is good enough for your work. Small models are confidently wrong more often than you might expect, usually by naming files that do not exist.
Step 2: substitute#
Choose Substitute on the same setting. Now, when Claude Code is about to start an Explore subagent, the Golem agent runs the brief on the local model first, for up to four minutes, and hands Claude Code the local answer only when all of these hold:
- the run finished with an answer, not a timeout, an error or an empty reply;
- the answer names at least one file, and every file it names exists in the working tree;
- the answer passed the injection check, where one runs.
Claude Code is told the answer came from the local model, and the real subagent does not start. If any check fails, or another brief is already running on that machine, the real subagent runs as if Golem had done nothing. Substitution never blocks the agent's work: the worst case is the time the local run took.
Under Substitute the panel shows how often the local answer was used, how often the real subagent ran instead and why, and the median time of a local run. There is nothing to compare a used answer with, because the real subagent never ran, so agreement is only measured in Shadow.
Or: offer it to the agent#
Choose Offer to let the agent decide. The agent gets a run_local tool on Golem's MCP server, and a golem-local-model skill that tells it when to use it. The skill says to use it for lookups whose answer the agent can check: where something is defined, which files call a function, what a module does. It says not to use it for edits, reviews, or anything that needs the conversation.
The agent writes a brief that stands alone. Golem runs it under the same rules and checks as a substituted subagent, and answers with the model that ran, the time taken, and how many cited files were checked. When a check fails, the local model is not installed, or another local run is in progress, run_local says why and the agent does the work itself.
Offer runs show in the panel as run_local, with how often the agent used one and how often it was refused. Substitute offers run_local too.
What the local run can do#
- It reads files only:
Read,GrepandGlob, confined to the working tree it was handed. It cannot write, run commands, or start subagents of its own. - It runs without the parent session's MCP servers, hooks or project instructions, which would not fit in a local model's context.
- It is capped at 15 turns, and one runs at a time on a machine.
- Thinking is turned off for every local run. Claude Code asks for it, and with it on, a small model spends most of its time thinking before it reads anything.
- Only Explore subagents are handed off. A model that is wrong about where code is misleads; one that is wrong about changing code does damage.
What is recorded#
Each attempt is a subagent_handoff entry in the parent session's chain: the subagent type, the model, the mode, the outcome, how long it took, the tokens the local model used, and how many files its answer named and how many of those are missing. The local answer itself, and in Shadow the real one, are kept with the entry's payload in your storage, not in the ledger.
| Outcome | Mode | Meaning |
|---|---|---|
completed | Shadow | The local run answered |
substituted | Substitute | The local answer was used and the real subagent did not run |
answered | Offer | run_local gave the agent the local answer |
fell_back | Offer | run_local refused; fallback_reason says why |
fell_back | Substitute | The real subagent ran; fallback_reason says why |
timeout, error, empty | Shadow | The local run did not answer |
skipped_busy, model_unavailable, unconfined_skipped | Shadow | The local run did not start |
The reasons a substitution falls back are missing_paths, injection, timeout, error, empty, skipped_busy, model_unavailable and unconfined.
What it saves, and what it does not#
On API billing, a substituted subagent is a subagent you did not pay for. On a Claude subscription seat a subagent has no extra dollar cost, so the saving is usage limits. In both cases the local run is usually slower than the real subagent, so measure the time in Shadow before you substitute.
Turn it off#
Set Hand subagents to a local model back to Off. The Golem agent picks the change up with the rest of the machine's profile, and every subagent runs on Claude again.