Free · Daily brief + weekly playbookDaily 60-sec AI Voice Brief + Weekly Production AI Agent PlaybookGet the brief →
ReleaseInsight · On RadarHabr AI→ original

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
gpt-oss 20B runs in VS Code on 32 GB RAM: a custom Modelfile fixed the agent's failures
Source: Habr AI. Collage: Hamidun News.
Listen to article
Article Fact Sheet & Key Figures
ParameterDetails
Primary sourceHabr AI ↗
Editor-in-Chief
Key metric #1A 40,960-token context fits prompts of up to 33.5K tokens, with KV-cache memory down 70%
A 512-token batchcache checkpoints every ~35 seconds instead of every 3.5 minutes
Temperature 0.6 and an 8192-token limitmore stable code and JSON for tool calls

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.

Story

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.

ZK
Zhemal Khamidun — Head of AI at Alpina Digital · MIPT (academic supervisor of the Tech Entrepreneurship department). Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Unified AI Workspace · Nomad

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.

Try Nomad AI →Launch Nomad Agent
Jemal Hamidun

Editor-in-chief · Cite this analysis

Jemal Hamidun

Head of AI at Alpina Digital · Academic Supervisor of the Tech Entrepreneurship Department at MIPT

Head of AI & CPO of AlpinaGPT at Alpina Digital, Academic Lead of Tech Entrepreneurship at MIPT. Founder of Hamidun News and Vibe Academy.

Ready-to-paste citation for journalists, blogs and Telegram channels

Source: Hamidun News — gpt-oss 20B runs in VS Code on 32 GB RAM: a custom Modelfile fixed the agent's failures https://news.hamidun.com/en/news/16635/gpt-oss-20b-runs-in-vs-code-on-32-gb-ram-a-custom-modelfile

What do you think?
Loading comments…