Early access: your sandbox is free, with $5 of AQ Composer credits every month. Your own subscriptions stay unmetered. Start free

aq.dev / guides / self-hosted-ai-coding-agents

Self-Hosted AI Coding Agents on Your Own Infrastructure

Running AI coding agents on your own infrastructure means owning the execution environment (the machine where the agent reads your code, runs commands, and holds your credentials), not the model. As of October 2026 there are five practical routes: run agent CLIs like Claude Code and Codex directly on a VM you own, deploy an open-source harness like OpenHands, run a fully self-hosted platform like Coder Agents (generally available September 9, 2026, air-gap capable), attach self-hosted workers to a vendor platform like Cursor or Warp's Oz, or use a harness like AQ built around your own cloud from the start. In almost every one of these setups the model is still a hosted API: unless you also serve open-weight models, you are self-hosting execution and custody, not intelligence. Choosing comes down to which boundary your policy actually requires: code, credentials, and execution on your machines (every route below delivers that), or source-derived prompts never leaving your network (only a locally served open-weight model, or an air-gapped platform pointed at one, delivers that). When you have picked a route, the step-by-step self-hosted AI coding agent setup guide walks the plain-VM path end to end.

What "self-hosted" actually means for a coding agent

A coding agent setup has three separable pieces, and vendors mean very different subsets by "self-hosted":

  • The model. The LLM doing the reasoning. It sees every prompt, and prompts include code context.
  • The harness and orchestration. The software that turns model output into tool calls, manages sessions, and gives you a dashboard: open source on your box, or a service in the vendor's cloud.
  • The execution environment. The filesystem with your repository clone, the shell, your GitHub tokens, cloud credentials, and network position. The highest custody stakes live here.

When a vendor says "self-hosted," ask which pieces move onto your infrastructure. Usually it is only the third. That is still valuable, but it is not the same claim as "nothing leaves our network."

Why teams run agents on their own infrastructure

  • Code custody. The repository clone, build artifacts, and everything the agent writes stay in your own cloud account.
  • Credential custody. A useful agent holds real secrets: a GitHub token that can push, database URLs, cloud credentials. On your VM they stay on hardware you can audit and wipe. Custody is necessary but not sufficient: keeping secrets out of coding agent prompts covers the other half, since anything the agent reads can end up in a prompt to the model provider.
  • Internal network access. Agents inside your network can reach private package registries, staging databases, and services behind your VPN.
  • Data residency and review. Regulated teams must document where source code and secrets go. "Execution stays in our cloud account" is a short answer.
  • Laptop lifetime. An agent on your laptop dies when the lid closes. A server session keeps working through your commute and overnight.
  • Compute economics. You pay your cloud provider's price for the VM, not a platform's bundled compute margin.

Option 1: A plain VM with tmux and SSH

The simplest setup needs no platform at all: a Linux VM, SSH, tmux, and the agent CLI of your choice. Claude Code and Codex run happily on a headless server, and tmux keeps the session alive when your connection drops.

# On the VM (once): install your agent CLI and log in
ssh dev-box

# Per task: a named tmux session that outlives your SSH connection
tmux new -s fix-auth
claude            # or codex, or any terminal agent

# Detach with Ctrl-b then d. Close your laptop. Later, from anywhere:
ssh dev-box
tmux attach -t fix-auth

Add mosh for flaky networks and Tailscale to keep the VM off the public internet. Total control, minimal moving parts, every CLI works, and it costs only the VM. The setup guide covers sizing, hardening, headless CLI auth, and keeping sessions alive; running Claude Code on a cloud VM walks the provisioning end of it (picking a provider, instance size, and headless login), and keeping Claude Code running after closing your laptop goes deep on the persistence patterns.

The limits arrive with teammates and scale: sharing a session means sharing SSH access, two tasks in one checkout trample each other unless you script git worktrees per task (isolation is half of limiting what a coding agent can destroy), tmux sessions are in-memory so a reboot clears them, and nobody sees what agents are doing without logging in.

Option 2: OpenHands and Coder, the fully self-hostable platforms

OpenHands is the most established fully self-hostable harness. As of October 2026 its core is MIT-licensed (the enterprise control plane is a separate commercial tier) and it typically runs via Docker: an application server serves the web UI and conversation logic, and spawns sandboxed runtime containers where the agent edits files and runs commands. It can also drive third-party agents such as Claude Code and Codex over the Agent Client Protocol, alongside its own agent. If you are weighing it against the routes on this page, the OpenHands alternatives page compares them head on.

