# OpenClaw on a Local Ollama Model: Setup, Limits, Security

> Set up OpenClaw as a local agent on Ollama: install, gateway, model, workspace, scheduled jobs, a chat channel, updates, and what to lock down first.

- Published: 2026-09-09
- Updated: 2026-11-15
- Author: Jacobo González Jaspe
- Language: en
- Tags: OpenClaw, Ollama, AI Agents, Tutorial
- Canonical URL: https://vorluxai.com/en/blog/openclaw-ollama-local-agent-setup-en/
- Source: VORLUX AI (J4SGON S.L.), https://vorluxai.com/

---

By the end of this guide you will have an OpenClaw gateway on a machine you own, answering through a model that Ollama serves on the same machine. It will have a workspace, one chat channel, one scheduled job, and tighter permissions than the defaults.

Every command and config key below was checked on 15 November 2026, in two ways. First against OpenClaw's documentation, which describes the latest stable release, 2026.11.3. Then against the `--help` output of the 2026.7.1-2 gateway we run in production. Where the two differ, we say which version a statement applies to.

> **TL;DR**
> - **One command installs it.** `ollama launch openclaw` installs OpenClaw, writes the Ollama provider config and starts the gateway.
> - **Use Ollama's native API.** OpenClaw's docs warn that the `/v1` URL breaks tool calling.
> - **The defaults trust the model.** The sandbox is off by default, and the agent can run shell commands as your user. Fix that before you connect a channel.
> - **Model size shows in judgement.** In our probe an 8B model called a shell tool to answer plain questions. A 26B model did not.
> - **"ok" is not "done".** A scheduled run can finish `ok` after its command failed. Check the run, not the status.

## Who this is for, and when not to do it

This is for you if you want an assistant that reads your files, follows a schedule and answers in a chat app, with the model on your hardware. It is the wrong choice in three cases:

