Which agent talks to which local server
The three agents speak two different APIs. Claude Code sends Anthropic Messages requests (POST /v1/messages); OpenCode and Codex CLI send OpenAI-style requests (Codex uses the Responses API). Ollama, LM Studio and oMLX each serve both styles on your Mac, so any agent can reach any of the three servers:
| Agent | API it calls | Quickest setup | Manual setup |
|---|---|---|---|
| Claude Code | Anthropic Messages | ollama launch claude | ANTHROPIC_BASE_URL → Ollama :11434, LM Studio :1234 or oMLX :8000 |
| OpenCode | OpenAI-compatible | ollama launch opencode | none on the same Mac: OpenCode finds Ollama and LM Studio itself |
| Codex CLI | OpenAI Responses | ollama launch codex or omlx launch codex | codex --oss --local-provider ollama (or lmstudio) |
The servers’ own pages: Ollama’s Anthropic compatibility and integrations, LM Studio’s Claude Code guide (its /v1/messages endpoint arrived in 0.4.1), and the oMLX README, which lists /v1/chat/completions, /v1/messages and /v1/models on port 8000. All three install from the Mac LLM apps page.
Step 1: serve the model with a 64K context
Most failures with a local agent are a context window that is too small, not a model that is too weak. The agent’s system prompt and tool definitions alone fill a large part of a small window before your code arrives, and once the conversation outgrows the window the server truncates the prompt or refuses it, depending on the runtime. Ollama’s documentation says agents and coding tools “should be set to at least 64000 tokens”, and its OpenCode and Codex pages ask for 64K as well. LM Studio’s Claude Code guide asks for more than about 25K, a floor rather than a target.
Ollama picks a default from GPU memory: 4K below 24 GiB, 32K from 24 to 48 GiB, and 256K from 48 GiB. On most 16–32 GB Macs that is below 64K, so set it yourself:
# Ollama: for the whole server (or move the context slider in the Ollama app's settings)
OLLAMA_CONTEXT_LENGTH=64000 ollama serve
ollama ps # the CONTEXT column shows what each loaded model got
# LM Studio: per model, when you load it
lms load <model_key> --context-length 65536
lms server start --port 1234
# oMLX: serves on port 8000 and reports each model's real context window to Claude Code (so it compacts in time)
A longer context needs more memory, which the table below works out per model. An 8-bit KV cache halves that extra memory (Ollama: OLLAMA_KV_CACHE_TYPE=q8_0, for GGUF models on its llama.cpp engine only — its MLX engine never reads it; llama.cpp: -ctk q8_0 -ctv q8_0). Go no lower for agent work: llama.cpp’s function-calling notes warn that extreme KV quantizations such as q4_0 “can substantially degrade the model’s tool calling performance”.
Claude Code with a local model
Ollama can install the settings and start Claude Code in one step; ollama launch claude --model <tag> --yes does the same without prompts. By hand, Claude Code needs three environment variables pointed at the local server. The values below are the ones in Ollama’s and LM Studio’s guides; the token is a placeholder the server ignores unless you turned authentication on:
# Ollama (port 11434)
ollama launch claude
# or by hand:
export ANTHROPIC_BASE_URL=http://localhost:11434
export ANTHROPIC_AUTH_TOKEN=ollama
export ANTHROPIC_API_KEY=""
claude --model qwen3.6:35b-a3b
# LM Studio (port 1234)
lms server start --port 1234
export ANTHROPIC_BASE_URL=http://localhost:1234
export ANTHROPIC_AUTH_TOKEN=lmstudio
export CLAUDE_CODE_ATTRIBUTION_HEADER=0
claude --model openai/gpt-oss-20b
# oMLX (port 8000)
export ANTHROPIC_BASE_URL=http://localhost:8000
export ANTHROPIC_AUTH_TOKEN=omlx # or your oMLX API key; without a token a saved claude.ai login stays active
claude --model <a model id from http://localhost:8000/v1/models>
Four settings from Claude Code’s environment-variable reference matter with a local server:
ANTHROPIC_DEFAULT_HAIKU_MODELis the model thehaikualias resolves to, and Claude Code also uses it “for background functionality”. Set it to the same local model so those background requests reach a model your server has.API_TIMEOUT_MSis how long each request may wait for response headers, and its default is already600000(ten minutes). A long first prompt on a Mac can take a while to process: if one times out, setAPI_FORCE_IDLE_TIMEOUT=0(the five-minute idle timeout ends a silent request first), and raiseAPI_TIMEOUT_MSonly for waits beyond ten minutes.CLAUDE_CODE_MAX_CONTEXT_TOKENS=64000(the context you served): Claude Code does not recognise a local model ID, so it assumes a 1M-token window and would not compact before the server’s 64K window fills.CLAUDE_CODE_ATTRIBUTION_HEADER=0, which LM Studio’s guide sets, omits a block carrying the client version and a prompt fingerprint from the start of the system prompt.
What does not carry over: Ollama’s Anthropic layer does not support prompt caching (cache_control), tool_choice or the token-counting endpoint, and accepts but does not enforce a thinking budget. Claude Code’s permission prompts work exactly as with Anthropic’s API, since they run in the client. If a session still reaches the cloud, settings files can override shell variables: run /status to see which apply.
OpenCode with a local model
OpenCode needs the least setup. Its provider documentation says it probes Ollama at http://127.0.0.1:11434 and LM Studio at http://127.0.0.1:1234/v1, and lists the models it finds under /models with no account or config file. Ollama’s launcher writes an inline config for the model you pick and leaves your opencode.json alone:
curl -fsSL https://opencode.ai/install | bash
ollama launch opencode # or: ollama launch opencode --config (configure, don't start)
# or start Ollama / LM Studio yourself, run opencode, then pick the model with /models
opencode
A server on another Mac (a Mac Studio across the room, say) needs only its address, with /v1 on the end:
{
"$schema": "https://opencode.ai/config.json",
"providers": {
"ollama": { "settings": { "baseURL": "http://studio.local:11434/v1" } }
}
}
The 64K context still has to be set on the server, as in Step 1: OpenCode’s page on Ollama’s site says it “requires a context length of 64k or higher”.
Codex CLI with a local model
Codex has a built-in switch for local models. Its command reference describes --oss as using “a local open source model provider”, with --local-provider choosing lmstudio or ollama for one run; without it Codex uses oss_provider from config.toml, and asks only when neither is set.
npm install -g @openai/codex
ollama launch codex # writes an Ollama profile and starts Codex
codex --oss --local-provider ollama -m gpt-oss:20b # Ollama, a model you have pulled
codex --oss --local-provider lmstudio # LM Studio
omlx launch codex # oMLX: needs Codex 0.148 or newer
The profile Ollama writes talks to http://localhost:11434/v1/ over the Responses API (wire_api = "responses"), and inside Codex /model switches between your installed tool-capable models. Ollama’s Codex page asks for a context window of at least 64K here too, and notes that in its profile, web-search requests go to Ollama’s service; -c 'web_search="disabled"' turns that off for a session.
Which models are agent-ready at 64K, on which Mac
The index’s agent-ready rule: a model is agent-ready at 64K on a Mac when its context window is at least 64K tokens and its RAM at 65,536 tokens with a 16-bit KV cache is no more than the Mac’s memory. That RAM is the index’s minimum, which already covers about the first 4K tokens of context, plus the cache for the rest. The cache comes from the model’s own config.json: two vectors (a key and a value) per KV head, per full-attention layer, per token. Sliding-window layers stop growing at their window, and the linear-attention and convolution layers of the newer hybrids keep a fixed-size state, which is why a 35B mixture-of-experts model can need less cache than a dense 27B. The methodology has the formula.
| Model | Min RAM | KV cache at 64K | RAM at 64K | Smallest Mac | Decode on that Mac | Architecture |
|---|---|---|---|---|---|---|
| GPT-oss 20B | 13 GB | 1.6 GB | 15 GB (14 with 8-bit KV) | 16 GB | estimated~41 tok/s Mac mini M6 16 GB | 24 layers, half of them sliding-window (128 tokens); 8 KV heads × 64 (config.json) |
| LFM2.5-24B-A2B | 17 GB | 1.3 GB | 19 GB (18 with 8-bit KV) | 24 GB | community114 tok/s Mac mini M5 Pro 24 GB | 40 layers: 10 attention, 30 convolution (no cache); 8 KV heads × 64 (config.json) |
| Recursive Flint | 20 GB | 1.9 GB | 22 GB (21 with 8-bit KV) | 24 GB | community92 tok/s Mac mini M5 Pro 24 GB | 49 layers: 14 full, 35 sliding-window (513 tokens); 4 KV heads × 128 (config.json) |
| North Mini Code 1.0 | 21 GB | 2.0 GB | 23 GB (22 with 8-bit KV) | 24 GB | community70 tok/s Mac mini M5 Pro 24 GB | 49 layers: 13 full, 36 sliding-window (4,096 tokens); 4 KV heads × 128 (config.json) |
| Qwen3.8-27B | 19 GB | 4.3 GB | 24 GB (22 with 8-bit KV) | 24 GB (tight) | sourced17 tok/s Mac mini M5 Pro 24 GB | dense; 64 layers: 16 full attention, 48 linear attention (fixed state); 4 KV heads × 256 (config.json) |
| Qwen 3.6-35B-A3B | 24 GB | 1.3 GB | 26 GB (25 with 8-bit KV) | 32 GB | community59 tok/s Mac mini M6 32 GB | 40 layers: 10 full, 30 linear attention; 2 KV heads × 256 (config.json) |
| Qwen3-Coder-Next | 48 GB | 1.6 GB | 50 GB (49 with 8-bit KV) | 64 GB | estimated~49 tok/s Mac mini M5 Pro 64 GB | 48 layers: 12 full, 36 linear attention; 2 KV heads × 256 (config.json) |
| GPT-oss 120B | 62 GB | 2.4 GB | 65 GB (64 with 8-bit KV) | 96–128 GB (64 GB with an 8-bit cache) | community92 tok/s Mac Studio M5 Max 128 GB | 36 layers, half sliding-window (128 tokens); 8 KV heads × 64 (config.json) |
| Qwen3.8-Flash-Next | 120 GB | 1.6 GB | 122 GB (121 with 8-bit KV) | 128 GB | community47 tok/s Mac Studio M5 Max 128 GB | 48 layers: 12 full, 36 linear attention; 2 KV heads × 256 (config.json) |
Min RAM, the KV cache and RAM at 64K are estimated: arithmetic on each model’s published architecture (GB = 109 bytes), not a reading of any Mac’s memory. RAM at 64K is rounded up to a whole gigabyte, as on the leaderboard’s RAM @64K column. Min RAM is the index’s figure on 18 November 2026; the decode column is filled from the index on every build, at a short prompt.
Three things the table does not show. First, the “tight” row leaves under about 1 GB spare, and macOS lets the GPU use only part of unified memory by default (methodology, Step 1), so on a 24 GB Mac Qwen3.8-27B needs an 8-bit cache, a shorter context or a higher iogpu.wired_limit_mb; North Mini Code 1.0 leaves about 1.4 GB. Second, the runtime’s own buffers grow with context too. Third, GLM-4.7-Flash is left out on purpose: it uses multi-head latent attention, whose cache is about 3.5 GB at 64K if the runtime keeps the compressed latent (47 layers × 576 values) and about 63 GB if it expands it to full keys and values, so check your runtime’s memory report before relying on it.
Per Mac, the Best LLM by Mac pages rank every model that fits, and the leaderboard filters by RAM.
A Mac that holds the 32 GB-tier agents at 64K
The cheapest configuration Amazon itself stocks with more than 32 GB is the Mac Studio M5 Max with 36 GB (32-core GPU, 460 GB/s), which holds Qwen 3.6-35B-A3B at 64K. The 48–128 GB Mac Studio and MacBook Pro configurations that hold Qwen3-Coder-Next or GPT-oss 120B are build-to-order from Apple: AppleInsider’s price guide showed no Amazon listing for them on 18 November 2026.
Mac Studio M5 Max (36 GB) on Amazon → Mac mini M5 Pro (24 GB) on Amazon →Disclosure: As an Amazon Associate, LLMCheck earns from qualifying purchases. This doesn’t affect the index’s figures or rankings.
Speed: decode, and the wait before the first token
Two speeds decide how an agent feels. Decode is how fast the reply streams; the index’s figures are plain decode at a short prompt, and decode slows as the context fills because every new token also reads the cache. Prefill is how fast the server reads the prompt before it can answer, and an agent sends a long prompt every turn. The index does not estimate prefill: it depends on compute, which the bandwidth model does not describe.
Two published sources show how much prefill matters. In Artificial Analysis’s AA-AgentPerf-Local (29 September 2026), which replays recorded agent sessions whose context grows to about 56K tokens, 73–93% of prompt tokens were served from the KV cache, and prefill still took 22–41% of the completion time for Qwen3.8-27B; on its one Mac, a MacBook Pro M5 Pro with 64 GB, the agent paused for up to 39 seconds before replying when a tool returned a large file. Every featured configuration in that benchmark used speculative decoding. And in Apple’s 15 October MLX tests, an M5 Ultra reached the first token of an 8,192-token prompt on Qwen 3.8 27B in 4.1 seconds against 18.2 on an M3 Ultra: the M5 generation’s Neural Accelerators speed prefill far more than decode.
In practice: prefer a mixture-of-experts model with few active parameters for an interactive agent (Qwen 3.6-35B-A3B decodes at community79 tok/s on a Mac mini M5 Pro, against sourced17 tok/s for the dense Qwen3.8-27B), keep the server running so its prompt cache stays warm, and on an M5-generation Mac use a runtime built on current MLX. oMLX keeps evicted cache blocks on the SSD and restores them when a later prompt starts with the same prefix, which is the pattern an agent produces. Ollama’s tok/s can be higher than the index’s figure because it turns on speculative decoding for some models; the Ollama MLX guide shows how to tell.
Tool-calling reliability: what the evidence says
No current, Mac-specific leaderboard measures how reliably local models call tools, and LLMCheck runs no tests of its own. What the published evidence supports:
- The chat template decides whether tools work at all. Ollama’s integration pages say to choose a model with tool support; the oMLX README says the model’s chat template must accept the
toolsparameter; llama.cpp’s server (with its Jinja templates, on by default) has native tool-call handlers for named model families and a generic fallback that “may consume more tokens and be less efficient”. - Moderate weight quantization did not separate builds in the one public Mac agentic suite. GAUNTLET Bench (data generated 12 October 2026, one M5 Max with 128 GB; most rows on LM Studio, six on Ollama) scores 14 builds at 100 on its agentic axis, among them Qwen3.8-27B from an IQ3_S GGUF to 4-bit MLX, Qwen 3.6-27B at 8-bit and Gemma 4 31B at 4-bit; its LM Studio Qwen3.8-27B builds at 5 and 6 bits scored 96–98. Its own control found identical files scoring up to 14.8 points apart, and 85% of its cells are single runs, so read small gaps there as noise.
- Keep the KV cache at 8 bits or more, per llama.cpp’s warning above.
- Vendor agentic scores are run on the vendor’s own scaffold. SWE-Bench and Terminal-Bench claims in model cards use the lab’s harness, and the index annotates the harness next to such claims; a figure from one scaffold does not predict another agent’s results.
The practical test is cheap: give the agent a small task in a scratch repository (read a file, change a function, run the tests) and watch whether it calls tools or prints them as text. A model that prints a JSON tool call instead of making it usually has a template the server does not recognise.
Related guides
- Local AI coding assistant on Mac: editor completion with Ollama and Continue.
- Best local LLM for coding on a Mac: the index’s coding picks by RAM tier.
- Ollama on MLX: which engine runs your model, and why its tok/s may include drafting.
- MCP with local LLMs and function calling.
- Multi-Mac clusters: when one Mac is not enough.