AI

Self-Host OpenHands with Docker and Ollama on Linux

I wanted OpenHands talking to a model on my own box, with no API bill, so I gave it an afternoon with Ollama and then went back for a second round when Agent Canvas 1.47.0 landed with a new DNS-rebinding guard. The container comes up in under 20 seconds. Getting a small local model to finish one real task through it is the slow part, and two models failed in two different ways before a third one passed.

Original content from computingforgeeks.com - post 188758

These notes cover the Docker command that works, what the rebinding guard does and doesn’t protect, the first-run screens, and the four things that broke between the container and Ollama. They also put the same openhands ollama install next to a hosted model through LiteLLM, on the same task. I reran all of it on November 30, 2026 on box1, an 8 vCPU, 31 GB Ubuntu 26.04.1 LTS VM with Docker 29.1.3 and Ollama 0.40.19 on CPU only, against Agent Canvas 1.47.0 with agent server 1.65.0, and every prompt below comes from that box.

Working out what OpenHands runs today

The maintained way to self-host OpenHands is Agent Canvas, one container image at ghcr.io/openhands/agent-canvas that bundles the web UI, the agent server and an automation service behind a single port, 8000. You point it at any OpenAI-compatible endpoint, Ollama included, and the agent’s terminal and file edits run inside that same container. I pinned the tag that actually ran, and its image labels confirm it:

docker image inspect ghcr.io/openhands/agent-canvas:1.47.0 --format '{{json .Config.Labels}}' | jq .

The version label and the revision are what you’d quote in a bug report:

{
  "org.opencontainers.image.description": "All-in-one agent-canvas: Agent Server + Automation + Frontend",
  "org.opencontainers.image.revision": "02f5e035cdcb08eb4df5bdc430a3553dfd07a720",
  "org.opencontainers.image.source": "https://github.com/OpenHands/OpenHands",
  "org.opencontainers.image.title": "agent-canvas",
  "org.opencontainers.image.version": "1.47.0"
}

Does it need the Docker socket, like the old OpenHands that started a sandbox container per conversation? The agent server answers that itself. Its /server_info endpoint inside the container reports version 1.65.0 and a local conversation runtime with no other runtimes available:

docker exec agent-canvas curl -s http://127.0.0.1:18000/server_info

I trimmed the JSON to the three fields that matter:

{
  "version": "1.65.0",
  "conversation_runtime": "local",
  "available_conversation_runtimes": []
}

So you don’t mount /var/run/docker.sock. The image ships a docker client, but inside the running container the socket doesn’t exist and docker info fails to connect, yet every task below ran fine. The flip side is that the agent shares one container with its own server, so whatever you bind-mount into /projects is what it can touch. The process runs as uid 10001 and sits in the container’s sudo group, which matters for the permission errors further down.

Prerequisites and sizing

Idle with the UI open, the container used about 900 MiB. The model is what decides your hardware, and the prompt size is what surprised me. OpenHands sends a system prompt plus tool schemas of about 14,000 tokens on the first turn of a conversation, before your task adds much. I’d plan for this much:

  • Docker Engine on Linux, any recent release
  • Ollama on the same host, with a model that supports tools
  • Context of at least 22000 tokens per the docs; I used 32768
  • RAM: 2 GB for the stack, plus about 7.6 GB per loaded 4B model at that context
  • A GPU if you want answers in seconds; CPU works, but turns take minutes

My 8 vCPU box is a floor for trying it, not a target. If you plan to use OpenHands daily on a local model, the sizing driver is prompt processing speed on a 14,000 token prompt, which on this CPU started near 30 tokens per second and sank below 15 as the prompt grew. A GPU with 12 GB or more of VRAM should move that a long way, though I haven’t measured it. If Ollama isn’t installed yet, my colleague’s Ollama setup on Ubuntu 26.04 covers it.

Running Agent Canvas in Docker

Make the project folder first. The agent works in /projects inside the container, and that path is a bind mount of a folder you own on the host:

mkdir -p ~/projects

My first container exited within seconds with Exited (1), on 1.47.0 exactly as on the older release I started with. The image runs as uid 10001, and a folder created by your login user is drwxrwxr-x owned by you, so uid 10001 can read it but not write. Grant that uid access with an ACL, including a default ACL so new files inherit it:

sudo apt-get install -y acl
sudo setfacl -m u:10001:rwx -m d:u:10001:rwx ~/projects

