Table of Contents
- What a self hosted AI agent puts under your control
- Managed, BYOC, or fully self-hosted: who operates what?
- Choose the execution boundary before the provider
- What the available sandbox options actually offer
- Compare the full cost of useful work
- Deploy one representative job before building a fleet
- Design persistence, scheduling, and migration together
- Self-hosting questions before you commit
- Can I self-host an agent and use a cloud model?
- Do I need to operate Kubernetes for one agent?
- Does a VM make unrestricted tool access safe?
- Where should I start if I mainly want lower hosting costs?
Do not index
A self hosted AI agent runs its application on infrastructure you operate, but its model and execution sandbox can live elsewhere. Choose full self-hosting when you need control of the execution environment and can maintain it; use managed sandboxes such as Agent37 when you want to run your agent without operating the underlying sandbox fleet.
The useful question is which responsibilities you want to own. You can manage an agent’s code and credentials while renting its execution environment. You can also operate the entire stack, including the hosts that run untrusted commands. Those choices have different costs, failure modes, and data paths.
This guide compares both routes, including bring-your-own-cloud, using documentation checked on November 14, 2026. Start with your workload, then price the infrastructure that can actually run it.
What a self hosted AI agent puts under your control
Separate three components before choosing a deployment. The agent application decides what to do next. The model produces responses and tool calls. The execution environment runs commands, stores working files, and provides access to tools.
Hosting the application yourself does not automatically host the model. If your agent sends prompts or document excerpts to an external inference API, those requests leave your server. Running a model locally is a separate infrastructure decision with its own memory, accelerator, and maintenance requirements.
Likewise, a self-hosted application can send code to a managed sandbox. That arrangement lets you keep your application’s release process while delegating sandbox provisioning and host maintenance. It does not put the sandbox inside your own cloud account.
Write down where prompts, files, logs, credentials, backups, and model requests travel. This gives you a more useful deployment specification than a single “self-hosted” label. It also exposes cases where moving a container changes very little about the actual data path.
Managed, BYOC, or fully self-hosted: who operates what?
Managed sandboxes provide an execution service through an API or dashboard. With full self-hosting, your team operates the sandbox service and its underlying infrastructure. Bring-your-own-cloud, or BYOC, places workloads in your cloud account under a vendor’s operating model.
Route | Infrastructure operator | Work you still own |
Managed sandbox | Provider | Agent, access, data, recovery |
BYOC | Contract-dependent | Cloud account, IAM, application |
Self-hosted stack | Your team | Hosts, runtime, agent, operations |
Managed infrastructure reduces the work of maintaining hosts. You still need application monitoring, access controls, tested recovery, and a cleanup policy. “Managed” does not mean the provider understands whether an agent’s proposed database write is appropriate.
BYOC can help when workloads must run in a particular account or network. Northflank’s BYOC offering supports deployments into customer infrastructure and manages cluster lifecycle. Before choosing any BYOC service, establish who can access the control plane, which permissions its operator receives, where telemetry travels, and who approves upgrades.
Do not treat deployment location as proof that every security or contractual requirement is satisfied. Map the complete service, including external model and tool connections, against your requirements.
Choose the execution boundary before the provider
An agent with shell access can affect every file and credential its process can reach. Give it a dedicated workspace and limited credentials. Avoid running unfamiliar generated code as the same user that holds your production secrets.
Ordinary Docker containers use namespaces and resource controls while sharing the host kernel. Docker’s security documentation also highlights the daemon and container configuration as attack surfaces. Mounting a powerful host socket into an agent container can undo much of the separation you intended.
gVisor adds a separate application kernel between the workload and the host. It is a distinct isolation design, not simply a synonym for Docker. Test the system calls, filesystem behavior, and dependencies your workload requires rather than assuming universal compatibility.
A microVM runs a guest kernel behind a virtualization boundary. Firecracker uses Linux KVM to create these environments. A guest kernel changes the boundary, but neither that label nor a launch-time benchmark proves your complete deployment is secure or fast.
On Agent37, standard sandboxes use gVisor. Full VMs are a separate option for workloads needing their own Linux kernel, including Docker and Compose. The standard runtime cannot run a Docker daemon. Read the VM requirements before choosing a template: VM entrypoints do not support systemd as init.
Use the microVM versus container guide for the architecture details. Then test your actual dependency installation, build, tool calls, and file writes on the candidate runtime.
What the available sandbox options actually offer
Choose infrastructure by its current deployment path. A public repository, an SDK, and a maintained self-hosting product are different things.
Agent37 provides managed standard gVisor and full VM sandboxes through a shared API and wallet. It fits teams that want to deploy agent workloads while buying infrastructure by usage. This guide uses that hosted service; it does not describe an Agent37 control plane you install in your own VPC.
E2B now documents Embed in its runtime repository, a single-machine deployment with Docker Compose and cloud provisioning paths. Its documented requirements include Linux with hardware virtualization. Embed serves plain HTTP without its own TLS, so follow its network guidance and plan authenticated, protected access. The repository distinguishes this single-node option from managed Cloud and enterprise deployment routes. A single-node install still needs a recovery and capacity plan.
Daytona has a maintained hosted service, but its old public core repository says core development moved to a private codebase in June 2026. The public repository was archived on October 3. An old self-host tutorial therefore needs a maintenance assessment; it is not evidence that you will receive the current service’s fixes or features. Its current Bring Your Own Compute documentation describes customer-run infrastructure connected to Daytona’s control plane and requires organization enablement. Our Daytona self-hosting guide explores that distinction.
Modal Sandboxes should not be dismissed as ephemeral functions. Its snapshot documentation describes filesystem, directory, and memory snapshots. Their retention and restoration limits differ, so persistence needs an explicit design. Northflank BYOC is another route when you want a vendor-operated platform on your own infrastructure.
For each candidate, test the same job and record its output, readiness time, total elapsed runtime, retained storage, and recovery behavior. This is an evaluation checklist, not a benchmark result from this article.
Compare the full cost of useful work
Open-source licensing does not remove compute, storage, model, or operating costs. Managed billing is not necessarily a flat subscription either.
For a self-hosted stack, budget the host, retained disks, backups, network services, monitoring, spare capacity, and time spent operating it. For managed infrastructure, include resource charges, retained state, transfer, plan fees, and any applicable allowances. Add model and tool spending separately in both cases.
Agent37’s published rates are $0.80 per vCPU, $0.70 per GB RAM, and $0.09 per GB disk per 730-hour month for standard compute. Usage is metered by the minute. Full VM compute costs 2.5 times the standard rate; disk has the same rate.
The following estimates use 2 vCPU, 4 GB RAM, and 4 GB disk, with no model or tool spend:
Usage and disk retention | Standard | Full VM |
60 hours, then deleted | $0.39 | $0.93 |
60 hours, disk kept 730 hours | $0.72 | $1.26 |
730 hours, disk kept 730 hours | $4.76 | $11.36 |
Standard compute for 730 hours is
2 × $0.80 + 4 × $0.70 = $4.40. Retaining 4 GB of disk for that period adds $0.36. For a shorter workload, multiply compute by running hours divided by 730, and disk by retained hours divided by 730.An awake instance bills compute even while its CPU is idle. Stop or sleep pauses compute; retained disk still costs money. Deleting the instance ends its meter, so export anything you need first. Auto-sleep requires configuration.
The Ubuntu VM template defaults to 12 GB disk when disk is omitted. At 2 vCPU and 4 GB RAM, its 730-hour estimate is $12.08. Choose disk for your images and working data; the 4 GB comparison is not a promise that every Docker workload fits.
These are list-rate calculations, not equivalent-throughput measurements. Shared resources, actual job duration, free allowances, and existing hardware can change the result. There is no universal “thousands of sandboxes” threshold at which self-hosting becomes cheaper. Use your own bill and operating time.
Deploy one representative job before building a fleet
Start with a small job that exercises the things your agent really needs: downloading dependencies, writing a file, calling a permitted API, and returning an artifact. Give it test data and a scoped credential. Record what success looks like before running it.
First, package the workload with a pinned release or image digest, explicit dependencies, and a repeatable startup command. Document its writable paths. On Agent37, custom templates provide the image path; do not assume every arbitrary image includes the chat endpoints supplied by harness templates.
Next, set CPU, memory, disk, execution time, and spending limits at the layers that enforce them. Keep the infrastructure administration key in your trusted controller where possible. A worker running generated commands should not automatically inherit credentials that can manage every other worker.
Configure outbound access before processing untrusted input. Agent37’s network policy defaults to allowing the public internet. An allowlist restricts destinations;
deny-all also blocks DNS and built-in model and tool services. Managed services require api.agent37.com to be allowed. An outbound policy does not replace authentication on incoming requests.Finally, exercise failure. Stop the worker during a job, restart it, and check whether the application can detect incomplete work. Retry safely using a durable job identifier. Test that unauthorized destinations fail and that expected outputs can be exported. Passing one happy-path command is only the first check.
Design persistence, scheduling, and migration together
A persistent disk and a resumable process are separate guarantees. Store checkpoints, completed job identifiers, and important outputs in durable storage. Keep a backup outside the instance when losing that instance would lose useful work.
Agent37’s auto-sleep documentation describes memory restoration with a possible cold-boot fallback. After that fallback, files remain but processes and memory do not. The application needs a startup and recovery path; it should not depend on a sleeping process remembering the next task.
Put schedules somewhere that remains active while the worker sleeps. Agent37’s platform crons can wake an instance and deliver its prompt. A crontab running only inside the sleeping instance cannot do that. Check whether your chosen template supports the scheduled action you need.
For migration, an image is a useful starting point. Also inventory volume paths, environment variables, secret delivery, execution APIs, network rules, health checks, and snapshot formats. A container image does not export all of those dependencies.
Run a restore drill on the destination: load a backup, start the application, execute a representative task, and retrieve its output. That is stronger evidence of portability than a claim that every move is just a redeploy.
Self-hosting questions before you commit
Can I self-host an agent and use a cloud model?
Yes. Your application and the model can run in different places. Document which data is sent to the model provider, and budget its charges separately from hosting.
Do I need to operate Kubernetes for one agent?
The deployment you choose determines that. One agent can run on a single suitable host or managed sandbox. Kubernetes is an operating choice, not a prerequisite attached to the word “agent.”
Does a VM make unrestricted tool access safe?
No. A VM boundary does not stop an authorized credential from deleting data in an external service. Combine runtime isolation with scoped access, network policy, and approval for consequential actions.
Where should I start if I mainly want lower hosting costs?
Measure one representative workload on the runtime it needs. If managed infrastructure fits, create an Agent37 sandbox, verify its recovery behavior, and compare the measured running hours plus retained disk with your self-hosting budget. Choose a full VM when the job needs Docker or kernel access, and keep model and tool spending in their own budget.
