A self-hosted AI agent — four boundaries you must own

Running the container is easy. Owning durable state, data paths, permissions, credentials and failure…

A self-hosted AI agent — four boundaries you must own

The short version

  • A self-hosted AI agent requires operator control over durable state, execution, data paths, tools, permissions, and recovery.
  • Task-scoped permission evaluation reduced severity-weighted credential attack surface by 84% on the paper’s labelled dataset.
  • Readers must trace outbound data, separate memory from authority, and plan who handles failures before deployment.

The Docker command finished before my espresso. The responsibility may outlive the machine. A self-hosted AI agent runs its task loop and stores working state on infrastructure I control.

But where do its prompts, credentials, files and tool results go?

External inference sends context across a provider’s boundary. A host-side MCP server can give the sandbox a door into my machine. Mounting a working directory directly makes every “creative” edit appear immediately on the host. Self-hosting gives me control by making the boundary my problem.

Bar chart comparing current figures against their baselines: Organisations with significant exposure… 86 % versus 14 %, Organisations reporting end-to-end… 14 % versus 86 %, reported order accuracy for the IBM… 80 % versus 95 %, Increase in available GPU KV-cache-token… 37 % versus 8 %.

Martin Merz described the requirements for Europe’s digital resilience:

La résilience numérique de l’Europe repose sur une souveraineté à la fois sécurisée et scalable.

I must know what can leave, which actions need approval, how access is revoked and whether unfinished tasks survive crashes. Launching the container is easy. Docker makes us feel competent for roughly seven seconds.

The server has to outlive the client

Continuity separates an agent from a chatbot. A chatbot waits for me. A background agent may keep inspecting a repository, processing an inbox or awaiting approval after I close my laptop. Its state belongs on the server doing the work.

AWS’s Pizza Bot design shows this cleanly. The server owns agent state and exposes it over HTTP; desktop, browser and terminal interfaces are clients. I can start tasks manually, on a schedule or through a webhook. The server runs them, checkpoints progress and puts completed work or approval requests into inbox queues. Because checkpoints live server-side, closing a thread or switching devices does not kill the job. Pizza Bot also stores data in an operator-owned folder and accesses tools through MCP servers.

The loop works like this. I submit a task; the server loads its instructions and relevant saved state. It sends selected context to my chosen model provider, which proposes an action. The runtime checks that the requested tool exists, invokes it and records the result. That result becomes context for the next model call—the model has not magically learned anything. At checkpoints, the server saves enough progress to resume after a restart or await approval. The run stops when it finishes, fails or reaches my stopping rule.

Clients become disposable. Browsers can reload, terminals can disconnect, and I can start a desktop task before approving it by phone. None holds the authoritative state.

Durability brings database problems, naturalmente. Hermes Agent’s September patch notes described secondary processes disrupting SQLite and POSIX locks. A dashboard could open a writable handle while another gateway was active; a cron lifecycle check could disturb a live database. Fixes separated shared state, constrained read-only consumers and rejected unsafe checkpoints. Another repair rebuilt damaged full-text search data while preserving authoritative transcripts. One malformed timestamp could also kill the session list—an operatic response to a bad date.

The model remains replaceable. Stored task state provides continuity; inference is a swappable dependency. That matters when a provider changes prices, a local model improves or Tuesday’s binary update turns throughput into minestrone.

Local inference closes only one exit

I once treated “self-hosted” as shorthand for “private.” I was wrong.

Cursor’s Self-Hosted Machines documentation is a useful reality check. The checkout, local credentials and build cache remain on the worker, which needs only an outbound connection. Teams can keep code execution inside their network without operating the whole agent service. But Cursor still runs the agent loop and inference. During a run, file contents, terminal output, diffs, screenshots and local MCP results can go to Cursor. Artifacts may land in Cursor-managed storage. Execution is local; the full data path is not.

Karine Brunet explained the limits of complete independence:

Today’s organisations operate in highly interconnected technology ecosystems where complete independence is rarely achievable.

Local inference closes one major outbound route. Webhooks may still fire, analytics phone home, packages get downloaded, and the agent may call a SaaS API five minutes later. I must trace every path—preferably before customer data takes the tour.

Local inference works on hardware many founders already own. Our test machine was an M3 Max with 128 GB of memory; both tested models used MXFP4 weights fully resident in memory.

There, gpt-oss:20b generated about 74 tokens per second, versus roughly 51 for gpt-oss:120b. The lighter model produced its first token in about four seconds; the larger needed around six under the same setup. Both felt comfortable for one interactive agent.

That says little about twenty concurrent background jobs, long contexts or recovery after the model server falls over. A batch test on one RTX 3090 shows why workload shape matters: with many concurrent requests, aggregate decode reached about 1,100 tokens per second, versus 46 for one request in the same vLLM benchmark. One user does not get warp-speed responses. The GPU stays busy serving a queue.

Hardware allocation can wreck a sensible plan. ComfyUI already occupied our RTX 5060 Ti, leaving Ollama around 150 MB of VRAM, so the language model ran on the CPU. Apparently the GPU had chosen art school.

