{"slug": "run-openclaw-as-a-personal-assistant-on-lens-agents", "title": "Run OpenClaw as a personal assistant on Lens Agents", "summary": "Lens Agents published a guide for running OpenClaw, a personal AI assistant with a web Control UI, inside a Lens Agents sandbox so the UI is never exposed on an open port, addressing the hundreds of thousands of exposed OpenClaw instances the post cites as a security problem. The setup binds the OpenClaw gateway to 127.0.0.1 on port 18789 and publishes it as a private port that requires a Lens Agents login and forwards the user's identity in a header, while the model runs through managed inference on OpenRouter with a placeholder key so the sandbox holds no API key. The configuration pins the image ghcr.io/openclaw/openclaw:2026.10.8 with 2 CPUs, 4Gi of memory and a 10Gi volume, and defaults to the anthropic/claude-opus-5.5 model.", "body_md": "**TL;DR**\n\n- [OpenClaw](https://openclaw.ai) is a personal AI assistant with a web Control UI. Put that UI on an open port, and anyone who finds it can talk to your assistant.\n- In a Lens Agents sandbox, the Control UI has no open port. It is a private port behind your Lens Agents login, and OpenClaw knows who you are from the platform.\n- The model comes through managed inference with OpenRouter, so the sandbox holds no API key. You decide what else on the network it can reach.\n\nOpenClaw is useful because it acts for you: it remembers, it runs tools, it does things. That's also why [hundreds of thousands of exposed instances](https://lenshq.io/blog/banning-ungoverned-ai-agents/) are a problem. An assistant with your context and your keys, on an open port, is an assistant for anyone who finds it.\n\nThis post runs OpenClaw for one person, in a Lens Agents sandbox, with none of that exposed.\n\n## How the pieces fit\n\nOpenClaw runs a gateway that serves the Control UI and talks to the model. In the sandbox, the gateway listens only on `127.0.0.1`. The sandbox publishes that port as **private**: Lens Agents gives it a URL, asks you to log in, checks your project access, and then forwards the request with your identity in a header. OpenClaw trusts that header, so it knows who you are without a second password.\n\nThe model is **managed inference**. The sandbox gets an OpenRouter endpoint and a placeholder key. The platform adds the real key at the boundary and meters the spend. OpenRouter is the easiest backend to set up: one API key, no cloud account, and hundreds of models behind it.\n\n## What you need\n\n- The latest Lens Agents release, with OpenRouter enabled for your org. An org admin adds the OpenRouter API key on the org's **Inference keys** page. If you don't have a platform yet, follow the[getting started guide](https://docs.lenshq.io/lens-agents/getting-started/) .\n- `nexusctl` , installed from your Lens Agents platform and logged in with`nexusctl auth login` .\n- The email address you log in to Lens Agents with. OpenClaw makes that identity the admin of the gateway.\n\n## Step 1: Define the sandbox\n\n```\nname: OpenClaw\nimage: ghcr.io/openclaw/openclaw:2026.10.8\ncpu: \"2\"\nmemory: 4Gi\n\nvolumes:\n  - mountPath: /data\n    size: 10Gi\n\nexposedPorts:\n  - name: web\n    port: 18789\n    auth: private\n\nenv:\n  LENS_SANDBOX_WRITABLE_DIR: /data\n  OPENCLAW_CONFIG_PATH: /data/openclaw.json\n  OPENCLAW_STATE_DIR: /data/state\n  OPENCLAW_WORKSPACE_DIR: /data/workspace\n  OPENCLAW_NO_AUTO_UPDATE: \"1\"\n  OPENCLAW_MODEL: anthropic/claude-opus-5.5\n  OPENCLAW_ADMIN: ${OPENCLAW_ADMIN}\n\nfiles:\n  - path: /home/node/start-openclaw.sh\n    content: |\n      [ -n \"$NEXUS_INGRESS_IDENTITY_HEADER_WEB\" ] || { echo \"publish the web port as private\" >&2; exit 1; }\n      origins=\"\\\"$(printf '%s' \"$NEXUS_INGRESS_ORIGINS_WEB\" | sed 's/,/\",\"/g')\\\"\"\n\n      openclaw config unset gateway.auth.identityScopes >/dev/null 2>&1\n      openclaw config set gateway \"{\n        \\\"mode\\\": \\\"local\\\", \\\"bind\\\": \\\"loopback\\\", \\\"port\\\": 18789,\n        \\\"trustedProxies\\\": [\\\"127.0.0.1\\\"],\n        \\\"auth\\\": {\n          \\\"mode\\\": \\\"trusted-proxy\\\",\n          \\\"trustedProxy\\\": {\n            \\\"userHeader\\\": \\\"$NEXUS_INGRESS_IDENTITY_HEADER_WEB\\\", \\\"allowLoopback\\\": true,\n            \\\"deviceAutoApprove\\\": {\n              \\\"enabled\\\": true,\n              \\\"scopes\\\": [\\\"operator.read\\\", \\\"operator.write\\\", \\\"operator.approvals\\\", \\\"operator.questions\\\"]\n            }\n          },\n          \\\"identityScopes\\\": { \\\"$OPENCLAW_ADMIN\\\": [\\\"operator.admin\\\"] }\n        },\n        \\\"controlUi\\\": {\n          \\\"allowedOrigins\\\": [$origins],\n          \\\"dangerouslyAllowHostHeaderOriginFallback\\\": false,\n          \\\"dangerouslyDisableDeviceAuth\\\": true\n        }\n      }\" --strict-json --merge || exit 1\n\n      openclaw config set update '{\"checkOnStart\": false, \"auto\": {\"enabled\": false}}' --strict-json --merge\n\n      openclaw config set models.providers.nexus \"{\n        \\\"api\\\": \\\"anthropic-messages\\\",\n        \\\"baseUrl\\\": \\\"$ANTHROPIC_BASE_URL\\\",\n        \\\"apiKey\\\": \\\"nexus-managed\\\",\n        \\\"models\\\": [{\\\"id\\\": \\\"$OPENCLAW_MODEL\\\", \\\"name\\\": \\\"$OPENCLAW_MODEL\\\"}]\n      }\" --strict-json\n      openclaw config set agents.defaults.model \"{\\\"primary\\\": \\\"nexus/$OPENCLAW_MODEL\\\"}\" --strict-json --merge\n      openclaw config set memory.search \"{\n        \\\"enabled\\\": true, \\\"provider\\\": \\\"openai\\\",\n        \\\"model\\\": \\\"openai/text-embedding-3-small\\\", \\\"fallback\\\": \\\"none\\\",\n        \\\"remote\\\": { \\\"baseUrl\\\": \\\"$OPENAI_BASE_URL\\\", \\\"apiKey\\\": \\\"$OPENAI_API_KEY\\\" }\n      }\" --strict-json --merge\n\n      openclaw config set mcp.servers.nexus \"{\n        \\\"command\\\": \\\"/.lens/nexus-mcp\\\", \\\"enabled\\\": true,\n        \\\"env\\\": {\n          \\\"NEXUS_MCP_URL\\\": \\\"$NEXUS_MCP_URL\\\",\n          \\\"HTTPS_PROXY\\\": \\\"$HTTPS_PROXY\\\",\n          \\\"HTTP_PROXY\\\": \\\"$HTTP_PROXY\\\",\n          \\\"SSL_CERT_FILE\\\": \\\"$SSL_CERT_FILE\\\"\n        }\n      }\" --strict-json\n\n      exec openclaw gateway\n\ncommand: sh /home/node/start-openclaw.sh\n\npolicy:\n  name: OpenClaw\n  networkDefaultVerdict: deny\n  managedInference:\n    enabled: true\n    provider: openrouter\n  allowedDomains:\n    - pattern: \"*\"\n      verdict: allow\n      transport: direct\n      description: Read-only internet\n      rules:\n        - { method: GET }\n        - { method: HEAD }\n```\n\nA few things to note:\n\n- **The image is pinned** , and`OPENCLAW_NO_AUTO_UPDATE` plus the`update` setting keep it pinned. An assistant that upgrades itself is no longer the one you reviewed.\n- **State lives on the `/data` volume** : config, memory, and workspace. A restart picks up where the assistant left off.`LENS_SANDBOX_WRITABLE_DIR` gives the volume to the image's own user before the gateway starts.\n- **The start script writes OpenClaw's settings on every boot** with OpenClaw's own`config set` , then starts the gateway. Settings you change in the Control UI stay, except the ones the script owns.\n- **The gateway trusts only the platform.** It binds to loopback and reads your identity from the header that the private port adds. The allowed origins are the URLs of this sandbox, so another site can't drive the Control UI from your browser.\n- **Only you administer it.**`OPENCLAW_ADMIN` gets the admin scope: channels, devices, gateway settings. Anyone else in the project who opens the port can chat and answer approvals, but can't change the gateway.\n- **You decide what the assistant can reach.** The policy denies by default. OpenClaw talks to the model through managed inference, which the policy grants separately. The one rule in`allowedDomains` gives read-only internet:`GET` and`HEAD` pass, so the assistant can read the web but can't post to it. That can also let OpenClaw read its model catalog and download skills from ClawHub. Remove the rule to block all of it, or add domains with the methods you trust.\n- **Memory search uses OpenRouter too.** OpenClaw indexes its memory with an embedding model, and the script points it at the same managed OpenRouter endpoint, through OpenRouter's OpenAI-compatible API.\n- **`OPENCLAW_MODEL`** is any OpenRouter model id. Change it to try another model.\n\n## Step 2: Create the sandbox\n\n```\nOPENCLAW_ADMIN=you@example.com nexusctl sandbox create --project <org>/<project> -f sandbox.yaml\n```\n\n`create` expands `${OPENCLAW_ADMIN}` from your environment. The image is large, so the first start takes a few minutes.\n\n## Step 3: Open the Control UI\n\n```\nnexusctl sandbox describe <sandbox> --project <org>/<project>\n```\n\nThe **Exposed Ports** section shows the URL of the `web` port. Open it, log in to Lens Agents if asked, and the Control UI opens as you, with admin rights. Say hello.\n\n## Step 4: Give the assistant your tools\n\nThe start script connects OpenClaw to the Lens Agents MCP gateway. Through it, the assistant can use any MCP server that you add to your project, such as your issue tracker or your docs:\n\n1. Add the MCP server to your Lens Agents project as a connector, and connect your account to it there.\n2. Grant the connector in the sandbox policy, and choose which of its tools the assistant can use.\n\nIn `sandbox.yaml`, the grant goes under `policy`:\n\n```\npolicy:\n  # ... as in Step 1\n  connectors:\n    - connectorId: <connector-id>\n      credentialId: <credential-id>   # only if the connector needs a login\n      allowedTools: [search_issues, get_issue]\n```\n\n`nexusctl connector describe <connector> --project <org>/<project>` shows the connector's id, its credentials, and its tools. Only the tools in `allowedTools` reach the assistant. Apply the change with `nexusctl sandbox update <sandbox> --project <org>/<project> -f sandbox.yaml`, with `OPENCLAW_ADMIN` set as in Step 2.\n\nYour login for the MCP server stays in Lens Agents. The sandbox sees the tools, never the token, and every tool call is recorded.\n\n## What the sandbox adds\n\nOpenClaw gives you the assistant. The sandbox decides what it can reach:\n\n- **No open port.** The Control UI is behind your Lens Agents login, and OpenClaw sees who is calling.\n- **No model key in the sandbox.** The OpenRouter key stays with the platform. Spend limits apply to it, and the spend is attributed to the sandbox.\n- **Default-deny egress** with per-domain, per-method rules. You choose what the assistant can reach beyond the model.\n- **Audit.** Every request the sandbox proxy handles is recorded, with the policy decision.\n\nLens Agents also ships an OpenClaw template in the web UI, with Slack as a channel. This spec is the same setup as a file, for one person, that you can keep in Git.\n\nFor more on running agents with these controls, read [how to run Hermes Agent securely](https://lenshq.io/blog/how-to-run-hermes-agent-securely/).\n\n## Run your agents governed\n\nRun OpenClaw and your other agents with identity, policy, and audit built in.\n\n## FAQ\n\n**Can someone reach the Control UI without logging in?**\n\nNo. The port is private, so every request goes through the Lens Agents login and a project access check before it reaches the sandbox.\n\n**Can I use another inference backend instead of OpenRouter?**\n\nYes, if your org has it. For most backends, change two things: `provider` in the policy, and the model in `OPENCLAW_MODEL`. OpenAI and Bedrock also need changes in the start script. The OpenClaw template in Lens Agents supports every backend, so use it as the reference.\n\n**How do I give the assistant a new tool or website?**\n\nThe read-only rule already lets it read any website. To let it write to one, for example to `POST` to an API, add that domain to `allowedDomains` with the methods it needs. For MCP tools, see Step 4.\n\n**What happens to the assistant when the sandbox restarts?**\n\nThe `/data` volume stays, so memory, workspace, and settings stay too. The script writes its own settings again, and the gateway starts.", "url": "https://wpnews.pro/news/run-openclaw-as-a-personal-assistant-on-lens-agents", "canonical_source": "https://lenshq.io/blog/openclaw-on-lens-agents/", "published_at": "2026-10-30 00:00:00+00:00", "updated_at": "2026-11-03 06:51:17.039245+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "ai-safety", "ai-infrastructure"], "entities": ["OpenClaw", "Lens Agents", "OpenRouter", "Lens", "anthropic/claude-opus-5.5"], "also_reported_by": [], "takeaway": "Binding the OpenClaw gateway to loopback and publishing port 18789 as a private Lens Agents port with trusted-proxy identity headers, plus a placeholder OpenRouter key, keeps the assistant off open ports and out of reach of anyone who finds it.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/run-openclaw-as-a-personal-assistant-on-lens-agents", "markdown": "https://wpnews.pro/news/run-openclaw-as-a-personal-assistant-on-lens-agents.md", "text": "https://wpnews.pro/news/run-openclaw-as-a-personal-assistant-on-lens-agents.txt", "jsonld": "https://wpnews.pro/news/run-openclaw-as-a-personal-assistant-on-lens-agents.jsonld"}}