The model is bring-your-own: paste an API key for a hosted provider, or set a custom base URL to point at a local server such as Ollama, vLLM, or LM Studio. That makes OpenHands one of the few options where every piece (harness, execution, even the model) can run inside your network. One sharp edge from its own docs: Ollama's default context window (4,096 tokens) is far too small for the agent's system prompt, so a local setup needs OLLAMA_CONTEXT_LENGTH raised to at least 22,000 tokens before it behaves correctly, with 32,768 the documented recommendation.

Coder Agents went generally available on September 9, 2026 and is the strongest "everything on our infrastructure" answer among the platforms: the control plane, orchestration, and execution all run in your own cloud VPC, on-prem, or fully air-gapped, and the model can be any hosted provider (Anthropic, OpenAI, Google, AWS Bedrock) or your own self-hosted endpoint, so a locked-down deployment can keep code, prompts, and model traffic entirely inside the network. The underlying platform is open source under AGPL v3; as of October 2026 Coder's pricing page allows up to five active Coder Agents on the Community and Premium tiers, with an AI Premium tier that is unlimited.

The tradeoff for both: you operate them. OpenHands needs Docker socket access to spawn sandbox containers (fiddly on locked-down hosts), Coder is a platform to deploy rather than a CLI to install, and upgrades, persistence, and access control are your job either way.

Option 3: Self-hosted workers for a vendor platform (Cursor, Warp Oz)

The newest pattern is "execution local, brain remote": the vendor's product, with the worker that touches your code on your machines.

Cursor runs cloud agents on machines you manage through Self-Hosted Machines, documented in two shapes as of October 2026: My Machines, which connects a personal laptop or VM to your own account, and Team Pools, named pools of workers on Enterprise plans that route agent runs to shared company-managed capacity (a pool request queues until a free worker picks it up, and admins can keep separate pools for different hardware, such as GPU boxes or Macs for iOS builds). Workers open a long-lived outbound HTTPS connection to Cursor's cloud, with no inbound ports, public IPs, or VPN tunnels, and the documented ceiling is 200 workers per user and 1,000 per team. Cursor's docs draw the boundary precisely: terminal commands, file edits, browser actions, and other tool calls execute on your worker, next to your repos, build caches, secrets, and internal services, while the agent loop, planning, and model inference run in Cursor's cloud; during a run the worker sends Cursor the file chunks the model reads, and uploads artifacts such as screenshots, videos, and log references to Cursor-managed storage. The repository clone stays local; the context the model reads does not.

Warp's Oz platform offers self-hosting exclusively on its Enterprise plan, in two shapes as of October 2026: a managed worker daemon (oz-agent-worker, open source on GitHub) that connects out to the platform and executes tasks in Docker containers, Kubernetes Jobs, or directly on hosts, or an unmanaged mode where your own CI or scripts invoke the agent command and Warp only tracks the session. Repository clones, source files, build artifacts, and runtime secrets stay on your infrastructure. Warp's documentation is direct about the boundary: orchestration metadata, session transcripts (including code context in prompts), and LLM inference route through Warp's control plane under Zero Data Retention agreements. A bring-your-own-LLM option on Enterprise can route inference through your own cloud provider account instead, and as of October 2026 it covers cloud agents, with support varying by provider.

This pattern satisfies "our code artifacts stay in our network." It does not satisfy "no source-derived context leaves our network": prompts still flow through the vendor and the model provider.

The model is usually still someone else's computer

Self-hosting the agent almost never means self-hosting the model. Claude Code executes on your machine but calls Anthropic's API. Codex CLI is open source under Apache 2.0 and runs locally, but the reasoning happens at OpenAI. Wherever the agent runs, prompts carry code context to the model provider under its data terms.

