A coding agent on a local 27B model
OpenCode against Qwen3.8 27B on a MacBook: a 65k window that is mostly gone before the first file is read, memory kept off MCP, and an agent that looped forty times once reasoning was switched off.
In August and September 2026 I set up OpenCode against a single local model, Qwen3.8 27B, served by MTPLX on the laptop itself (an M1 Max with 64 GiB, later an M4 Max with 36 GiB). The configuration lives in opencode-config, next to the Claude Code setup it borrows most of its rules from. Most of the time went into measuring things, and a few of the measurements changed the setup.
The window
The usable context is about 65k tokens, and OpenCode’s system prompt plus its built-in tool definitions take roughly 9,600 of them before anything else happens. Restricting a tool through the permission block does not help with that, since the schema is still sent and the model still tries the call; the tools map is the setting that keeps a schema out of the request, and disabling six built-ins there took the tool block from 5,462 tokens to 2,551.
Memory stays off MCP
Claude Code on the same machine keeps its notes in Basic Memory, and I wanted OpenCode to read the same store. As an MCP server it advertises 23 tools, about 10,600 tokens of schemas on every request, which would have put a third of the window on the floor with the baseline. Two small wrapper tools calling the Basic Memory CLI cost 252 tokens instead.
The default search ranking was also wrong on my notes — “edgerouter backup” did not find the note about my EdgeRouter backups in the top four, while vector search put it first. With vector scores, unrelated notes came back between 0.72 and 0.75 and correct ones above 0.765, so the recall plugin keeps a result above 0.75 and otherwise injects nothing. That threshold comes from six queries against eleven notes, which is enough to run with and not enough to trust.
Leave the context window alone
The first real problem was requests dying on the M1 Max with nothing generated, each of them a cold prefill of around 50k tokens that pushed the server past its own memory cap. Smaller prefill chunks (2,048 instead of 8,192) fixed most of it and made prefill faster as well, 73 tokens per second instead of 47.
The obvious alternative was to halve the context window, and it would have made things worse. OpenCode compacts the conversation when it reaches the window, compaction rewrites the prompt and throws away the server’s prefix cache, and re-reading 53k tokens at 73 tokens per second takes about twelve minutes before the first output token. A three-hour session at the full window never compacted once, and decode slows only gradually as the context fills.
Switching reasoning off
Qwen’s reasoning mode costs time, so the natural speed-up is to turn it off. A single-turn benchmark said that was fine — every configuration passed almost everything, which meant the tasks were too easy to tell them apart.
The multi-turn test was a Terraform module to schedule an existing Glue job, with a least-privilege IAM role and a few deliberate ambiguities. With reasoning on at low effort the agent asked two questions before writing anything and finished in about sixteen minutes. With reasoning off it asked nothing, started writing files, and sent forty consecutive requests retrying the same failing edit until it hit the hour limit. Raising the presence penalty did not stop it, since that penalises repeated tokens within one answer and this was the same action repeated across turns; a frequency penalty produced Terraform with Python walrus operators in it. Both penalties are now at zero and reasoning stays on.
The reasoning-on runs were not clean either. Both invented aws_events_rule, which has never existed in the AWS provider, and when terraform validate caught it the model fixed the code and then explained the mistake as a provider-version difference. All of this is one run per configuration on one task.
aider for small edits
Most agentic CLIs depend on the model producing reliable native tool calls, which is exactly where local models are weakest. aider edits through search-and-replace blocks in plain text, and a real edit turn cost it 3,800 tokens in total. It cannot explore a repository or run its own tests, so it only suits changes to files I already know, but it is configured against the same server and I use it for those.
Was it worth it?
Yes. It does not compete with the frontier models I use for work, but at about twelve seconds a turn on the M4 Max it is plenty usable for simpler projects and for tasks with a limited scope, such as parsing logs. Most of the MTPLX bugs and peculiarities described above have receded in later versions, and the stock release no longer needs the finely tuned launcher this repo carries. I will probably revisit the setup before long, as models and servers change from one week to the next.
dmorel69/opencode-config— OpenCode, MTPLX, Qwen3.8 27B, Basic Memory