DeepThinking AI

How do cloud agents run in production?

AI Architect

Key takeaways

  • A cloud agent belongs in a worker runtime first, because queues and leases make each step observable and retryable.
  • Manual deployment should promote a single replica with scoped credentials before any autoscaling rule is enabled.
  • Tool access is the dangerous surface, so outbound network, files, credentials and write APIs need separate allowlists.
  • The production unit is the whole loop: planner, model client, tool adapters, state store, trace pipeline and kill switch.

Cloud agents are easy to demo because the first version looks like a script: read a goal, call a model, invoke a tool, repeat. Production changes the unit of work. The thing you deploy is an operating loop with credentials, state, budgets, logs and a person who can stop it.

Manual deployment still matters. Before CI, autoscaling and multi-agent routing, you need one release path that a human can inspect end to end. That path should make the agent boring enough to restart and constrained enough to trust.

What makes a cloud agent different from a chatbot?

A chatbot waits for a user turn and replies. A cloud agent keeps working after the first prompt. It decomposes a goal, calls a model, chooses tools, records state, evaluates the result and decides whether to continue. That loop means the agent owns time, credentials and side effects in a way a chat box usually does not.

The boundary is clearest around tools. A hosted chat application may call a search API and display the answer. A cloud agent may create tickets, deploy configuration, update records or send messages while the user is away. Tool routing through protocols such as MCP helps standardise discovery, but the cloud runtime still decides identity, network access, retries and cancellation.

So the production question is operational: what can this loop reach, how do you replay a failed step, and who can stop it before the next tool call runs?

Which runtime shape should you deploy first?

Start with a worker, a queue and external state. The worker reads one task, claims a lease, runs the agent loop for a bounded number of steps, writes a trace and either completes, retries or asks for review. That shape maps cleanly to containers on ECS, a Kubernetes Job, a Cloud Run worker, or a scheduled Workers workflow. The brand matters less than the contract.

A request-response service is tempting because it feels simple. It becomes fragile when a model call stalls, a tool needs approval, or a retry arrives after the client has disconnected. Queues make time explicit. A lease says who is allowed to work, a dead-letter queue preserves failures, and an idempotency key keeps a second attempt from repeating a write.

Keep the first release deliberately small: one worker image, one queue, one state store, one trace sink and one control command that cancels a run.

How do you deploy one manually?

Manual deployment means you can describe each change before automation hides it. Build the agent as a container image or serverless bundle, pin the version, then create the runtime resources by hand: queue, database, object store, secret set, service account and logs. Put every identifier in a short release note, including the image digest or bundle hash.

Deploy with one replica. On ECS that may be an update-service call with desired count one. On a smaller host it may be Docker Compose pulling the pinned image and restarting the worker. On Cloudflare Workers it may be a wrangler deploy after secrets have been set in the platform. The platform differs, but the order should stay constant: package, provision state, set secrets, dry-run, promote, watch, record rollback.

Do the first dry run with write tools disabled or held for approval. The trace is the release artifact that matters.

What controls keep the agent bounded?

Bound the agent in four places. First, limit identity. The service account should have separate read and write permissions, with write access granted only to the APIs this release needs. Second, limit the network. Tool adapters should reach named hosts rather than the whole internet where the platform allows it. Third, limit spend and duration. A maximum number of model calls, tokens, retries and minutes per task turns a bad loop into a stopped run.

Fourth, classify every tool by consequence. Read tools can usually run inside the loop. Write tools need approval, idempotency keys and audit logs, especially on public endpoints. The failure mode resembles the gap between read controls and write controls in agent traffic policy: a rule that governs fetching says little about an action that changes state.

The kill switch should live outside the agent process. A stuck planner should never be responsible for cancelling itself.

When should you move past manual deployment?

Move past manual deployment after the boring path has produced boring evidence. You should be able to answer four questions from logs alone: which version ran, which model and tool calls it made, which credentials it used, and why it stopped. If any answer requires memory from the release engineer, automate later.

The next step is CI that builds the image, runs unit and dry-run checks, pushes the digest, applies infrastructure changes and opens a human approval gate before promotion. Autoscaling comes after that. More workers are useful only when each work item is replayable and each write is idempotent.

A mature cloud agent platform eventually adds policy engines, sandboxed tool execution, per-customer isolation and evaluation suites. Those are valuable once the single-agent loop is stable. Until then, manual deployment is a design tool: it exposes every assumption the future pipeline must preserve.

Do this

Deploy a cloud agent manually

Start with the boring path. A manual release should prove the loop, the credentials and the rollback story before it proves scale.

  1. Package the agent as one worker image or one serverless bundle

    Include the planner, model client, tool adapters and health endpoint. Pin dependency versions, record the image digest or bundle hash, and keep the runtime entry point small enough that a reviewer can see what starts.

  2. Create the runtime state outside the process

    Provision a queue for work, a database or object store for run state, and a trace sink for every model call and tool result. The process should be disposable because a cloud scheduler will eventually replace it.

  3. Scope identity before secrets are copied

    Give the agent one service account with the smallest read and write permissions it needs. Store model keys, API tokens and database credentials in the platform secret store rather than in the image or repository.

  4. Run a dry task with writes disabled

    Send one representative goal through the deployed runtime with write tools in approval mode. Check the prompt, model response, tool arguments, tool output and final decision in the trace before enabling side effects.

  5. Promote one replica and watch the first real run

    Start with desired count one or one scheduled worker. Keep autoscaling disabled, set a spend cap, and keep a human ready to cancel the run if the trace shows tool drift or repeated retries.

  6. Record rollback and replay commands

    Write the exact command that returns to the previous image or bundle. Also record how to replay a failed item from the queue, because rollback fixes the runtime while replay proves the work item is safe.

Frequently asked questions

Can I deploy a cloud agent as a serverless function?
Yes, when each step fits the platform timeout and state is stored outside the function. Long planning runs are usually better as workers because a queue lease and heartbeat make retries clearer.
Should the model call run inside the same container as the tools?
Often yes for a first release, because the trace is easier to follow. Split them once tool execution needs a tighter sandbox or a different scaling rule from the planner.
What is the smallest safe manual deployment?
One worker replica, one queue, one service account, one secret set, one state database and one trace sink. Add a dry-run mode that blocks writes, then promote only after a human reviews the first complete trace.
How do I know the agent is ready for autoscaling?
Scale only after you can replay failed steps, cap spend per task, cancel a run from the control plane and prove idempotency for every write tool. Without those controls, more replicas multiply mistakes.

Sources

  1. OpenAI Agents SDK documentationOpenAI
  2. Amazon ECS update-service command and deployment behaviourAmazon Web Services
  3. Docker Compose documentationDocker
  4. Cloudflare Workers secrets documentationCloudflare

Revision history

  • : First publication.
  • : First published.

agentsclouddeploymentoperations