The exception is open-weight models. As of October 2026, Ollama, vLLM, LM Studio, and llama.cpp can serve models like the Qwen3-Coder family on your own GPUs, and all four speak an Anthropic-compatible /v1/messages API (Ollama shipped its native endpoint in v0.14.0 in January 2026, and vLLM's own docs cover pointing Claude Code at a vLLM server directly), so even Claude Code can point its base URL at a local endpoint, and nothing leaves your network at all. Budget context as well as GPUs: Ollama's docs recommend at least a 32k token context window for Claude Code, the same lesson as the OpenHands guidance above. The costs are real: serious GPU capacity, and open-weight coding models that still trail the hosted frontier on hard agentic work. Most teams split it: self-host execution and custody, keep a frontier hosted model under your own accounts and keys, and cover the prompt flow with the provider's enterprise data terms. The open-weights shelf is also refreshing faster than it ever has: DeepSeek V4 Pro went GA under MIT on August 13, 2026, and Z.ai's GLM-5.3 (August 14) ships its weights roughly two weeks after launch, so a self-hosted model menu that looked settled in spring is worth re-checking monthly.

The options at a glance (October 2026)

OptionRuns on your infrastructureStays with a vendorModel
Plain VM + tmuxEverything except the modelNothingHosted API, or local via a compatible endpoint
OpenHandsHarness, UI, and executionNothing requiredYour choice, including fully local
Coder AgentsControl plane, orchestration, and execution; air-gap capableNothing requiredAny hosted provider or your own self-hosted endpoint
Cursor Self-Hosted MachinesTool calls: terminal commands, file edits, browser actionsAgent loop, planning, inference, run artifactsHosted via Cursor
Warp Oz self-hostedCode, execution, runtime secretsOrchestration, transcripts, inference routingHosted via Warp, or BYO-LLM on Enterprise
AQAgent CLIs, code, credentials, execution on your VMWeb dashboard streaming your sessionsYour own Claude/OpenAI accounts via CLI login

Which self-hosted route should you pick?

Match the route to the boundary you need and the operations you can afford, not to feature lists:

  • One engineer, comfortable with SSH: the plain VM with tmux. Nothing to operate, every CLI works, and you can graduate later without redoing anything.
  • You want a harness UI on your own machines and will operate it: OpenHands. MIT-licensed core, Docker deployment, and the only route on this page where the model can also be local with no commercial tier involved.
  • Regulated or air-gapped enterprise with a platform team: Coder Agents. The whole platform runs in your VPC or enclave, against any hosted or self-hosted model endpoint.
  • Already on Cursor or Warp Enterprise and the requirement is "execution inside our network": their self-hosted workers. Accept that prompts, orchestration, and inference still route through the vendor.
  • A team that wants the plain-VM pattern shared and persistent without operating a harness: AQ, covered next.

Whichever route you pick, decide the model question separately: hosted frontier model under your own accounts and keys, or an open-weight model served locally when the policy requires that prompts never leave the network.

Where AQ fits

AQ is the multiplayer coding harness where engineering teams run AI coding agents like Claude Code and Codex together: shared live terminals, a code editor, and app previews, in your own cloud. In this guide's terms, AQ is the plain-VM pattern turned into a team product. Agents run as real CLIs (Claude Code, Codex, Cursor Agent, Kimi, Grok, or plain shells) in persistent tmux sessions on your team's VM, so sessions survive a closed laptop, and each one is streamed to the browser where teammates can open the same workspace and see and steer the same live session.

Custody follows the same lines as doing it by hand. Each engineer logs into the CLIs with their own Claude or OpenAI account (no inference markup, no shared vendor key), commits and PRs use per-user GitHub auth, and every workspace gets its own isolated git worktree so parallel tasks never collide. Live previews support pinned comments that can be sent straight to the agent, Linear issues flow in via an "ai-task" label, and there is no shared multi-tenant execution tier: your agents run on your VM. The glue is built in: runner health is visible in the product, the installer runs preflight checks, and an aq-runner doctor command diagnoses a broken host.

Pricing is two plans. The Free plan is a personal sandbox for one person, created by AQ with nothing to install. Self-hosting on VMs you bring, exactly what this guide covers, is part of the AQ Pro plan at $50 per user per month early access pricing (standard $200, billed monthly), which also includes a dedicated, always-on AQ-managed option, with your rate locked for your first 12 months.

Plainly: if you are one engineer and comfortable in tmux, the VM pattern above is enough, and you should use it. AQ earns its place when a team wants those same self-hosted sessions shared, persistent, and visible without building the glue.

Frequently asked questions

Does self-hosting an AI coding agent keep my code off vendor servers?

It keeps your repository clone, build artifacts, and credentials on your machines, which is the highest-stakes part. But unless you also serve an open-weight model locally, prompts containing code context still go to the model provider, and platforms like Cursor and Warp additionally route orchestration and inference through their own clouds. Be precise about which boundary your policy actually requires.

Can I run Claude Code or Codex CLI without any cloud dependency?

The CLIs themselves run entirely on your machine, but by default they call hosted APIs at Anthropic and OpenAI. As of October 2026, Ollama (native /v1/messages endpoint since v0.14.0, January 2026), LM Studio, llama.cpp, and vLLM expose an Anthropic-compatible API, so Claude Code can be pointed at a locally served open-weight model via its base URL setting; Ollama's docs recommend at least a 32k token context window for it. Expect a capability gap against frontier hosted models on hard agentic tasks, and budget real GPU capacity.

What is the cheapest way to self-host a coding agent?

A small Linux VM, tmux, and the CLI subscription you already have. SSH in, start a named tmux session, run the agent, detach. Your only new cost is the VM. AQ's Pro plan wraps exactly this pattern on VMs you bring, and the Free plan skips the setup entirely: a personal sandbox AQ creates for you, with the browser workspace on top.

How do I set up a self-hosted AI coding agent environment?

One Linux VM you control, an agent CLI like Claude Code or Codex, and tmux for persistence: that is the whole environment. Size the VM for your builds, keep SSH off the public internet, authenticate the CLIs once on the headless machine, and run each task in a named tmux session inside its own git worktree. The setup guide walks every step in order, from a fresh Ubuntu server to a persistent working agent.

What is the best self-hosted AI agent platform for a team?

It depends on which pieces you want to operate yourself. OpenHands is the most established fully self-hostable harness if you are willing to run and upgrade it, and Coder Agents (generally available September 2026) extends that to the whole platform, control plane included, with air-gapped deployment supported. Cursor and Warp Oz put workers on your machines while keeping orchestration and inference in their clouds. AQ keeps agent execution, code, and credentials on VMs you bring and adds the team layer on top: shared live sessions, previews, and per-user auth, without operating a harness yourself.

Can I self-host the entire coding agent stack, including orchestration and the model?

Yes, two ways as of October 2026. OpenHands runs its MIT-licensed harness and sandboxed execution on your machines and can point at a locally served model through Ollama, vLLM, or LM Studio. Coder Agents, generally available since September 9, 2026, runs the control plane, orchestration, and execution in your own VPC, on-prem, or fully air-gapped, against any hosted or self-hosted model endpoint (as of October 2026 Coder's pricing allows up to five active agents on the Community and Premium tiers, with an unlimited AI Premium tier). Both make you the operator: deployment, upgrades, and access control become your job, which is exactly the work the plain-VM route avoids.

Is a locally hosted coding agent different from a self-hosted one?

In practice "locally hosted" usually means the agent runs on your laptop or workstation, while "self-hosted" usually means a server or VM you control. The custody story is identical; the difference is lifetime. A laptop agent dies when the lid closes, a server agent keeps working, which is why most teams graduate from local to a VM once agents run longer than a coffee break.

Do Cursor's self-hosted cloud agents keep everything on my infrastructure?

No. As of October 2026, the workers you run keep tool execution (terminal commands, file edits, browser actions) and your repos, build caches, and secrets inside your environment, connecting outbound over HTTPS with no inbound ports. Cursor's own documentation is precise about what leaves during a run: the file chunks the model reads, plus artifacts such as screenshots, videos, and log references uploaded to Cursor-managed storage. The agent loop, planning, and model inference remain in Cursor's cloud. That split is useful, but it is narrower than full self-hosting.

Do I need Kubernetes to self-host coding agents?

No. A single Linux VM with tmux runs any agent CLI, and that is the right starting point for most teams. Kubernetes enters the picture at fleet scale: Cursor documents Kubernetes templates for large self-hosted worker pools, Warp's managed worker can execute tasks as Kubernetes Jobs, and OpenHands documents a Kubernetes deployment. If you are not already operating a cluster, do not stand one up just for agents.

How do I keep secrets safe on a self-hosted agent machine?

Self-hosting puts credentials on hardware you control, but the agent can still read anything on the box and include it in a prompt to the model provider. Scope tokens per user and per task, keep production credentials off the agent VM entirely, and prefer short-lived credentials the agent requests at use time. Keeping secrets out of coding agent prompts covers the patterns in detail.