The container’s own log spells out the fix, and getfacl confirms the two entries afterwards:

Agent Canvas container exiting with Workspace directory is not writable /projects, fixed with setfacl for uid 10001

That covers an empty folder. If you mount a folder that already holds code, add -R and use rwX so existing files get access too, since the error message says existing project files need read and write access:

sudo setfacl -R -m u:10001:rwX -m d:u:10001:rwX ~/projects

The capital X grants execute only on directories and files that are already executable.

Now start the container. This is the documented Docker quickstart, run detached with a name and a pinned tag, plus one flag I had to add, --add-host, which the Ollama section explains. The port is published on 127.0.0.1 only, and that’s deliberate:

# https://github.com/OpenHands/OpenHands/releases/tag/v1.47.0
docker run -d --name agent-canvas \
  --add-host host.docker.internal:host-gateway \
  -p 127.0.0.1:8000:8000 \
  -v openhands-data:/home/openhands/.openhands \
  -v ~/projects:/projects \
  ghcr.io/openhands/agent-canvas:1.47.0

My first round used -e AGENT_CANVAS_ALLOW_LAN_SESSION_KEY=true, which embeds the backend’s session key in the page so the browser connects without asking. I dropped it after testing the rebinding guard in the next section, and you’ll paste the key once instead. The named volume openhands-data holds the generated keys, settings and conversations, so it survives docker rm. Give it about 20 seconds, then check the logs:

docker logs agent-canvas 2>&1 | grep '^\[agent-canvas\]'

You want all three services ready and a single entry point on port 8000. On a fresh volume it also generates the keys, including the session key you’ll need in a minute. This log is from my first start, which still had the LAN option on, so I removed the one warning line that option adds:

[agent-canvas] Generated OH_SECRET_KEY (persisted to /home/openhands/.openhands/agent-canvas/secret-key.txt)
[agent-canvas] Generated API key (persisted to /home/openhands/.openhands/agent-canvas/api-key.txt)
[agent-canvas] Pinned AUTOMATION_KV_SECRET (persisted to /home/openhands/.openhands/agent-canvas/automation-kv-secret.txt)
[agent-canvas] Starting agent-server on port 18000...
[agent-canvas] Starting automation server on port 18001...
[agent-canvas] Using SQLite database: sqlite+aiosqlite:////home/openhands/.openhands/automation/automations.db
[agent-canvas] Agent Server is ready on port 18000
[agent-canvas] Automation Server is ready on port 18001
[agent-canvas] Starting frontend + proxy on port 8000...
[agent-canvas] All services started. Unified entry point: http://0.0.0.0:8000/

Print the session key, because the first screen of the UI asks for it:

docker exec agent-canvas cat /home/openhands/.openhands/agent-canvas/api-key.txt

Open http://127.0.0.1:8000/canvas/ in a browser on the same machine. On a headless server like mine, forward the port over SSH from your laptop with ssh -L 8000:127.0.0.1:8000 [email protected] and open the same URL locally.

Testing the DNS-rebinding guard

