Agent Deployment: A Complete Guide from Setup to Hardening
This guide breaks down 11 agent runtime deployment paths into four categories based on infrastructure ownership and operational responsibility. It covers the engineering details of each category, a four-question decision framework, a five-layer security hardening checklist, and a staged rollout plan with measurable acceptance criteria.
1. Why Deployment Paths Need to Be Classified First
Many teams pick the wrong direction at the very first step of deploying an agent runtime: they get it running locally, move it straight to a public cloud host with exposed ports, and are then forced to rework isolation and authentication. A safer approach is to classify deployment paths by “infrastructure ownership” and “operational responsibility boundary” before discussing options.
The 11 paths in the source material can be abstracted into four categories. The differences are not about command length but about three things: who bears the hardware and electricity costs, who bears the network exposure, and who provides model inference resources.
| Deployment category | Typical form | Setup time | Monthly variable cost | Main risk |
|---|---|---|---|---|
| Local one-click install | Script install or global package install | Minutes | Close to zero | Excessive local privileges |
| High-performance local machine | Small host + local inference | Hours | Mainly electricity | Missing physical security and backups |
| Cloud host / online virtual environment | Prebuilt image or bare-metal init | Hours | Pay-as-you-go | Public exposure and configuration drift |
| Containers and managed runtimes | Container platform + managed service | Days | Resources and traffic | Image supply chain |
2. Engineering Details of the Four Categories
1. Local One-Click Install: Validate Feasibility, Not Production Workloads
The value of one-click scripts and global package installs is compressing environment preparation to minutes. They suit individual trials, API connectivity checks, and prompt tuning. The risk is that install scripts usually run with high privileges and write to global directories.
Recommended practice:
# Use an isolated user and directory to avoid polluting the global environmentsudo useradd -m agentlabsudo -u agentlab -H bash -lc 'mkdir -p ~/runtime && cd ~/runtime'# After installation, immediately confirm the version and executable sourcecommand -v agent-runtime && agent-runtime --version
Pin the version number during validation. Do not use a floating latest tag, or the same set of prompts will behave differently at different times.
2. High-Performance Local Machine: Trade a One-Time Cost for Long-Term Zero Cloud Fees
Take a small host in the $800–2000 range as an example. Its economics come from shifting inference cost from “per-token billing” to “fixed depreciation.” Once a local inference framework takes over the model, the marginal cost of daily calls approaches zero. Memory capacity determines the model size you can run: a 64GB M4 Pro-class platform can run a quantized 32B-parameter model fairly smoothly, while a 16GB device usually handles only the 7B class.
The key engineering point of localization is the trade-off between VRAM/memory and quantization precision:
Available memory ≈ model parameters × bytes per parameter + KV Cache + runtime overhead# A 32B model at 4-bit quantization needs about 18–22GB; long context significantly increases KV Cache
The required complements: scheduled tasks for configuration and data backups, access control within the LAN, and a lightweight monitoring probe (process liveness, VRAM usage, request latency).
3. Cloud Hosts and Online Virtual Environments: Image-Based Delivery and Minimal Exposure
Entry-level instances are commonly offered at around ¥68/year or ¥99/year by some cloud providers, while overseas platforms typically provide one-click deployment templates and free tiers. Their real value is not low cost but reproducible, image-based delivery.
Recommended minimal-exposure principles:
- Open only necessary ports; allow management ports from fixed source addresses only;
- Handle TLS termination and access logging uniformly at the reverse proxy layer;
- Manage processes with system-level services and configure automatic restart;
- Put secrets in environment variables or a secrets management service, never in the code repository.
[Unit]Description=Agent RuntimeAfter=network-online.target[Service]User=agentlabEnvironmentFile=/etc/agentlab/runtime.envExecStart=/opt/agentlab/bin/agent-runtime --config /etc/agentlab/config.yamlRestart=alwaysRestartSec=3[Install]WantedBy=multi-user.target
4. Containers and Managed Runtimes: Reduce the Deliverable to an Image
Once you have more than three instances, configuration drift becomes the main source of failures. Containerization fixes dependencies into images. Combined with rolling updates, log services, and monitoring/alerting from the container platform, it can significantly reduce troubleshooting time. At this stage, introduce image scanning and signature verification, and avoid base images of unknown origin.
3. Decision Framework
Four questions are enough to locate the right path:
- Can data leave the internal network? If not, choose the local machine option;
- Is 24/7 availability required? If yes, choose a cloud host or managed runtime;
- Is the call volume predictable? If not, prefer pay-as-you-go;
- Is multi-person collaboration involved? If yes, identity authentication and auditing must be in place early.
4. Security Hardening Checklist
Security is not the last step; it proceeds alongside deployment. Implement defense in depth across five layers:
- Identity layer: disable default passwords, switch to keys or single sign-on, and enforce least-privilege accounts;
- Network layer: deny inbound by default, allow only necessary ports, and route the management plane through a bastion host or private network;
- Runtime layer: run containers and processes as non-root users, and mount configuration directories read-only;
- Data layer: encryption at rest, encrypted backups, and regular key rotation;
- Audit layer: centrally collect access logs and tool-call records, and set alert thresholds for abnormal high-frequency calls.
Tool invocation is a risk surface specific to agents. Build a whitelist and sandbox for it:
tools:allow:- read_file- http_getdeny:- shell_execsandbox:network: restrictedread_only_rootfs: truetimeout_seconds: 30
5. Launch and Acceptance
A staged approach is more controllable: local validation → internal network trial → small-traffic canary → full rollout. Each stage needs quantifiable acceptance items, such as time to first token, error rate, cost per task, and recovery time. To further reduce operational burden, you can evaluate the combination of general capabilities such as container platforms, log services, and monitoring/alerting offered by Baidu AI Cloud, so you can focus on business logic rather than infrastructure.
