Deploy AI agents: Runtime, isolation, and deployment costs

Deploy an agent worker, verify readiness, and control its lifecycle. Compare sandbox and VM costs while planning isolation, recovery, and retained storage.

โ€ข

Published on

โ€ข

Deploy AI agents: Runtime, isolation, and deployment costs
Do not index
To deploy AI agents, package the agent and its dependencies, choose an isolated execution environment, configure model access, and verify readiness before sending work. Then test recovery, authorization, and cleanup before increasing concurrency. Agent37 provides standard gVisor sandboxes and full VMs for the execution layer, with lifecycle controls and a separate budget for managed model and tool usage.
A deployment should produce an inspectable result, survive a restart, and stop spending when its work is done. This guide connects those requirements to a concrete API walkthrough, a runtime decision framework, and compute-plus-storage estimates.

AI agent infrastructure: separate the agent runtime from its host

Consider an agent asked to inspect a repository, run tests, and propose a patch. The model selects actions. The runtime turns those choices into work, captures results, and feeds useful observations back into the next step. It also needs a way to stop, recover, and report failure.
Map each responsibility to a component before comparing products:
Layer
Its job
What you still need to decide
Model service
Produces text and proposed tool calls
Which actions are permitted and how to validate them
Agent harness or orchestration runtime
Runs the loop, manages context, coordinates steps
Where it runs and how durable state is stored
Hosted application runtime
Starts your agent application and serves requests
Deployment contract, identity, scaling, and session limits
Sandbox or VM
Executes bounded processes
Runtime compatibility, credentials, and cleanup
Durable storage
Retains checkpoints and outputs
Retention, backups, and tenant access
Queue and monitoring
Admit jobs and expose failures
Concurrency, deadlines, and spend limits
These layers can come bundled. They can also run separately. A framework does not automatically provide a hosted machine. A hosted machine does not automatically make a workflow recoverable.
LangGraph, for example, describes itself as an orchestration framework and runtime for stateful agents. Its graph execution is a different responsibility from the sandbox that runs a repository's install scripts. Keeping that distinction explicit makes both your architecture and your bill easier to understand.

Choose the runtime around the work you execute

Start with the agent's most demanding tool, then choose its environment. A customer-support agent calling approved HTTP APIs has different requirements from a coding agent that installs unknown dependencies or starts Docker services.
For an API-only agent, your existing application platform may be enough. You still need authentication, bounded retries, and durable records, but there may be no reason to create a fresh machine for each tool call.
For repository work, generated scripts, or browser processes, use a sandbox with the language runtimes and system dependencies the job needs. Keep one workspace across related steps when files and installed packages must survive between calls. Choose a fresh workspace when jobs need clean isolation from previous inputs.
For Docker Compose, Kubernetes, or software requiring kernel features, verify that the environment supports them. Agent37's standard gVisor instances cannot run a Docker daemon. Its full VMs provide a Linux kernel and KVM access, with a separate compute rate. The Ubuntu VM template includes Docker and Compose.
This is a compatibility decision before it is a price comparison. Run a representative install, test suite, and artifact export on the proposed environment. A cheaper hourly rate cannot compensate for a runtime that cannot execute your workload.

Decide how much operation you want managed

A managed application runtime can remove deployment work when its request and session model fits your application. A sandbox service gives you more direct control over the processes and filesystem you run. Neither choice supplies every part of the agent system.
Amazon Bedrock AgentCore Runtime hosts agent or tool code and manages infrastructure and sessions. Its microVM documentation describes isolated session environments and versioned deployments. The default session compute is ephemeral, but persistent filesystem options include managed session storage in preview and bring-your-own storage. Check the selected storage's expiry, version-update behavior, and network requirements. A new process can mount retained files without restoring its previous memory.
Google Cloud Agent Runtime, within Gemini Enterprise Agent Platform, is a managed environment for deploying and operating agents. Its current overview supports multiple languages and frameworks through a container runtime contract. Evaluate the contract, supported regions, and integrations against the application you already have. A managed agent endpoint and a general-purpose development workspace solve different operational needs.
Agent37 supplies sandbox infrastructure for your own application or a supported harness template. You control lifecycle and resource choices through the API. Use it when you want persistent files, process execution, and a choice between standard gVisor and a full VM. You remain responsible for your application's job queue, checkpoint logic, and external side effects.
If you already operate a reliable container platform, include staying there in the comparison. Price the engineering work you would avoid by moving, alongside the compute you would buy.

