Offline Coding Agent: What OpenCode and Qwen3.5 9B Can Do

Offline Coding Agent: What OpenCode and Qwen3.5 9B Can Do

Agentic AI

A 6.6 GB model on a laptop, with Wi-Fi switched off, fixed a failing test in one line. A Thomson Reuters principal engineer living in the Himalayan foothills ran that test for Latent Space, and it shows developers who code on flights or through outages exactly how much of a coding-agent workflow survives without a connection. It’s enough for small, test-backed fixes, but only if the setup is done while still online.

The Framework

The Latent Space walkthrough pairs three tools. OpenCode, an open-source terminal coding agent, reads files, proposes edits and runs commands. Ollama serves the model locally. Qwen3.5 9B, an open-weight model, does the reasoning. The test task was a small expense calculator whose function replaced its running total instead of adding to it, so three of five tests failed. Offline, the agent proposed changing total = Decimal(amount) to total += Decimal(amount), asked permission to edit, and ran the tests. The author then reran them independently, and they passed.

The author’s setup choices sort into five decisions.

1. Pick the Model for Tool Use, Not Just Coding

The author chose Qwen3.5 9B over the 4B model because its published scores were stronger on both coding and function calling. Per Qwen’s model card, cited in the post, the 9B scores 65.6 on LiveCodeBench v6 and 66.1 on BFCL-V4, against 55.8 and 50.3 for the 4B. Function calling matters because an agent has to pick the right tool and pass it the right arguments. The author notes these are published scores, not measurements from the laptop.

2. Budget Memory Beyond the Download

The 9B download is 6.6 to 7.6 GB, but download size isn’t the RAM requirement. The post cites a 12 to 16 GB memory budget for a 6.6 GB build, and warns that its 64k-token OpenCode context may need more.

3. Lock the Agent to Localhost

The project’s opencode.json points both the main and helper model at Ollama on 127.0.0.1, enables only the local provider, asks before editing files or running shell commands, and blocks web tools. Ollama is started with its cloud features disabled. The author still disconnects the network and checks that localhost answers while an external address fails.

4. Give the Agent the Exact Test Command

While online, OpenCode first proposed pytest, though the project uses Python’s built-in unittest. The permission prompt caught it. The author’s fix is to put python3 -m unittest -v in the prompt.

5. Keep Tasks Small and Verify Yourself

The author kept the original tests unchanged and reran them outside the agent. Two harder exercises, a CSV report and a log analyzer, ship in the companion repo, but their offline runs aren’t done yet.

Where It Doesn’t Apply

Anything that needs a package download or a web lookup still needs a connection. The author is explicit that a one-line fix says nothing about a large repository or an unfamiliar framework. The post also cites a preprint where OpenCode used about 40 times Goose’s tokens per solved task on cloud models. That doesn’t predict local performance, but it matters when a laptop’s memory is the limit. Stack Archive’s look at Bonsai 27B running on an iPhone covers fitting a larger Qwen model onto an even smaller device.

The So What

Developers who expect to lose connectivity should do the whole setup online first: download the model, dependencies and docs, and launch the exact offline configuration once. Then use the local agent for small, test-backed fixes. Nothing here shows a 9B model can replace a cloud agent on a large codebase, so plan offline sessions around small tasks you can check yourself.

Source: Latent Space

Content created with AI assistance and reviewed for accuracy.

💬

Join the conversation

Stack Insiders is our free community for readers who want to go deeper — share resources, ask questions, and connect with others across every vertical we cover.

Join Stack Insiders →

Newsletter coming soon.

Curated digests across AI, biohacking, photography, travel, and more. Be the first to know when we launch.