Como rodar um agente de código totalmente offline com OpenCode, Ollama e Qwen3.5 (EN)
A walkthrough documented by a Thomson Reuters engineer shows how to set up a coding agent that runs entirely on a laptop, with no cloud, using OpenCode, Ollama, and the open model Qwen3.5.

Why coding without internet became an AI topic
Rittika Jindal is Principal Engineer at Thomson Reuters and moved to the foothills of the Himalayas a year ago. In an article published on Latent Space on October 27, she describes how she started planning her work around network and power outages, something that previously wasn't even part of the equation.
I moved to the foothills of the Himalayas a year ago. I love the peace of living here, but it also comes with its own challenges, including network and power outages.
Rittika Jindal, Principal Engineer at Thomson Reuters
The problem she describes isn't exclusive to living in the mountains. Anyone who has tried to review a pull request on a train, in a small inland town with an unstable connection, or during a flight knows that intermittent connectivity is also a reality here. The question she asked herself is direct: can you use a coding agent the way we use it day to day, but with Wi-Fi turned off?
The three pieces of the setup
The walkthrough combines three tools, each with a well-defined role:
- OpenCode: an open source coding agent that reads project files, proposes edits, and runs commands like the test suite, always asking for permission before acting.
- Ollama: serves the model locally, exposing a compatible API at
http://127.0.0.1:11434. - Qwen3.5: a family of open-weight models; you download the parameters once and run everything afterward, with no external calls.
If you prefer a more guided editing flow, Aider also appears as an option in the original text, since it also supports Ollama. Jindal chose to keep everything in the terminal with OpenCode so that the setup and results stayed consistent throughout the account.
Which Qwen size to choose
The model choice wasn't random. Jindal compared the numbers published in Qwen's model card across two benchmarks: LiveCodeBench v6, which measures code generation, and BFCL-V4, which evaluates function calling (the ability to pick the right tool and pass the correct arguments).
| Model | LiveCodeBench v6 | BFCL-V4 |
|---|---|---|
| Qwen3.5 4B | 55.8 | 50.3 |
| Qwen3.5 9B (used in the walkthrough) | 65.6 | 66.1 |
| gpt-oss-20b | 74.6 | not reported |
These numbers come from Qwen's model card, not from a measurement taken on the laptop used in the article. The 9B beat the 4B on both criteria, which justified the choice as a starting point, but the table says nothing about actual speed or about the model's behavior within OpenCode's full workflow.
How much RAM this actually requires
Download size is not the same thing as memory requirement, and this is a common trap for anyone trying a local model for the first time.
- Qwen3.5 4B: a download of approximately 3.3 to 4.0 GB.
- Qwen3.5 9B: a download of approximately 6.6 to 7.6 GB.
- Qwen3.5 27B: a download of 17 to 20 GB.
Ollama lists all available sizes, and the download varies depending on the runtime format. For the 6.6 GB build of Qwen3.5 9B, provider Voltti recommends reserving between 12 and 16 GB of memory; the 64,000-token context configuration used in the walkthrough's OpenCode setup may require even more space, so it's worth leaving extra RAM for context and for other open applications.
What agent benchmarks say about OpenCode
A detail the article raises that doesn't usually show up in product announcements: the preprint The Scaffold Effect in Coding Agents compared OpenCode, Goose, and OpenHands-SDK across 50 Terminal-Bench Pro tasks, using two cloud models (not the local Qwen).
| Agent | Qwen3.6 Plus | MiniMax M2.5 |
|---|---|---|
| Goose | 48% [34-62%] | 38% [24-52%] |
| OpenCode | 50% [36-64%] | 46% [32-60%] |
The brackets show the 95% confidence interval, and the study's authors note that most of the differences in success rate weren't statistically clear. The same study reported that OpenCode consumed about 40 times more tokens per solved task than Goose. Since these runs used cloud models different from the local Qwen3.5 9B, they can't be used to predict performance in the offline setup, but they help explain why it's worth measuring before trusting.
The walkthrough: from online setup to a bug fixed offline
With internet still available, the first step is to clone the Latent Space example repository and install OpenCode version 1.19.4, following the project's README. The opencode.json file is the project's configuration: in it, model and small_model both point to Qwen3.5 9B, baseURL points to http://127.0.0.1:11434/v1, only the local provider is enabled, and web tools are blocked.
With terminal B open, the command below starts Ollama listening only on localhost and disables cloud features:
OLLAMA_HOST=127.0.0.1:11434 OLLAMA_NO_CLOUD=1 OLLAMA_CONTEXT_LENGTH=65536 ollama serveIn terminal A, still online, download the model:
ollama pull qwen3.5:9bThe example used in the walkthrough is an expense calculator with a classic bug: the total variable is overwritten on each iteration instead of accumulated. Running python3 expense_total.py prints 8.00 instead of the correct value, 25.50, and python3 -m unittest -v shows three failing tests (decimal arithmetic, reimbursement, and the sample expense set).
Still online, Jindal opened OpenCode directly from the project folder with .tools/node_modules/.bin/opencode --pure and asked for a diagnosis without editing: "Read expense_total.py and run the tests. Explain the bug without editing any files." The agent found the tests on its own, but proposed pytest by default, even though the project uses Python's native unittest, which confirms a practical piece of advice: it's worth including the exact test command in the prompt from the start.
With the diagnosis validated, it's time to turn off Wi-Fi and disconnect Ethernet or phone internet sharing. To confirm that the local network still works and the external one doesn't, two commands:
curl --noproxy '*' --fail http://127.0.0.1:11434/api/tags
curl --noproxy '*' --connect-timeout 5 --max-time 10 --head https://example.comThe first keeps responding and lists the downloaded qwen3.5:9b; the second fails with "Could not resolve host", confirming there's no path out to the internet. With that verified, OpenCode is reopened with the same direct command, and the fix prompt asks: "Fix the bug in expense_total.py so the existing tests pass. Don't change the tests or install anything. Run the tests and explain your fix."
The fix proposed by Qwen was one line: replacing total = Decimal(amount) with total += Decimal(amount), asking for permission before applying the edit and then running the five tests. After the agent finished, the check was repeated manually outside OpenCode, confirming all five tests passing and the program returning 25.50.
What's still left to prove
The example repository includes two more exercises that, as of the article's publication, hadn't yet been run through the offline flow: a CSV report generator that groups rows by product and calculates revenue, and a log analyzer with bugs in error counting and in selecting the slowest request. Both already come with ready-made test suites, and they're the natural next candidates for testing how much the local model can handle beyond a one-line fix.
The author herself is clear about the limits of what was demonstrated: fixing a variable that doesn't accumulate value says nothing about how the model would do in a large repository or an unfamiliar framework. It's a starting point, not proof that the setup scales to the entire day-to-day job.
What changes for developers in Brazil
This walkthrough matters less for the exotic Himalayan setting and more for what it solves: running a coding agent without relying on an API key, without sending code to a third-party server, and without a token bill at the end of the month. For anyone working on a train, on a plane, in an area with an unstable inland connection, or simply wanting to test agents without putting a client's sensitive data at risk, it's a real alternative to try before recommending.
The price of this independence was also made clear in the material: the published benchmarks show that smaller open models, like Qwen3.5 9B, still lag behind larger options on LiveCodeBench and BFCL-V4, and that OpenCode itself tends to consume far more tokens per solved task than other agents, according to the Scaffold Effect study. In practice, this suggests starting small: well-defined tasks, with a test suite already in place to check the result, and the exact test command given to the agent beforehand, as the author herself recommends after the stumble with pytest.
Translated from the Brazilian Portuguese original · Read the original
Ollama strengthens tool calling with new models: how to build a 100% local agent
Ollama has supported structured function calling for a while, but the wave of models released between October 14 and 24, 2026 made this feature much more usable for building truly local agents.