Deploy AI agents on Agent37: create, check, and run

Use a supported harness for your first deployment when it fits the job. The example below uses OpenCode on a standard sandbox with explicit resources. It demonstrates provisioning and a small agent turn; it does not install your application or prove production readiness.
Run these Bash commands from a trusted terminal or backend with curl, jq, and AGENT37_API_KEY already set. Get the key from Cloud API keys. Keep it out of frontend code and agent prompts. Your workspace wallet must satisfy the current create funding requirement.

1. Create the worker and set a managed-usage budget

set -euo pipefail
: "${AGENT37_API_KEY:?Set your workspace API key first}"

created=$(curl --fail-with-body -sS \
  https://api.agent37.com/v1/instances \
  -H "Authorization: Bearer $AGENT37_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "template": "agent37-opencode",
    "type": "default",
    "region": "us",
    "name": "deployment-check",
    "resources": {"cpu": 2, "memory": 4, "disk": 4},
    "budget": {"monthly_cap_micros": 1000000},
    "auto_sleep": false
  }')
INSTANCE_ID=$(printf '%s' "$created" | jq -er '.id')
INSTANCE_URL=$(printf '%s' "$created" | jq -er '.url')
printf 'Created instance: %s\n' "$INSTANCE_ID"
The one-million-micro setting is a $1 monthly ceiling for this instance's managed usage. It does not fund the wallet or cap compute, disk, or charges on your own provider keys. Managed budgets default to zero, so configure one before using the managed model. See managed services and budgets.
The bare template name follows its current release. For repeatable production creates, choose a published version from the template catalog and pin it with name@version. Record the resolved image digest alongside your application revision.

2. Check the agent, then send a bounded task

Creating a running computer does not prove its agent is ready. This loop waits for healthy: true; an HTTP 200 or ok: true alone is insufficient. The timeout below is a local readiness deadline, not a provisioning guarantee.
ready=false
for attempt in $(seq 1 30); do
  if curl --fail-with-body -sS --max-time 10 \
    "$INSTANCE_URL/v1/health" \
    -H "X-Agent37-Key: $AGENT37_API_KEY" |
    jq -e '.healthy == true' >/dev/null; then
    ready=true
    break
  fi
  sleep 2
done
if [ "$ready" != true ]; then
  printf 'Agent not ready; inspect logs for %s\n' "$INSTANCE_ID" >&2
  exit 1
fi

curl --fail-with-body -sS "$INSTANCE_URL/v1/responses" \
  -H "X-Agent37-Key: $AGENT37_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input":"Reply with the word READY. Do not use tools.","stream":false}' \
  > first-turn.json
jq -e '.status == "completed"' first-turn.json
jq '{session_id, status, output_text}' first-turn.json
Control-plane requests on api.agent37.com use Authorization: Bearer. Instance requests on agent37.app use X-Agent37-Key. Save the returned session ID when continuing a conversation; on OpenCode, omit it for the first turn. A completed response still needs an output check. A failed response requires inspecting its error before retrying. These examples follow the current health and chat contracts; they are not a deployment benchmark.

3. Keep state deliberately and clean up

Auto-sleep is disabled here so a quiet background job is not unexpectedly suspended. Configure it after testing the workload's activity pattern. A failed readiness or agent request can leave the instance running: save its ID and stop it when finished investigating.
curl --fail-with-body -sS -X POST \
  "https://api.agent37.com/v1/instances/$INSTANCE_ID/stop" \
  -H "Authorization: Bearer $AGENT37_API_KEY"
Stopping retains the disk and its storage bill. After exporting anything you need, delete the disposable instance through the dashboard or delete endpoint to end its instance meter.
For your own agent application, build a versioned image and register a workspace template, or use the cloud build workflow. Exclude secrets from the build context. Define the entrypoint and readiness behavior yourself; an arbitrary image does not acquire a chat API automatically. Updates preserve the configured disk mount while resetting the OS layer, so place durable data under that mount and test image rollback with compatible state.

