gpt-oss 20B runs in VS Code on 32 GB RAM: a custom Modelfile fixed the agent's failures
The gpt-oss 20B model (20 billion parameters, MoE: only part of the parameters are active for each word) fits into 32 GB of RAM, but in the Kilo Code plugin for VS Code it goes off the rails: it calls bash without a command and floods the output with reasoning. According to the author of the Habr analysis, the culprit is the default Ollama template, not the hardware. He offers his own Modelfile with a 40,960-token context. If a local agent is babbling, check the template first.
AI-processed from Habr AI; edited by Hamidun News
Many developers want to move an AI assistant onto their own computer. Some are held back by corporate security rules, some don't want to send their code to the cloud, and some are simply curious. Hardware has long stopped being the main obstacle.
The gpt-oss 20B model has about 20 billion parameters, but it is built on the MoE (Mixture of Experts) scheme: only a portion of those parameters is activated for each word. That is why it gets by with 32 GB of ordinary RAM and does not need a top-end graphics card. The real problem lies elsewhere.
If you connect this model via Ollama (a program for running models locally) to the Kilo Code plugin for VS Code, it starts behaving strangely right out of the box. A Habr analysis explains why this happens and how to fix it with a Modelfile, that is, the settings Ollama uses to assemble the prompt.
What breaks out of the box
The scenario is familiar. You download the model, install Kilo Code, connect it to a local Ollama server, and ask it to find problems in a repository. Instead of help, the logs fill with a stream of reasoning.
The model tries to call a tool called repo_browser.search, which the plugin doesn't have; it has grep, read, edit, bash, and others. Then it calls bash without the required command argument and gets an error.
Next it analyzes its own failure, gets confused about whether the user had asked anything at all, and ends up delivering a lecture on how to call bash correctly. Nobody asked for that. At the end of the log, the speed reads about 3.
1 tokens per second.
The author argues that the weak model is not to blame. The default Ollama template, in his account, doesn't know how to properly prepare tools for complex plugins like Kilo Code. As a result, the model mixes up its internal reasoning with its answer to the user, and tool calls arrive with errors.
What changes in the Modelfile
The author creates a custom Modelfile based on gpt-oss:20b and rewrites the template. Strict calling rules are added to the system prompt: one tool per turn, and arguments must be strictly valid JSON with escaped quotes and newlines. Tool calls are routed to a separate commentary channel. Tool results, such as console output, are passed back to the model even when the tool's name isn't known in advance. In addition, the reasoning level is fixed at Reasoning: low.
The parameters are tuned for CPU generation:
- num_ctx 40960. A 40K-token window fits the plugin's prompts of up to 33.5K tokens and, according to the author's estimate, saves about 70% of KV-cache memory (the memory where the model stores context it has already read);
- num_batch 512. Cache checkpoints are saved roughly every 35 seconds instead of every 3.5 minutes;
- num_predict 8192. The limit is enough for reasoning and a large diff;
- temperature 0.6 and top_p 0.95. Less randomness means more stable code and strict JSON in tool calls;
- num_thread 4.
How to apply it and what to watch for
The procedure is standard for Ollama: save the config to a Modelfile, build your own version of the model from it with the ollama create command, then in the Kilo Code settings select the Ollama provider and the name of the new model. This keeps private code on your machine.
There are caveats. The figures on memory savings and checkpoint frequency come from the author himself; there are no independent measurements. Speed on a CPU is modest, and the rule "one tool per turn" lengthens action chains. The template shown is tailored to a specific combination of model, Ollama, and plugin, and on other versions it will need to be verified.
The practical takeaway goes beyond this one case. When a local model starts babbling inside an agentic plugin, look first at the prompt template and the handling of tool calls, and only then at model size and memory. For teams that cannot send code to the cloud, this is an inexpensive route to a working assistant on an ordinary 32 GB workstation.
- Dec 2, 2026Ai2 Releases MolmoWeb2 Web Agents: 27B Model Solves 75.3% of Tasks
- Dec 2, 2026Amazon Releases Ergo Open Weights for Coding: 1.1 Trillion Parameters and 2,200 Tokens per Second
- Dec 2, 2026OpenAI Opens Dots Agent to ChatGPT Plus Subscribers With 10,000+ Plugins
- Dec 2, 2026FSK Group Has Launched 395 AI Agents in Six Months, with a 97.7% Success Rate
Key Questions Answered
What breaks out of the box?
The scenario is familiar. You download the model, install Kilo Code, connect it to a local Ollama server, and ask it to find problems in a repository. Instead of help, the logs fill with a stream of reasoning. The model tries to call a tool called repo_browser.search, which the plugin doesn't have; it has grep, read, edit, bash, and others. Then it calls bash without the required command argument and gets an error.
What changes in the Modelfile?
The author creates a custom Modelfile based on gpt-oss:20b and rewrites the template. Strict calling rules are added to the system prompt: one tool per turn, and arguments must be strictly valid JSON with escaped quotes and newlines. Tool calls are routed to a separate commentary channel. Tool results, such as console output, are passed back to the model even when the tool's name isn't known in advance. In addition, the reasoning level is fixed at Reasoning: low.
How to apply it and what to watch for?
The procedure is standard for Ollama: save the config to a Modelfile, build your own version of the model from it with the ollama create command, then in the Kilo Code settings select the Ollama provider and the name of the new model. This keeps private code on your machine. There are caveats. The figures on memory savings and checkpoint frequency come from the author himself; there are no independent measurements. Speed on a CPU is modest, and the rule "one tool per turn" lengthens action chains.
Test Frontier LLMs & Autonomous Agents in One Workspace
Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.
Daily 60-sec AI Voice Brief + Weekly Production AI Agent Playbook
Listen to a 60-second AI news brief every morning and get a weekly hands-on playbook for shipping AI agents to production — tools, MCP servers and patterns that work. Curated by Jemal Hamidun, Head of AI at Alpina Digital.
