How to run AI agents as backend services in production
AgentField turns Python, TypeScript or Go agent functions into API endpoints with async execution, retries and discovery. From notebook to production.
To run AI agents as backend services, give each agent a stable HTTP endpoint, a durable queue for long work, and a control plane that routes, traces and scales the calls; AgentField is an open-source (Apache 2.0) control plane that does this by turning plain Python, TypeScript or Go functions into endpoints other services can call. The deciding condition is simple: the moment a second service, a cron job or a backlog needs to call your agent, you are building backend infrastructure, not an agent.
At a glance
| What production needs | How AgentField provides it |
|---|---|
| A callable API | Every reasoner or skill becomes POST /api/v1/execute/<node>.<function> |
| Long-running work | POST /api/v1/execute/async/<target> returns 202 and an execution ID |
| Completion without polling | Optional webhook, HMAC-SHA256 signed, 3 delivery attempts by default |
| Agents calling agents | app.call("node.function") through the control plane |
| Scale | Stateless control plane; each agent deploys and scales on its own |
| Storage | SQLite locally, PostgreSQL in production (AGENTFIELD_POSTGRES_URL) |
| Observability | Workflow DAG, Prometheus /metrics, structured JSON logs |
| Hosted option | None. You run it on your own infrastructure |
Step 1: write the agent as a function
A reasoner is a function where a model makes a judgment; a skill is deterministic code such as a database read. Both register with the control plane and become endpoints. This is the Python example from the AgentField quickstart:
# app.py
from agentfield import Agent, AIConfig
from pydantic import BaseModel
app = Agent(
node_id="my-agent",
agentfield_server="http://localhost:8080",
ai_config=AIConfig(model="anthropic/claude-sonnet-4-20250514"),
)
class Summary(BaseModel):
title: str
key_points: list[str]
@app.reasoner()
async def summarize(text: str) -> dict:
return (await app.ai(system="Summarize concisely.", user=text, schema=Summary)).model_dump()
app.run()The same shape exists in TypeScript (agent.reasoner(...), agent.serve()) and Go (a.RegisterReasoner(...), a.Serve(...)). The model string goes through LiteLLM in Python, so any of 100+ models work, including a local ollama/llama3.
Step 2: run the control plane and the agent
curl -sSf https://agentfield.ai/get | bash # installs the af binary
af server # terminal 1: control plane on :8080, SQLite
python app.py # terminal 2: the agent registers itselfStep 3: call it like any other API
curl http://localhost:8080/api/v1/execute/my-agent.summarize \
-H "Content-Type: application/json" \
-d '{"input": {"text": "AgentField is an open-source control plane for AI agents."}}'The response is structured JSON with execution_id, run_id, status and result, not raw model text. For work that may take minutes or hours, call /api/v1/execute/async/my-agent.summarize instead: it returns {"execution_id": "...", "status": "queued"} at once, and you poll GET /api/v1/executions/{id} or register a webhook. The deferred execution docs say async executions have no timeout ceiling; the control plane's own call to an agent defaults to agent_call_timeout: 1800s.
From a dozen notebooks to services
If your agents live in notebooks today, each one becomes an agent node: move the cell logic into reasoners and skills, give the node a node_id, and run it as its own process or container. Other services stop importing your Python and call <node>.<function> over HTTP instead. The LangGraph migration post walks through this translation for a real graph, and The AI Backend explains why we treat agents as services at all.
Scaling horizontally, like microservices
The deployment docs describe a stateless control plane with independent agent scaling: support can ship a fix while analytics runs a long job, and neither redeploys the other. In production:
export AGENTFIELD_POSTGRES_URL="postgres://user:pass@db.company.com/agentfield"
af serverFor Kubernetes, the docs ship a Deployment with liveness and readiness probes on /api/v1/health, and warn that multi-replica deployments need PostgreSQL because SQLite does not support concurrent writes. Two versions of one agent can run side by side and split traffic by weight, which is how the docs do canary and A/B rollouts.
Honest limits: the README puts routing overhead at roughly 100 to 200 ms per cross-agent hop, so keep hops coarse when latency is tight. Under load the control plane pushes back with 429 or 503 and Retry-After rather than queueing forever.
When something else fits better
- One agent, one caller, already inside a web app. Wrapping it in your existing FastAPI or Express service is less to run. Add a control plane when a second service needs it.
- You already run Temporal. Temporal (MIT licensed) gives durable execution for any code, with eight SDKs, and its Durable AI docs integrate with the OpenAI Agents SDK, LangGraph, Google ADK and Pydantic AI. If your team knows it well, that is a sound choice; AgentField adds agent-specific pieces (discovery, memory scopes, agent identity) you would otherwise build.
- You want managed hosting for LangGraph graphs. LangSmith Agent Server (formerly LangSmith Deployment) runs LangGraph agents in LangChain's cloud on paid plans, or self-hosted on the Enterprise plan. If your agents are already LangGraph graphs and you want a managed service, that is the shorter path. See AgentField vs LangGraph.
- Model serving, not agent orchestration. Ray Serve is a Python library for online inference APIs whose steps autoscale independently, and Modal runs functions and web endpoints serverless, with GPUs chosen in code, on capacity it hosts. Both are excellent at compute; neither is an agent control plane.
For agents that call each other, read orchestrating agents that call each other. For the open-source options in this category, see open-source control planes for AI agents.
Questions people ask
How do I deploy Python AI agents so other services can call them?
Run each agent as an AgentField node and start the control plane with af server. Every function decorated with @app.reasoner() or @app.skill() becomes POST /api/v1/execute/<node>.<function>, callable from any language over HTTP. Use the async endpoint for anything that may run longer than a normal request.
Can AI agents scale horizontally like microservices?
Yes. In AgentField each agent is a separate process that registers with a stateless control plane, so you scale an agent by running more copies of it and scale the control plane by adding replicas behind a load balancer with PostgreSQL storage. Agents deploy on their own schedule without redeploying each other.
Do I need Kubernetes to run AgentField?
No. af server runs locally with SQLite and no extra infrastructure, and the same binary runs in Docker, on Kubernetes, or on Railway, Fly.io, AWS ECS and Google Cloud Run. The docs ship Kubernetes manifests with health probes on /api/v1/health when you need them.
Is there a hosted AgentField service?
No. AgentField is open source under Apache 2.0 and you run the control plane and agents on your own infrastructure. There is no managed cloud offering today.
How long can an agent run?
The deferred execution docs say async executions have no timeout ceiling and run until they complete, fail or are cancelled. The control plane's call to an agent node defaults to 1800 seconds and is configurable as agent_call_timeout.
Sources
- AgentField docs, checked 2026-11-21: quickstart, how it works, deferred execution, webhooks, deployment, A/B deployments, models
- Agent-Field/agentfield README, checked 2026-11-21 (scaling and hop overhead)
- LangSmith deployment docs, Temporal: understanding Temporal, Temporal Durable AI, Ray Serve docs, Modal guide, checked 2026-11-21
Checked 2026-11-21 against the AgentField docs and README on that date.