Keep the controller separate from untrusted execution

A useful design puts job ownership and powerful credentials in a trusted controller. That controller sends a bounded task to a worker sandbox, then validates the result before taking further action. The separation can be across services; it need not mean buying a large orchestration platform.
For the repository example, the controller records the job ID, approved repository revision, deadline, and allowed output paths. The worker receives the files and a scoped task. It can run tests and produce a patch, but publishing that patch remains a separately authorized action.
Give each worker only the credentials and outbound destinations needed for its task. Agent37 defaults to outbound internet access; configure a network allowlist for restricted jobs. Include api.agent37.com when the worker needs managed models and tools. A sandbox does not make a broad cloud key safe to expose. Network restrictions also need testing: confirm the intended package and model requests work, and that a destination outside the policy fails. Our agent sandboxing guide covers those boundaries in more detail.
Treat returned files and logs as untrusted input. Check file size, path, format, and job identity before displaying or importing them. Keep a controller-side execution record even if the worker deletes its local logs.
Cancellation needs an owner too. A disconnected browser or expired HTTP request does not prove the worker stopped. Record cancellation, interrupt execution through the mechanism your runtime supports, and confirm the job reached a terminal state before releasing its resources.

Connect each workspace to an authorized tenant

When several customers use the same application, isolation starts before the worker launches. The controller should bind the authenticated user, tenant, job, and worker together. Check that relationship whenever someone resumes a session, reads an artifact, or requests cancellation. A caller supplying a valid worker ID does not prove they own it.
This responsibility remains even with managed hosting. AWS documents that applications must manage the relationship between users and session IDs. Apply the same design principle to your own controller: resolve ownership from trusted application records, rather than accepting a tenant or session identifier from the model as authorization.
Keep credentials scoped to the job and avoid putting long-lived administrative keys in reusable images. When a worker only needs to produce a patch, its access should reflect that task. Let a separate service authorize publication. Keep model access, repository access, and deployment access independently revocable.
Plan data retention across the whole stack. Deleting a worker does not also delete its exported artifacts, application database records, or external backups. Give those stores their own retention policy. Before reusing a workspace for another tenant, prove that old files, credentials, and session state are gone, or create a fresh environment.

Make recovery part of the runtime contract

A saved filesystem, a running process, and a completed business action are three different kinds of state. Design recovery for each one.
Workspace files include source code, generated reports, and installed dependencies. Keep required files on persistent storage. Export important outputs before deleting a disposable environment.
Workflow state records the current step and what has already completed. LangGraph's persistence documentation distinguishes thread checkpoints from cross-thread stores. For a self-hosted graph, choose a durable checkpointer instead of keeping production state only in memory. Managed deployment products may supply that storage for you.
External effects include sending a message, updating a ticket, or publishing a deployment. Before retrying an interrupted step, determine whether that action already happened. Use an idempotency key where the external API supports one, and keep a durable action record. A checkpoint alone cannot reverse an already-sent message.
On Agent37, auto-sleep can restore saved memory, but a wake may cold-boot instead. Durable state belongs on disk or in an external store. After a cold start, verify the application is ready before submitting work; infrastructure status and application health are separate checks.
A practical acceptance test is to interrupt a job after it writes an output but before it records completion. Resume it and inspect the result. You want one accepted output, a clear execution history, and no duplicate external action.

Size the worker fleet before increasing concurrency

Size for simultaneous execution, not registered users. In a hypothetical fleet, 20 workers configured with 2 vCPU and 4 GB RAM represent 40 vCPU and 80 GB of configured memory while all run. That is capacity arithmetic, not a throughput guarantee or an account entitlement. Check the provider's current workspace limits before promising that concurrency.
Put excess jobs in a queue. Give each job a deadline, maximum attempts, and an execution owner. A lease or equivalent ownership record helps the controller identify abandoned work after a crash. Before reassigning it, check whether the previous attempt already produced an accepted result.
A warm pool can reduce the wait for an available worker, but idle running capacity can still cost money. Measure queue wait and environment readiness separately from model latency and tool execution. Then decide whether a smaller pool meets your actual response target.
Track job ID, worker ID, template version, model configuration, exit status, peak memory, and retained storage. Keep secrets out of logs. Alert on repeated failures, queue age, and jobs that stay running after cancellation. These signals tell you whether to add capacity, repair an image, or tighten cleanup.
Pair infrastructure metrics with a small set of representative jobs and explicit acceptance criteria. A process exiting successfully does not prove its patch passes tests or its report uses the right data. Before changing an image or model configuration, rerun those jobs and compare accepted outputs, elapsed time, and retries. Keep the previous version available for rollback.

