Skip to content

Back to the catalog

Coding From the Himalayas With an Offline AI Agent
latent.spacewriteup

Coding From the Himalayas With an Offline AI Agent

Walkthrough of running OpenCode against Qwen3.5 9B served by Ollama on a Mac, with Wi-Fi switched off. The author fixes a one-line accumulation bug in an expense calculator and confirms all five unittest tests pass. It covers the opencode.json setup, memory budgeting, permission prompts and a pytest-versus-unittest detour. Two further exercises (CSV report, log analyzer) were not yet run offline.

TL;DR Shows how to run OpenCode with Ollama and Qwen3.5 9B on a laptop with the network off, fixing a small bug against existing tests.
Document

What it claims

A Thomson Reuters principal engineer ran the OpenCode agent (version 1.19.4) against Qwen3.5 9B served by Ollama on a Mac with all network links off. The agent made a one-line fix, total = Decimal(amount) to total += Decimal(amount), and all five unittest tests passed. The author re-ran the tests by hand and confirmed the test file was unchanged. This is a single small task. The author states it says nothing about large repositories or unfamiliar frameworks.

How it works

OpenCode handles the project: it reads files, proposes edits and runs commands. Ollama serves the model on localhost. The project's opencode.json sets both model and small_model to Qwen3.5 9B. It points baseURL at http://127.0.0.1:11434/v1, enables only the local provider, asks before file edits and shell commands, and blocks web tools.

flowchart LR
  subgraph Mac["Mac, Wi-Fi off"]
    OC[OpenCode --pure] -->|localhost:11434| OL[Ollama, no cloud]
    OL --> Q[Qwen3.5 9B]
    OC -->|permission prompt| U[Engineer approves]
    U --> F[Edit files / run unittest]
  end
  OC -.web tools blocked.-x NET[Internet]

How to use it

Do everything that needs the network first: follow the companion repo's README, pull the model, and launch the exact offline setup once. Start Ollama in a second terminal:

OLLAMA_HOST=127.0.0.1:11434 OLLAMA_NO_CLOUD=1 OLLAMA_CONTEXT_LENGTH=65536 ollama serve
ollama pull qwen3.5:9b
.tools/node_modules/.bin/opencode --pure

--pure disables external plugins. After switching off Wi-Fi, Ethernet and tethering, check that the local API still answers and that outside hosts do not:

curl --noproxy '*' --fail http://127.0.0.1:11434/api/tags
curl --noproxy '*' --connect-timeout 5 --max-time 10 --head https://example.com

Put the exact test command (python3 -m unittest -v) in the prompt. Without it, Qwen first proposed pytest, and the permission prompt is what caught the mistake.

Memory: the Qwen3.5 9B build downloads at 6.6 GB. A third-party source (Voltti) budgets 12 to 16 GB of RAM for it. The 64k-token context used here may need more.

Evidence

The model choice rests on scores from Qwen's own model card, LiveCodeBench v6 and BFCL-V4, comparing it with the 4B variant. These were not measured on the laptop. For the agent, the author cites the preprint "The Scaffold Effect in Coding Agents." It compared OpenCode, Goose and OpenHands-SDK on 50 Terminal-Bench Pro tasks with two cloud models. Most pass-rate differences were not statistically clear. OpenCode used about 40 times Goose's tokens per solved task, which matters for local inference speed. Those runs do not predict local Qwen performance.

Limits

Only the expense example ran offline. The CSV report and log analyzer exercises have seven tests each and were not run. The page reports no speed or latency figures. Installing packages and looking things up on the web still need a connection, so dependencies and docs must already be on disk. The examples use only the Python standard library, which hides that problem.

Organisations named here

  • Thomson Reuters
  • Qwen
  • Ollama
  • OpenCode
  • Voltti
  • Latent Space
  • BFCL-V4
  • LiveCodeBench
  • OpenHands
  • Terminal-Bench

Technologies named here

  • OpenCode
  • Qwen3.5-9B
  • Ollama
  • Qwen3.5-4B
  • Qwen
  • Aider
  • Goose
  • OpenHands-SDK
  • Python unittest
  • pytest
  • Qwen3.5
  • OpenHands
  • macOS
  • Python

Techniques named here

  • Test-driven agent task