Sandbox: WSL2 on Windows 11
Two pieces:
- Ollama Desktop on Windows, using your GPU.
- Codehamr inside WSL2, a real Linux sandbox.
They talk to each other over plain localhost, thanks to WSL2 mirrored networking (Windows 11 22H2+). No Docker Desktop, no GPU passthrough.
For the plain non-sandboxed path see Run codehamr on Windows 11.
1. Install Ollama Desktop on Windows
Follow steps 1 and 2 of the Windows quickstart: install Ollama, lift the context length, pull a model.
Then let Ollama accept connections from WSL2 — by default it only listens on localhost. In PowerShell, set a Windows environment variable, then quit and restart Ollama from the system tray:
PowerShell
setx OLLAMA_HOST "0.0.0.0"
This exposes Ollama on your local network — fine on a trusted machine. Come back here.
2. Install WSL2
In PowerShell as administrator:
wsl --install
Reboot when Windows asks. Ubuntu launches and prompts for a Linux username and password, anything works.
Confirm:
wsl --status
You want Default Version: 2.
3. Enable mirrored networking
This makes localhost inside WSL2 reach your Windows host directly. Create the file %UserProfile%\.wslconfig (in your Windows user folder) with:
%UserProfile%\.wslconfig
[wsl2]
networkingMode=mirrored
Then restart WSL from PowerShell so it takes effect:
wsl --shutdown
4. Install codehamr inside WSL2
Inside the Ubuntu terminal:
curl -fsSL https://codehamr.com/install.sh | bash
codehamr --version
5. Point codehamr at the host's Ollama
In your project:
.codehamr/config.yaml
active: local
models:
local:
llm: your-model
url: http://localhost:11434
key: ""
context_size: 256000
With mirrored networking, localhost from WSL2 is your Windows host — exactly as if codehamr ran on Windows directly.
6. Run
codehamr
GPU on Windows, agent in Linux, your Windows files untouched.
If something doesn't work
From the WSL terminal:
curl -s http://localhost:11434/v1/models
- JSON back → all good, recheck
url:in your config. - Connection refused → Ollama Desktop isn't running, or you skipped
OLLAMA_HOST=0.0.0.0(set it, then restart Ollama). localhostwon't connect → mirrored networking isn't active. Check.wslconfigand that you ranwsl --shutdown. On Windows 10 (no mirrored mode), use the host IP instead: runip route show | grep -i default | awk '{print $3}'in WSL and put that IP inurl:.
VS Code
Install the WSL extension on Windows, then Ctrl+Shift+P → WSL: Open Folder in WSL. Run codehamr in the integrated terminal.