Two operators guide a replacement storage node into a private-cloud rack during a self-hosted AI recovery test.

Alt text: A self-hosted AI agent server holding task state while clients, model providers, tools and approval queues connect through controlled boundaries.

Permissions must survive a confused model

I want the model proposing actions. A separate enforcement layer decides whether they happen.

The sequence should be boring enough to audit. The runtime requests a specific tool operation, destination and payload. Before any effect, policy checks the task, agent identity and permitted operation. Sensitive actions pause for human approval. A credential broker grants authority only for the approved destination; network rules block unmatched outbound traffic. The result returns through that controlled route into the task record. I can revoke access even if the model misunderstands instructions or swallows a malicious webpage prompt.

Static API keys are ugly because they expose every deployment-time permission to tasks needing one narrow capability. An evaluation of task-based permission scoping found that a role ceiling closed 28% of the original credential set’s severity-weighted attack surface. Adding a classifier to choose permissions for the current task raised the reduction to 84% on the paper’s labelled dataset. These numbers come from an evaluation, not production incidents. The mechanism still holds: authority withheld from a task cannot be abused by it.

Memory complicates this because yesterday’s notes can impersonate today’s authorization policy. The EAL-Bench paper found incremental memory writers created false authority for up to 50% of unauthorized requests in tested domains. When false authority was present, executor models acted on it in 99% of trials. Memory updates can therefore change what the next model believes it may do, not just its context. I let memory retain preferences and task history. Permissions need a separate source of truth and explicit revocation.

Docker Sandboxes provide a practical local boundary. They place the agent in a microVM, proxy permitted outbound TCP traffic and inject provider credentials through a host-side proxy, keeping raw values outside the VM. Hostname binding matters: credentials approved for one API should fail elsewhere.

Read Docker’s workspace-mount documentation twice. Direct mounts are read-write, so sandbox and host share one working tree. Without a private clone, agent edits—including Git hooks or CI files—appear on my machine immediately. Local stdio MCP servers also run on the host outside the sandbox VM, so I treat them as trusted host integrations. A microVM cannot protect me from a bridge I deliberately built around it.

Someone still gets the 3 a.m. call

I start with the three-in-the-morning test. Who patches the runtime, restores the state database, rotates leaked credentials and stops runaway tasks? If every answer is “future Luca,” I price in a tired, annoyed Luca already debugging something else. He is talented but deeply resentful.

Full self-management gives me maximum control over execution and stored state. A hybrid service may keep workers inside my network while the vendor runs the agent loop or control plane. Managed agents move more operations to the provider. Air-gapped deployments are stricter because even outbound management connections may violate the requirement.

Scale changes the job: multiple agents need distinct identities, central suspension and per-task limits. WSO2’s Agent Manager materials describe a self-hostable control plane with sandboxed execution, OpenTelemetry traces, MCP controls and per-agent identity. In the company’s September release materials, Rania Khalaf wrote:

Speed and control get treated like a tradeoff.

Her point was that operators should keep both. I agree, but independent production-scale evidence still cannot show whether self-hosted stacks suffer fewer security incidents than managed agent services. We also lack comparable operating-cost, patching-burden, reliability and recovery-time data across local machines, private clouds and managed deployments. Nobody knows how often operators weaken their own sandboxes with direct mounts or host-side MCP servers.

That uncertainty cuts both ways. Vendors cannot wave at “enterprise security” and declare victory. Self-hosters cannot point at a rack and assume sovereignty. I need deployment evidence: where data travelled, which authority was used, who approved the action and whether restored tasks behave correctly after failure.

By the end of 2027, I expect serious self-hosted agent products to include resumable server-side state and task-scoped credential brokers by default. Today, products still give agents permanent API keys and writable home-directory mounts. Soon that will look like a deep fryer beside paper napkins.

Before an agent touches customer data, I want to unplug the model and answer three questions: what could it access, what did it change, and can I revoke its authority? Intelligence supervising itself is merely confidence with shell access.

Frequently asked questions

What is a self-hosted AI agent?

A self-hosted AI agent runs its task loop and stores working state on infrastructure the operator controls. The operator is responsible for tracing outbound data, controlling tools and permissions, revoking access, preserving unfinished tasks through crashes, and maintaining the runtime and state database.

Does self-hosting an AI agent keep all data private?

Self-hosting does not automatically keep all agent data private. External inference can receive prompts and context, while webhooks, analytics, package downloads, SaaS tools, artifacts, and host-side MCP results may cross other boundaries. Local inference closes one outbound route, so operators must trace the entire data path.

How should a self-hosted AI agent handle permissions?

Agent permissions should be enforced outside the model through policy checks, human approvals, task-scoped credentials, destination binding, and outbound network rules. Memory may retain preferences and history, but it must not become the source of authorization. Access must remain explicitly revocable even when the model misunderstands instructions.

Sources

Related reading

Luca

Luca

Luca by the way is the personal blog of Los Angeles based entrepreneur Luca Capula. A true Italian who lives between Torino and LA.

More posts →