---
id: 16635
lang: en
title: "gpt-oss 20B runs in VS Code on 32 GB RAM: a custom Modelfile fixed the agent's failures"
published_at: "2026-10-28 08:00:18"
source_name: "Habr AI"
source_url: "https://habr.com/ru/articles/1100390/?utm_campaign=1100390&utm_source=habrahabr&utm_medium=rss"
canonical_url: "https://news.hamidun.com/en/news/16635"
categories: ["llm", "research"]
publisher: "AI News by Jemal Hamidun (news.hamidun.com)"
---

# gpt-oss 20B runs in VS Code on 32 GB RAM: a custom Modelfile fixed the agent's failures

> **Краткая суть (BLUF):** 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.  • A 40,960-token context fits prompts of up to 33.5K tokens, with KV-cache memory down 70% • A 512-token batch: cache checkpoints every ~35 seconds instead of every 3.5 minutes • Temperature 0.6 and an 8192-token limit: more 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.

---
- **Первоисточник:** [Habr AI](https://habr.com/ru/articles/1100390/?utm_campaign=1100390&utm_source=habrahabr&utm_medium=rss)
- **Каноническая ссылка:** https://news.hamidun.com/en/news/16635
- **Экосистема автора:** [Бесплатный интенсив по вайбкодингу — предзапись в Нике](https://t.me/vibecodeguidebot?start=agent_intensive_news_md) · [Nomad AI](https://nomadnet.ai) · [Telegram @jemal_hamidun](https://t.me/jemal_hamidun)