Calculate runtime cost from running hours and retained disk

For infrastructure, start with allocated CPU, memory, running time, and storage retention. Then add model calls, paid tools, external databases, and other services your application uses. Compare the same workload and billing definitions across providers.
Agent37's published pricing lists standard compute at $0.80 per vCPU and $0.70 per GB RAM per 730-hour month. Disk is $0.09 per GB over the same period. Full VM compute is 2.5 times standard compute; disk uses the same rate. Usage is metered by the minute.
For one instance with 2 vCPU, 4 GB RAM, and an explicit 4 GB disk, the estimates are:
Usage and retention
Standard gVisor
Full VM
Run 60 hours, then delete; disk exists for those 60 hours
$0.39
$0.93
Run 60 hours; retain the disk for all 730 hours
$0.72
$1.26
Run and retain the disk for all 730 hours
$4.76
$11.36
The middle row is standard compute of $4.40 ร— 60 รท 730, plus $0.36 for retained disk. Full VM compute substitutes $11.00 for $4.40. These are resource estimates rounded to cents. They exclude models, tools, external databases, external storage, and other services; they are not performance benchmarks.
An awake instance still bills compute while its agent waits on a model or sits idle. Stop or sleep pauses compute; retained disk continues billing. Delete the instance to end its meter. Auto-sleep must be enabled and configured around the workload.
For 20 standard workers each running 60 hours, with all twenty 4 GB disks retained for 730 hours, compute plus instance disk is about $14.43. That uses 1,200 aggregate worker-hours, not 60 hours for the whole fleet. Multiply unrounded rates before rounding the total.
Measure cost per accepted result alongside resource rates. Divide the total spend for a batch, including failed attempts and retries, by the number of outputs that pass your acceptance check. Track infrastructure and model/tool components separately. If the worker is inexpensive but repeatedly produces unusable results, adding more workers may increase waste before it increases useful output.
Also check template defaults. The Ubuntu VM defaults to 12 GB disk when resources are omitted, giving $12.08 at 730 running hours for its default 2 vCPU and 4 GB RAM. The $11.36 row above explicitly selects 4 GB disk; it is not that template's default price.

AI agent infrastructure and runtime FAQ

Is an agent runtime the whole infrastructure stack?

No. A framework can supply the software runtime that executes the agent loop. Hosting, isolated tool execution, durable storage, identity, and monitoring remain additional responsibilities, whether you assemble them yourself or buy a managed service.

Do AI agents need a GPU?

An agent that calls a hosted model API can run its application and compatible tools on CPU infrastructure. Running model inference yourself is a separate hardware decision. Size the worker for the code, browser, or other tools it executes, and budget hosted inference separately from that worker.

Does every agent need a sandbox?

An agent limited to approved API calls may run within an existing application service. Agents executing generated code, dependency installation, or repository scripts need an execution boundary appropriate to that work and its data access.

Can I keep the same worker between agent turns?

Yes, when the provider's lifecycle supports it. Decide what must persist and where. A reused session identifier, a retained disk, and a resumed process do not offer identical guarantees. Verify recovery after a cold start.

How should I start with Agent37?

Choose standard gVisor for compatible workloads or a full VM when you need Docker or kernel access. Create a sandbox, run one representative job, and test its restart and cleanup behavior. Then compare your measured running hours and retained storage with the published rates.
Vishnu

Written by

Vishnu

Founder at Agent37, which runs managed hosting for OpenClaw and Hermes agents for 1,000+ users. Writes about what actually breaks when you leave an AI agent running.