Self-Hosted AI Agent: What You Run, and What You Must Lock Down

A self-hosted AI agent runs on hardware you control instead of a vendor's cloud. You operate four parts yourself: a model runtime that serves an open-weight model, an orchestrator that runs the agent loop, the tools it may call, and a memory store. The payoff is data control; the cost is that security becomes your job.

The four parts of a self-hosted agent
PartWhat it doesOpen-source examples
Model runtimeLoads a model and answers requests over a local APIvLLM, LocalAI
OrchestratorRuns the loop: ask the model, call a tool, feed back the resultLangGraph, CrewAI, smolagents, n8n
ToolsFunctions or MCP servers the agent may callFilesystem MCP server, your own scripts
MemoryStores conversations, documents and stateA database you already run

Updated

Self-hosting appeals to businesses that cannot send customer records to a third party, or that want fixed costs instead of per-request bills. It is real engineering work, though: you patch the servers, size the hardware and decide what the agent may touch. This page walks through each part in plain words and ends with a checklist you can tick through before anything goes live.

Self-hosted agent security checklist

Tick what is already true. Your ticks stay in this browser tab only.

Model runtime

Orchestrator

Tools

Memory and data

Running it

Keeping the runtime private

A sketch of the network idea, not a full deployment. Only the orchestrator is published to the host; the runtime has no published port.

docker-compose.yml outline

The runtime sits only on an internal network with no route out; the agent joins it and the default network. Replace the image names with the runtime and agent you chose.

services:
  runtime:
    image: your-model-runtime:pinned-version
    networks: [private]
    # no "ports:" here, so nothing outside can reach it

  agent:
    image: your-agent:pinned-version
    environment:
      MODEL_URL: http://runtime:8000
    ports:
      - "127.0.0.1:3000:3000"
    networks: [private, default]

networks:
  private:
    internal: true

Why the runtime and the agent are separate

The runtime only answers "given this text, what comes next". It has no idea what an order or a booking is. The orchestrator turns those answers into actions by reading the model's request for a tool, running it, and passing back the result.

Keeping them apart means you can swap the model without rewriting the agent, and you can lock the runtime away on a private network while the orchestrator handles the outside world.

Security is the part people skip

OWASP names excessive agency as a core risk: an agent with too many functions, too many permissions or too much autonomy. In a self-hosted setup you set all three, so set them low.

The MCP project's security guidance adds a point specific to local tool servers: they run on your machine with your access, so only install ones from sources you trust and review what each one can do.

How it works

  1. Choose an open-weight model whose licence allows your use, and a runtime that can serve it on your hardware.
  2. Pick an orchestrator in a language your team can maintain.
  3. Give the agent the fewest tools that do the job, each with the narrowest permissions possible.
  4. Work through the checklist below, then run it on test data for a while before real customers see it.

Tips

Frequently asked questions

Is a self-hosted agent more private?

It can be, because prompts and data stay on machines you control. That only holds if the runtime, logs and backups are also kept private, and if no tool quietly sends data to an outside service.

What hardware do I need?

It depends heavily on the model size and how many people use it at once, so we will not quote a number. As one data point, vLLM's install guide lists Linux and a GPU with compute capability 7.5 or higher, while LocalAI says no GPU is required. Test on rented hardware first.

Can I self-host a no-code agent tool instead of writing code?

Some workflow tools can be self-hosted. n8n, for example, offers self-hosting under its own Sustainable Use License, a fair-code licence with limits that differ from MIT or Apache, so read it before commercial use.

What is the biggest security risk?

Prompt injection: text the agent reads, such as an email or web page, that tricks it into acting against you. OWASP lists it first in its risks for language model apps. Limiting tools and requiring human approval for high-impact actions are its main defences.

Related: How to build an AI agent, What is an MCP server?, Open-source agent frameworks, Filesystem MCP server, AI agent test checklist.

Start for free or see all free tools. We.Inc is free to start, with no card needed. AI building is on paid plans from $20 a month.

More in Guides

We.Inc is an AI-powered website builder you can resell under your own brand. Launch a branded client dashboard, bill on Stripe Connect, and deliver AI-generated websites in minutes. White-label plans start at $99 a month for 25 client sites, with a 7-day free trial and no per-site fees.

Product

Who It's For

Features

Resources

Company

View Sitemap