- **Several people who do not trust each other will share it.** OpenClaw's [security page](https://docs.openclaw.ai/gateway/security) assumes one trust boundary per gateway and says it is not a hostile multi-tenant boundary.
- **The agent will read untrusted mail or web pages with tools switched on.** The [prompt injection page](https://docs.openclaw.ai/gateway/security/prompt-injection) says small models are easier to steer and advises against them for that work.
- **You need long, unattended, multi-step work.** Our own local agents need a wrapper that re-prompts them and checks their output. See the limits section.

## What you need

- **Node.js 24.16.0 or later on the 24 line, or 26.1.0 or later.** OpenClaw's [Node page](https://docs.openclaw.ai/install/node) recommends Node 26, and 24.22.1+ or 26.12.1+ for security fixes.
- **Ollama.** [Ollama's tutorial](https://ollama.com/blog/openclaw-tutorial) of 23 February 2026 asks for 0.17 or later. Our numbers come from 0.30.10 and 0.34.0. New to it? Start with [installing Ollama and your first model](https://vorluxai.com/en/blog/install-ollama-first-local-llm-en/).
- **A model with the `tools` capability** and memory to hold it with a long context (Step 1).
- **macOS, Linux or Windows.** The [install page](https://docs.openclaw.ai/install) lists a PowerShell installer and WSL2 for Windows. We have only run it on Linux.
- **Docker**, if you want the sandbox in Step 5.

## Step 1: prepare the model in Ollama

An agent's model must return well-formed tool calls and hold a long prompt.

```bash
ollama pull gemma4:26b
ollama show gemma4:26b     # "tools" must appear under Capabilities
```

Then set the context. Ollama's [context length page](https://docs.ollama.com/context-length) (read 15 November 2026) gives the default by VRAM: 4k tokens under 24 GiB, 32k from 24 to 48 GiB, 256k above that. It recommends at least 64,000 tokens for agents. OpenClaw's [Ollama setup page](https://docs.openclaw.ai/providers/ollama/setup) accepts a model only with tool support and at least 16K of context.

We bake the window into a named copy:

```bash
printf 'FROM gemma4:26b\nPARAMETER num_ctx 32768\n' > Modelfile
ollama create gemma4-32k -f Modelfile
ollama ps                  # the CONTEXT column shows what is loaded
```

Context costs memory, and how much depends on the model. Loaded sizes from `ollama ps` on our NVIDIA DGX Spark machines (GB10, 128 GB unified memory), 2 November 2026 ([result file](https://vorluxai.com/data/measurements/ollama-num-ctx-2026-11-02.json)):

| Model (Q4_K_M) | Context | Parallel slots | Loaded |
|---|---|---|---|
| `llama3.1:8b` | 32,768 | 1 | 9.21 GB |
| `llama3.1:8b` | 32,768 | 4 | 22.38 GB |
| `gemma4:26b` | 32,768 | 1 | 17.47 GB |
| `gemma4:26b` | 131,072 | 1 | 18.36 GB |

Our machines have 128 GB, and we have no data for a laptop or a consumer card. To size yours, use [how much VRAM a local LLM needs](https://vorluxai.com/en/blog/how-much-vram-local-llm-en/).

## Step 2: install OpenClaw and start the gateway

**The launcher.** [Ollama's integration page](https://docs.ollama.com/integrations/openclaw) documents one command:

```bash
ollama launch openclaw --model gemma4-32k
```

According to that page, it offers to install OpenClaw through npm, shows a security notice, configures the provider, installs the gateway service and opens the terminal UI. It also enables Ollama's web search, which is a hosted service (see the limits).

**By hand.** These commands are from OpenClaw's [install page](https://docs.openclaw.ai/install):

```bash
curl -fsSL https://openclaw.ai/install.sh | bash
openclaw onboard --install-daemon     # choose Ollama, then "Local only"
openclaw gateway status
```

**What you should see.** This is `openclaw gateway status` on our gateway, 15 November 2026, trimmed, with paths and addresses replaced:

```text
Service: systemd user (enabled)
Config (cli): ~/.openclaw/openclaw.json
CLI version: 2026.7.1-2
Gateway version: 2026.7.1-2
Runtime: running (pid <pid>, state active, sub running, last exit 0, reason 0)
Connectivity probe: ok
```

The gateway listens on port 18789 by default.

We did not run a fresh install for this guide: our gateway is in production. The install steps come from the two vendors' documentation. The output above is ours.

## Step 3: check the provider configuration

Open `~/.openclaw/openclaw.json`. The Ollama provider should look like this, in the shape of OpenClaw's [configuration page](https://docs.openclaw.ai/providers/ollama/configuration):

```json5
{
  models: {
    providers: {
      ollama: {
        baseUrl: "http://127.0.0.1:11434",   // no /v1
        apiKey: "ollama-local",              // a marker for local hosts, not a secret
        api: "ollama",
        timeoutSeconds: 300,                 // room for a cold first load
        models: [
          { id: "gemma4-32k", name: "gemma4-32k",
            contextTokens: 32768,
            params: { num_ctx: 32768, keep_alive: "15m" } }
        ]
      }
    }
  },
  agents: { defaults: { model: { primary: "ollama/gemma4-32k" } } }
}
```

Three things matter here:

- **No `/v1`.** The [provider page](https://docs.openclaw.ai/providers/ollama) says that URL "breaks tool calling", and that models can then print tool-call JSON as plain text. OpenClaw talks to Ollama's native `/api/chat`.
- **`contextTokens` and `num_ctx` agree.** The [advanced page](https://docs.openclaw.ai/providers/ollama/advanced) says `contextTokens` caps what OpenClaw sends and `params.num_ctx` sets what Ollama allocates. Local discovery normally caps `contextTokens` at 32,768.
- **Models are named `ollama/<name>`.** Check with `openclaw models list`.

Our gateway uses two provider types: a native `ollama` provider, and an OpenAI-compatible one that points at a LiteLLM router in front of our two machines. The docs warn that tool calling is less reliable in that mode. With one machine, stay native.

## Step 4: know the workspace and the memory

OpenClaw keeps two things apart. `~/.openclaw/` holds config, credentials and sessions. The workspace, by default `~/.openclaw/workspace`, is the agent's working directory. Its memory is plain Markdown there. The [memory page](https://docs.openclaw.ai/concepts/memory) says the model remembers only what is saved to disk.

| File | What it is for |
|---|---|
| `AGENTS.md` | Operating instructions, loaded every session |
| `SOUL.md` | Persona, tone and boundaries |
| `USER.md` | Stable preferences about you |
| `MEMORY.md` | Long-term facts and decisions |
| `memory/YYYY-MM-DD.md` | Daily notes; today's and yesterday's load on a new session |
| `TOOLS.md`, `IDENTITY.md` | Local tool notes and the agent's name |

The descriptions follow the [agent workspace page](https://docs.openclaw.ai/concepts/agent-workspace). Ours holds all seven files and the `memory/` folder.

A second agent gets its own workspace and its own model:

```bash
openclaw agents add work --workspace ~/.openclaw/workspace-work --model ollama/gemma4-32k
openclaw agents list
```

We run nine agents this way, each in a `workspace-<id>` folder. One version difference: our 2026.7.1-2 config stores agents under `agents.list`, while the 2026.11.3 documentation writes `agents.entries`. Let the CLI write it.

Memory search needs embeddings. The [memory search page](https://docs.openclaw.ai/concepts/memory-search) says the default provider is OpenAI and lists `ollama` and `local` as options with no API key. Set one of those if nothing may leave the machine.

## Step 5: lock it down before you connect anything

These are the defaults in the 2026.11.3 documentation:

| Area | Default | Source |
|---|---|---|
| Gateway bind | loopback only, with a token created at onboarding | [Network exposure](https://docs.openclaw.ai/gateway/security/network-exposure) |
| Unknown sender in a DM | gets a pairing code, not an answer | [Security](https://docs.openclaw.ai/gateway/security) |
| Sandbox | off | [Sandboxing](https://docs.openclaw.ai/gateway/sandboxing) |
| Shell commands on the host | `security: full`, `ask: off` | [Exec approvals](https://docs.openclaw.ai/tools/exec-approvals) |
| Workspace | the default directory, not a boundary | [Agent workspace](https://docs.openclaw.ai/concepts/agent-workspace) |

Put together: by default the agent can run any command and read any file that the gateway's operating-system user can. Absolute paths reach outside the workspace.

**What to do, cheapest first:**

1. **Give it its own user or a small VM.** Ollama's tutorial asks you to run OpenClaw "in an isolated environment". Then the agent's reach is that user's reach.
2. **Turn on the sandbox.** It moves tool execution into a Docker container. The docs call it not a perfect boundary, but one that limits file and process access.
3. **Restrict the tools.** Deny what the agent does not need, and make shell commands ask.
4. **Run the audit.** `openclaw security audit` checks config and state for common mistakes. `--fix` changes files, so read the report first.

A starting point, built from the [hardened baseline](https://docs.openclaw.ai/gateway/security/hardened-baseline) and the [sandbox modes](https://docs.openclaw.ai/gateway/sandboxing/modes-scope-and-backend):

```json5
{
  gateway: { bind: "loopback", auth: { mode: "token" } },
  agents: { defaults: { sandbox: { mode: "all", workspaceAccess: "none" } } },
  tools: {
    fs: { workspaceOnly: true },
    exec: { security: "allowlist", ask: "on-miss" },
    elevated: { enabled: false }
  },
  channels: { telegram: { dmPolicy: "pairing", groups: { "*": { requireMention: true } } } }
}
```

`workspaceAccess` takes `none`, `ro` or `rw`. The exec-approvals page calls `security` and `ask` a legacy pair that `openclaw doctor` migrates to `tools.exec.mode`. Check the result with `openclaw sandbox explain`. We assembled this block from the documentation and did not apply it to our production gateway for this guide.

**What never to expose to the network:**

- **Port 18789.** The network exposure page says never to expose the gateway unauthenticated on `0.0.0.0`. For remote access it prefers Tailscale Serve, which keeps the gateway on loopback.
- **Ollama's port 11434.** Ollama's [FAQ](https://docs.ollama.com/faq) says it binds to `127.0.0.1` by default. Leave it there.
- **`~/.openclaw/`.** It holds credentials and channel sessions. Backups of it do too.

A local model does not remove the injection risk. Any page, mail or file the agent reads can carry instructions. Practise on [the email that gives orders](https://vorluxai.com/en/playground/prompt-injection/) and [the poisoned document](https://vorluxai.com/en/playground/indirect-injection-rag/).

## Step 6: connect one channel

Telegram is the shortest path, because it needs only a bot token. From the [Telegram setup page](https://docs.openclaw.ai/channels/telegram/setup): create a bot with `@BotFather`, then:

```bash
openclaw channels add --channel telegram --token <bot-token>
openclaw channels status --probe
# send your bot any message, then:
openclaw pairing list telegram
openclaw pairing approve telegram <CODE>
```

The page says pairing codes expire after one hour. All four commands exist on 2026.7.1-2. We did not run them: our gateway has one channel, WhatsApp, linked with `openclaw channels login --channel whatsapp`.

The transport is not private. Messages cross Telegram's or WhatsApp's servers even when the model is local.

## Step 7: schedule a job

```bash
openclaw cron add --name "Morning notes digest" \
  --cron "0 8 * * 1-5" --tz "Europe/Madrid" \
  --session isolated --model ollama/gemma4-32k \
  --message "Read the files in notes/ changed in the last 24 hours. Reply with three bullets and one action for today." \
  --announce --channel telegram --to <chat-id> \
  --disabled
openclaw cron list --all
openclaw cron run <job-id> --wait     # then: openclaw cron runs --id <job-id>
openclaw cron enable <job-id>
```

Every flag is in the `--help` of 2026.7.1-2 and in the [cron reference](https://docs.openclaw.ai/cli/cron). We did not create this job on our gateway.

Two things we learned running 17 jobs ([footprint file](https://vorluxai.com/data/measurements/openclaw-gateway-footprint-2026-11-15.json)):

- **Not every job needs a model.** `--command "<shell>"` runs a script on the gateway with no agent turn. Our health checks are command jobs: a script decides, and the chat hears about it only when something changed.
- **Read the run, not the status.** The [troubleshooting page](https://docs.openclaw.ai/automation/cron-jobs/troubleshooting) says a run can finish `ok` after an exec call failed and the agent replied. We check that each agent left a dated note in `memory/` and changed the file it was asked to change.

One naming difference: the 2026.11.3 documentation calls this feature "automations" and accepts both spellings. On 2026.7.1-2 only `openclaw cron` exists.

## Step 8: update without losing state

Our gateway is on 2026.7.1-2, and `openclaw update status` reported 2026.11.3 available on 15 November 2026. The order below is from the [rollback and recovery page](https://docs.openclaw.ai/install/updating/rollback-and-recovery). `backup create` and `update --dry-run` exist on our version.

```bash
openclaw backup create --output ~/Backups/openclaw --verify
openclaw update --dry-run
openclaw update
openclaw doctor
```

The same page warns that downgrading the package "does not reverse config or database migrations". The supported way back is the verified backup with its matching release. Keep that archive private: it can contain credentials.

We have not made this jump ourselves. It crosses four months of releases, and the docs describe migrations: heartbeat monitors become scheduled jobs, and exec approvals move from a JSON file to a database. Read the [release notes](https://github.com/openclaw/openclaw/releases) first.

## What a local model can and cannot do as the brain

**Tool calls: form is fine, judgement depends on size.** On 15 November 2026 we sent two models six requests each, with three tools shaped like an agent's (`Read`, `Bash`, `Grep`). Temperature 0, one run per case, checked by script ([result file](https://vorluxai.com/data/measurements/ollama-anthropic-messages-probe-2026-11-15.json)).

| | `llama3.1:8b` | `gemma4:26b` (32k) |
|---|---|---|
| Tool calls well formed | all | all |
| Cases passed | 4 of 6 | 5 of 6 |
| "Reply with exactly three words" | called `Bash` with `echo` | plain text |
| "What does JSON stand for?" | called `Bash` with `echo` | plain text |

The 8B model reached for the shell when no tool was needed. In an agent with exec on the host, each of those is a command you did not ask for. The 26B model's one miss was listing the test files before running them.

This probe used Ollama's Anthropic-compatible endpoint with a short system prompt. OpenClaw uses `/api/chat` and sends a far longer prompt with more tools. Read it as a floor. The full method is in [Claude Code on a local Ollama model](https://vorluxai.com/en/blog/claude-code-local-models-ollama-web-search-subagents-en/).

**Structured output points the same way.** In our test of 40 Spanish invoices on 5 November 2026, `gemma4:26b` got every field right in all 40. `qwen2.5-coder:7b` managed 85% and `llama3.1:8b` 62.5% ([result file](https://vorluxai.com/data/measurements/structured-extraction-2026-11-05.json)).

**Context: overflow can be silent.** In the same probe we sent a 64,507-character prompt to a model loaded with 6,144 tokens. Ollama returned HTTP 200, counted 3,070 input tokens, and the model said it saw no code word. The word was on the first line. OpenClaw's advanced page says that its native requests now set `truncate: false`, so a supporting server rejects the overflow, and OpenClaw compacts and retries. The page reports this as verified with Ollama 0.33.3. We have not tested it, and we do not know if 2026.7.1-2 behaves that way.

**Long tasks: the turn ends when the model writes text.** Our local agents tend to describe the work after a few tool calls, and the turn is over. We run them through a wrapper that re-prompts until a file changed or the agent wrote a reason for stopping. We have no result file for this, so take it as our experience and not as a measurement.

## What we measured: the gateway itself

One read-only sample of our production gateway on an NVIDIA DGX Spark (GB10, 128 GB unified memory), 15 November 2026 ([result file](https://vorluxai.com/data/measurements/openclaw-gateway-footprint-2026-11-15.json)):

| Item | Value |
|---|---|
| Version | OpenClaw 2026.7.1-2 |
| Gateway process, resident memory | 529,652 kB (about 0.53 GB) |
| Same process, peak since start | 1,181,328 kB (about 1.18 GB) |
| Service memory (systemd), current and peak | 0.62 GB and 1.39 GB |
| Agents, scheduled jobs, channels | 9, 17, 1 |

It had been up for about 35 hours and was idle between jobs. The model's memory comes on top of this. An earlier version of this article quoted September 2026 figures with no result file. We removed them.

## Failures you will hit

**1. Tool calls arrive as text.** The provider URL ends in `/v1`, or the model cannot handle tool schemas. Use the native URL with `api: "ollama"`. For a small model that still fails, the [troubleshooting page](https://docs.openclaw.ai/providers/ollama/troubleshooting) suggests `compat.supportsTools: false` on its entry.

**2. The first answer times out.** The model is loading from disk. In our context test `gemma4:26b` took 32 seconds on first load and 9 to 10 seconds on the next two. Set `timeoutSeconds` and `keep_alive` as in Step 3.

**3. `Unknown command: openclaw automations`.** We got this on 2026.7.1-2 by typing a command from the current docs. Older installs only have `openclaw cron`.

**4. The service complains about Node.** Our `gateway status` prints `Gateway service uses Node from a version manager; it can break after upgrades.` We installed Node with nvm. The message recommends `openclaw doctor`.

**5. A job ran and nothing arrived.** The cron troubleshooting page lists a missing or invalid `channel` or `to`, delivery mode `none`, and channel auth errors. Start with `openclaw cron runs --id <job-id>`.

**6. Restart loops on WSL2 with an NVIDIA GPU.** OpenClaw's Ollama troubleshooting page describes Ollama's service reloading a model at boot until Windows stops the VM. Its mitigation is `sudo systemctl disable ollama`. We do not run WSL2.

## Limits and what we did not test

- **Web search is not local.** OpenClaw's [web search page](https://docs.openclaw.ai/providers/ollama/web-search) says a local host must be signed in with `ollama signin`. Leave it off for a strictly local setup.
- **No hosted safety filter.** The [local models page](https://docs.openclaw.ai/gateway/local-models) says local models lack the filters of hosted providers.

**Not tested by us:** a fresh install on today's release, 2026.11.3 itself, the security block in Step 5, Telegram, the sandbox, macOS, Windows, and any machine smaller than ours.

## Frequent questions

**Does OpenClaw work fully offline?** The gateway and a local model do. Chat channels, web search and updates need the network.

**Is 32k enough when Ollama recommends 64k?** It works for us with short jobs. Long sessions compact sooner. If you have the memory, use 64k.

**OpenClaw or n8n?** n8n runs fixed steps you drew. OpenClaw lets a model decide the steps. For a pipeline that must do the same thing every day, use [n8n](https://vorluxai.com/en/blog/n8n-workflow-content-pipeline-tutorial/).

## Next steps

- Size the memory: [how much VRAM a local LLM needs](https://vorluxai.com/en/blog/how-much-vram-local-llm-en/).
- See context against memory, model by model: [Ollama num_ctx, measured](https://vorluxai.com/en/blog/ollama-context-length-memory-measured-en/).

## Work with us

We run nine agents on an OpenClaw gateway on our own hardware, and we know where local models stop. If you want a first agent in your office, locked down and sized for your machine, [get in touch](https://vorluxai.com/en/contact/) or see [how our consulting works](https://vorluxai.com/en/consulting/).