Release 1.47.0 added Host and Origin checks against DNS rebinding and cross-site WebSocket hijacking (PR #20061). I wanted to know two things: does it break host.docker.internal traffic to Ollama, and does it protect the Docker setup at all? It does neither. The guard only switches on when the listener binds to loopback, and inside the container the proxy binds 0.0.0.0, which the code leaves permissive on purpose for reverse proxies and Docker. Here’s the check in bind-host.mjs:

docker exec agent-canvas grep -n 'OH_ALLOWED_HOSTS\|isLoopbackBind' /opt/agent-canvas/bind-host.mjs

Line 153 returns early for any non-loopback bind, before a single header is inspected:

19:export function isLoopbackBind(host) {
103:  return isLoopbackBind(hostname) || LOCALHOST_SUBDOMAIN_RE.test(hostname);
108: * comma-separated `OH_ALLOWED_HOSTS`: the public name of a tunnel or reverse
116:    String(env.OH_ALLOWED_HOSTS ?? "")
141: * nor in `OH_ALLOWED_HOSTS` (DNS rebinding), and reject WebSocket upgrades or
153:  if (!isLoopbackBind(bindHost)) return false;
205:  const loopback = isLoopbackBind(host);

Outbound calls from the agent server to Ollama never pass through that proxy, so the guard can’t break them, and the container’s curl to host.docker.internal:11434 kept working. Inbound is the part to worry about. A request with a forged Host: attacker.example header still got a 200 for /canvas/, and with the LAN session key option on, the page served to that forged host carried the session key in its HTML. Recreating the container without the variable removed the key from both pages, and the API refused requests without it:

Agent Canvas 1.47.0 serving the session API key in HTML for a forged Host header with the LAN option on, and 401 on the API without it

What should you take from that? On a box where only you can reach 127.0.0.1:8000, the forged-host page is a lab curiosity, because a rebinding attack needs a browser that can already reach the port. But the guard you might assume 1.47.0 added doesn’t cover this deployment, so the session key is the real lock. Leave AGENT_CANVAS_ALLOW_LAN_SESSION_KEY off and paste the key yourself.

Walking through the first-run screens

The first-run flow changed since my earlier round. Without the embedded key, 1.47.0 opens on an “Add a backend” screen, and onboarding now runs through five steps:

  1. Add a backend: host URL plus the session key
  2. Telemetry consent, saved per backend
  3. Choose your agent: OpenHands, Claude Code, Codex, Gemini CLI, Pi or OpenCode
  4. Set up your LLM, with Basic and Advanced tabs
  5. Say hello, a chat box with suggested automations

On the backend screen, the Host is the URL your browser uses to reach the container, which is http://127.0.0.1:8000 over the tunnel, and API Key is the value from api-key.txt:

Agent Canvas 1.47.0 Add a backend screen with the host URL, the session API key field and the Next button marked

Click Next, answer the telemetry prompt, and the agent picker comes up. Pick OpenHands. The other five entries run those agents inside Agent Canvas, which I didn’t test here:

Agent Canvas onboarding screen with the OpenHands agent selected and the Next button marked

The LLM step pre-selects a hosted OpenAI model on its Basic tab. Ollama goes in Advanced, which I’ll fill in once the plumbing below works.

Pointing OpenHands at Ollama

My first attempt failed before the model ever saw a token, because nothing between the container and Ollama was set up for it. Across both rounds, I hit these in order:

  1. Plain quickstart container: host.docker.internal didn’t resolve
  2. With --add-host: it resolved to 172.17.0.1, connection refused
  3. Ollama on 0.0.0.0: reachable, but its context was 4096 tokens
  4. Context raised: model unloaded after 5 idle minutes, so I raised keep-alive too

The fixes are a Docker flag, a systemd override and a firewall rule. On Linux, Docker only creates the host.docker.internal name when you pass --add-host host.docker.internal:host-gateway, which is why it’s in the run command above. Ollama installs listening on 127.0.0.1 only, so it needs to listen on more than loopback, and it needs a bigger default context. Open an override for the service.

sudo systemctl edit ollama

Add these three variables under a [Service] header, then save.

[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"
Environment="OLLAMA_CONTEXT_LENGTH=32768"
Environment="OLLAMA_KEEP_ALIVE=30m"

Restart Ollama and confirm it now listens on every address rather than 127.0.0.1.

sudo systemctl restart ollama
ss -ltn | grep 11434

Look for an asterisk in the local address column.

LISTEN 0      4096               *:11434            *:*

Ollama has no authentication, so binding it to 0.0.0.0 on a server with a public address would hand your models to anyone. I let only the Docker bridge subnet in and denied the port for everyone else. Add the allow rule before the deny, because UFW stops at the first match. ufw allow OpenSSH opens port 22 only, so allow your real SSH port first if it differs, or enabling UFW locks you out.

sudo ufw allow OpenSSH
sudo ufw allow from 172.17.0.0/16 to any port 11434 proto tcp
sudo ufw deny 11434/tcp
sudo ufw --force enable

Test it from inside the container, which is the path OpenHands will use. A JSON model list means the name resolves, the port is open and Ollama answers.

docker exec agent-canvas curl -sS -m 5 http://host.docker.internal:11434/v1/models

The screenshot shows the whole sequence on box1: refused while Ollama sat on loopback, then the UFW rules in order and the model list once both were fixed.

curl inside the agent-canvas container refused on host.docker.internal port 11434, then UFW rules allowing 172.17.0.0/16 and the Ollama model list

That list only shows what’s pulled. The model that finished my test comes later in this post, so pull it now and the settings below point at something real:

ollama pull qwen3:4b-instruct

Back in the browser, open the Advanced tab of the LLM step and fill three fields. The openai/ prefix on the model routes it through LiteLLM’s OpenAI-compatible client, and the key is a placeholder because Ollama does not check it, though the form will not save it empty.

  • Custom Model: openai/qwen3:4b-instruct
  • Base URL: http://host.docker.internal:11434/v1
  • API Key: local-llm, or any other text

Leave the Authentication dropdown above them on “API key” for Ollama:

Agent Canvas Advanced LLM settings with openai/ model tag, Ollama base URL on host.docker.internal and a placeholder API key

Click Next and onboarding saves an LLM profile named after the model, qwen3-4b-instruct, with the default 300 second timeout. That default is the next problem. The OpenHands docs page on local LLMs describes the same three fields if you want the official wording.

Finding a small model that finishes on CPU

I gave every model the same task in a new conversation: “In /projects/demo create fizzbuzz.py with a fizzbuzz(n) function, and test_fizzbuzz.py with unittest cases for 3, 5, 15 and 7. Run python3 -m unittest in /projects/demo and tell me the result.” It’s small enough for a 4B model, and it needs the terminal, the file editor and a test run. In my first round, on Agent Canvas 1.39.0 earlier in November, three models tried it:

Model (Ollama tag)What happenedResult
qwen2.5-coder:7bTwo 300 s timeouts on the first prompt, then printed the tool call as JSON textNo files written
qwen3:4bThinking never switched off; a 162-token title request generated 3,616 tokens in 11 minutesAbandoned
qwen3:4b-instructFirst prompt took about 20 minutes, then 2 to 5 minutes per turn with real tool calls4 tests passed, about 47 minutes end to end

On 1.47.0 I went straight to qwen3:4b-instruct, and the onboarding profile failed the same way the 7B model did. The first prompt was 14,058 tokens, Ollama processed it at about 27 tokens per second, and LiteLLM cut the request at 4m50s. The retry reused 7,171 cached tokens from Ollama’s slot, which looked promising, but prompt processing slowed to about 15 tokens per second deeper into the context and the second attempt died too. This release gives up after two attempts and says so plainly:

docker logs agent-canvas 2>&1 | grep -o 'litellm.Timeout: LLM hard timeout.*total)'

The 608 seconds is two 300 second attempts plus the backoff between them:

litellm.Timeout: LLM hard timeout after 300 seconds. The model did not return a complete response within the LLM timeout of 300s (gave up after 2 attempts, 608s in total)

The capture below pairs the retry log with Ollama’s journal, where both requests end in a 500 after exactly 4m50s:

OpenHands log with two litellm Timeout attempts and Ollama journal showing a 14,058 token prompt, 7,171 cached tokens on retry and two 500 responses after 4m50s

Raising the timeout is the first change any CPU setup needs. In Settings, open LLM, click Add LLM Profile, switch to the All tab and set Timeout to 1200. I named mine qwen3-4b-cpu, because a duplicate of the onboarding profile’s name keeps the Save button disabled. Note the Stream Idle Timeout field next to it, also 300 by default, which only applies to streaming responses:

Agent Canvas LLM profile settings with the Timeout field raised to 1200 seconds for a CPU-only Ollama model

Saving it logged one more timeout, from the profile’s validation request, which waited behind the conversation Ollama was still chewing on. The profile saved anyway. Pick it per conversation from the model menu under the chat box.

With the longer timeout, the same prompt finished in 19 minutes 48 seconds. Most of that was the first turn, a single 12m40s request. Ollama reused 5,005 cached tokens of the 14,397-token prompt, processed the other 9,392 at 20 tokens per second falling to 14, then generated 235 tokens at 2.55 per second. After that the prompt cache did its job, and the five follow-up turns took between 46 seconds and 2m10s each:

journalctl -u ollama --since 02:38 --no-pager | grep GIN

The 4.35s line is the conversation title; the rest are agent turns:

[GIN] 2026/11/30 - 02:38:52 | 200 |    4.35s |      172.17.0.2 | POST     "/v1/chat/completions"
[GIN] 2026/11/30 - 02:51:33 | 200 |   12m40s |      172.17.0.2 | POST     "/v1/chat/completions"
[GIN] 2026/11/30 - 02:52:21 | 200 |   48.14s |      172.17.0.2 | POST     "/v1/chat/completions"
[GIN] 2026/11/30 - 02:53:49 | 200 |    1m20s |      172.17.0.2 | POST     "/v1/chat/completions"
[GIN] 2026/11/30 - 02:55:38 | 200 |    1m40s |      172.17.0.2 | POST     "/v1/chat/completions"
[GIN] 2026/11/30 - 02:56:24 | 200 |   45.97s |      172.17.0.2 | POST     "/v1/chat/completions"
[GIN] 2026/11/30 - 02:58:35 | 200 |    2m10s |      172.17.0.2 | POST     "/v1/chat/completions"

The model made five tool calls. Its first file write failed with [Errno 2] No such file or directory: '/projects/demo/.fizzbuzz.py.4frn0nuu.tmp' because the folder didn’t exist yet, so it ran mkdir -p, wrote both files again and ran the tests. That’s a 4B model recovering from its own mistake, which it couldn’t do at 300 seconds:

OpenHands conversation on qwen3:4b-instruct over CPU Ollama reporting all 4 FizzBuzz unit tests passed, with the qwen3-4b-cpu profile selected

That’s down from about 47 minutes on 1.39.0 for the same model and task, though round one also lost time to three requests that hit the 1200 second timeout and ended in a 500, so I wouldn’t credit the whole gap to the new release.

Why did qwen3:4b fail in round one? Agent Canvas sent reasoning_effort: "high" by default, and ollama show qwen3:4b lists its thinking capability with levels true and default true. Setting Reasoning Effort to none in the profile didn’t stop it. Ollama’s OpenAI compatibility docs map none to thinking off for models with a plain on/off switch, and a model that advertises levels may not count as one. A direct request to Ollama with the same value still came back with the model musing until it hit the token limit. The instruct variant answered without a thinking phase on every turn I watched, which is why it’s the one I’d start with.

Switching the same install to a hosted model

Every model call in OpenHands goes through LiteLLM, so a hosted model is just another profile on the same install. I planned to use OpenRouter, but the account had no credit left, so I used an Anthropic key instead. Add another profile on the All tab with three fields:

  • Profile Name: claude-haiku-5-5
  • Custom Model: anthropic/claude-haiku-5-5
  • API Key: your Anthropic key, Base URL left empty

The anthropic/ prefix is LiteLLM’s provider route, the same job openai/ does for Ollama. For OpenRouter it would be openrouter/ plus the model ID from OpenRouter’s catalogue and an OpenRouter key. The key field shows a green check once it’s saved:

Agent Canvas Add LLM Profile screen with profile name claude-haiku-5-5, model anthropic/claude-haiku-5-5 and a redacted API key

I sent the same FizzBuzz prompt, pointed at /projects/demo-hosted, from a new conversation on that profile. It checked whether the folder existed, tested that /projects was writable, ran mkdir -p, wrote both files, ran the tests and reported back 16 seconds after I hit send:

OpenHands conversation on Claude Haiku 5.5 creating fizzbuzz.py and test_fizzbuzz.py and reporting 4 unit tests passed

I don’t take an agent’s word for a passing test, so I reran the suite. From the host shell it failed with PermissionError: [Errno 13], because the file editor writes files with mode 0600 and the ACL mask drops to ---, leaving my own user locked out of what the agent wrote. Running the tests as the container’s user is the honest check:

docker exec -w /projects/demo-hosted agent-canvas python3 -m unittest -v

All four cases pass:

test_multiple_of_15_returns_fizzbuzz (test_fizzbuzz.TestFizzBuzz.test_multiple_of_15_returns_fizzbuzz) ... ok
test_multiple_of_3_returns_fizz (test_fizzbuzz.TestFizzBuzz.test_multiple_of_3_returns_fizz) ... ok
test_multiple_of_5_returns_buzz (test_fizzbuzz.TestFizzBuzz.test_multiple_of_5_returns_buzz) ... ok
test_multiple_of_7_returns_number_as_string (test_fizzbuzz.TestFizzBuzz.test_multiple_of_7_returns_number_as_string) ... ok

----------------------------------------------------------------------
Ran 4 tests in 0.000s

OK

Here are the two runs side by side, both on 1.47.0, same prompt, same container:

qwen3:4b-instruct on CPU (Ollama)Claude Haiku 5.5 (Anthropic API)
Profile changeTimeout raised to 1200New profile, model and key
Time to finish19m48s16 s
Tool calls5, one failed and retried7, including a UI navigation
Prompt tokens89,885 (79,621 cached)138,931 (114,192 cached)
Completion tokens1,0341,944
Cost$0 (electricity)$0.0052
Tests4 passed4 passed
fizzbuzz(7) returns7, an integer"7", a string

Both finished, and both test suites pass when I run them myself. The hosted model was about 74 times faster for half a cent, and it wrote the more conventional FizzBuzz, returning strings for every input. The local model’s version returns the number itself for 7, and its test asserts exactly that, so the suite passes on a spec it invented. For a private repo you can’t send to an API, the 20-minute local run is real. For anything you’d iterate on, the hosted profile in the same install is the one you’ll keep picking from the model menu.

Running the backend headless

I found no headless switch in the Docker image. The header of /opt/agent-canvas/entrypoint.sh says it starts three services, plus an optional fourth for auth tests, and none of its options skips the frontend. Splitting them is the job of the npm launcher, @openhands/agent-canvas, and the OpenHands VM setup guide describes it in two halves:

  • On the VM: agent-canvas --backend-only --public
  • On the laptop: agent-canvas --frontend-only, then add the VM’s URL as a backend
  • With --public: a strong LOCAL_BACKEND_API_KEY set first

The guide lists Node 24 or newer and uv as requirements for the launcher, and box1 had neither, so I stayed on the Docker image for this round. The split earns its keep when you want the backend on a server and the UI on your laptop. If one machine runs both, the container above is the simpler setup, and the session key works the same way in both.

Errors I hit, with fixes

Each of these came from one of the two lab rounds, quoted as the tool printed it.

ERROR: Workspace directory is not writable: /projects

The container exits with code 1 and the log continues with mktemp: failed to create file via template '/projects/.agent-canvas-probe.XXXXXXXX': Permission denied. The host folder isn’t writable by uid 10001. Run the setfacl command from the Docker section against the real host path, remove the container and start it again. On SELinux hosts the log suggests the :z mount option as well; my box was Ubuntu, so I didn’t need it.

curl: (6) Could not resolve host: host.docker.internal

Docker Desktop provides that name; Docker Engine on Linux doesn’t unless the container was started with --add-host host.docker.internal:host-gateway. You can’t add it to a running container, so docker rm -f agent-canvas and rerun with the flag. Your settings and conversations survive in the named volume.

curl: (7) Failed to connect to host.docker.internal port 11434

The name resolves, so the Docker side is fine, and Ollama is listening on 127.0.0.1 only, which ss -ltn | grep 11434 shows as 127.0.0.1:11434. Set OLLAMA_HOST=0.0.0.0:11434 in the systemd override and restart Ollama. If it still refuses with UFW enabled, the allow rule for 172.17.0.0/16 is missing or sits below the deny. That subnet is the default bridge; a container on a user-defined Docker network gets another range, such as 172.18.0.0/16, which needs its own rule.

litellm.Timeout: LLM hard timeout after 300 seconds

The model didn’t finish the prompt inside the profile’s Timeout, and on 1.47.0 the conversation stops after two attempts with an Error badge in the chat box. On CPU that’s normal for the first turn, because the whole system prompt has to be processed once. Raise Timeout in the LLM profile (I used 1200), keep OLLAMA_KEEP_ALIVE long so the prompt cache survives between turns, and don’t run two conversations at once against one Ollama, since the second one waits behind the first and times out.

PermissionError: [Errno 13] Permission denied on files the agent wrote

Files created by the agent’s file editor land as -rw------- owned by 10001, and getfacl shows mask::---, so the default ACL entries do nothing for them and your host user can’t read them. The editor writes a hidden temp file such as .fizzbuzz.py.4frn0nuu.tmp and renames it into place, which the CPU run’s first failed write exposed, and a private temp file is the likely source of the 0600 mode. Run tests with docker exec -w /projects/<folder> agent-canvas, or take the files back with sudo chown -R $USER ~/projects/<folder> when you’re done with that conversation.

Ollama context shows 4096 in ollama ps

This one doesn’t throw an error, which is what makes it dangerous. Before my override, ollama ps showed the 7B model loaded with CONTEXT 4096, while OpenHands sends about 14,000 tokens on the first turn. Set OLLAMA_CONTEXT_LENGTH=32768, restart Ollama, send one request and check that column reads 32768.

The model prints a tool call as JSON text

No error appears, yet it’s the most common failure with small local models. In round one, qwen2.5-coder:7b replied with {"name": "file_editor", "arguments": {"command": "create", "path": "/projects/demo/fizzbuzz.py", ...}} as text, the conversation ended, and nothing changed on disk. The model doesn’t emit tool calls in the format Ollama parses. Listing tools in ollama show isn’t enough, since the 7B coder lists it too. Switch to a model that handled tool calls in your own test.

Locking it down

Treat this container as a remote shell on your machine. The OpenHands VM guide warns that the agent server can read and write files, run commands, reach the network and store secrets, and the rebinding test above showed the session key is the only thing between a browser and that shell. I kept five controls in place.

  • -p 127.0.0.1:8000:8000, never a bare -p 8000:8000
  • No AGENT_CANVAS_ALLOW_LAN_SESSION_KEY; key pasted at Add a backend
  • Access over ssh -L 8000:127.0.0.1:8000 from my laptop
  • Ollama allowed from 172.17.0.0/16 only, port denied to the world
  • Only the project folder mounted, never a home directory

One more default caught my eye: the conversation state reports "confirmation_policy":{"kind":"NeverConfirm"}, so the agent runs every command without asking you first. On a real domain with TLS, set your own LOCAL_BACKEND_API_KEY and put an authenticating reverse proxy in front, as the VM guide describes. I did not run a public deployment for this post, so I would start from that guide rather than improvise one.

Comparing it with OpenCode and Claude Code

OpenHands is a browser app with a server behind it; OpenCode and Claude Code are terminal agents that run as your user in your shell. That one difference decides most of it. OpenHands isolates the agent in a container and keeps conversations on the server, so you can close the laptop and come back. A terminal agent starts in seconds and works on your real checkout with your real tools, without the uid 10001 file ownership dance.

OpenHands (Agent Canvas)OpenCodeClaude Code
InterfaceWeb UI on port 8000Terminal TUITerminal
Where tools runInside the containerYour shellYour shell
Local models via OllamaYes, OpenAI-compatible URLYesNot its main path
Runs other agentsYes, picked at onboardingNoNo

I find the last row the interesting one. The 1.47.0 agent picker offers Claude Code, Codex, Gemini CLI, Pi and OpenCode next to OpenHands, so the choice isn’t strictly either-or. I haven’t tried that path. If you’d rather stay in the terminal, start with setting up OpenCode and the OpenCode CLI cheat sheet, or the Claude Code cheat sheet for the hosted side. If you want one LiteLLM endpoint in front of both Ollama and hosted keys, the LiteLLM proxy gateway guide sets that up. The six CLI agents we tested by execution and Hermes Agent on a CPU Ollama model hit the same small-model limits from other angles.

What I still don’t know

I do not know for sure why Reasoning Effort none didn’t stop qwen3:4b thinking. Both the UI and a direct API call failed to switch it off on the build I had in round one. It might be the levels flag in ollama show, the model’s template, or the value never reaching the template. I’d test "think": false on Ollama’s native API next to separate the two.

I also haven’t measured how far a single consumer GPU moves the CPU numbers, or whether a 14B to 32B coder model stops printing tool calls as text. Those two questions decide whether local OpenHands is a daily tool or a demo, and both need a GPU box I did not have for this run. Nor do I know whether the 0600 files are intended or an accident of the editor’s write path, because nothing in the settings changes it. If you run the same FizzBuzz prompt on a GPU, I’d like to hear your first-turn time.

Keep reading

Run Amazon Ergo Locally: Hardware Requirements and vLLM Setup AI Run Amazon Ergo Locally: Hardware Requirements and vLLM Setup Open Source LLM Comparison Table (2026) AI Open Source LLM Comparison Table (2026) Ollama Models Cheat Sheet: Best Models by VRAM, Tested (PDF) AI Ollama Models Cheat Sheet: Best Models by VRAM, Tested (PDF) AI NAS Explained: Is Local AI on a NAS Worth It? AI AI NAS Explained: Is Local AI on a NAS Worth It? MedGemma 2 vs Gemma 4 vs MedGemma 1.5: Local Benchmark AI MedGemma 2 vs Gemma 4 vs MedGemma 1.5: Local Benchmark Best GPU for LLMs in 2026: Tested by VRAM, Budget, and Model Size AI Best GPU for LLMs in 2026: Tested by VRAM, Budget, and Model Size

Leave a Comment

Press ESC to close