Agentic AI
AI agents demand new API design: bring back microservices principles, keep data unified
Scaling APIs for AI agents requires stateless compute and centralized state management—applying 2010s microservices thinking to a problem that didn't exist then.
1/4
The New Stack
AI applications today interact with large language models through structured APIs, most commonly OpenAI-compatible endpoints. But as agents scale, traditional API design breaks down. The traffic patterns agents generate are fundamentally different from web traffic, and that difference requires rethinking how to build resilient systems.
Why agent traffic breaks conventional scaling#
Agent workloads have four defining characteristics that stress traditional architectures:
- Long conversations with stateless requests: A 40-turn agent session becomes 40 independent HTTP calls with no protocol-level binding. Each request must be routed to the right conversation state, even if previous turns landed on different servers.
- Unpredictable tool fan-out: A single chat turn may trigger zero downstream calls or several, each with wildly different latencies. The same input can generate different sequences of tool invocations, making load prediction nearly impossible.
- Aggressive retry loops: Agent harnesses wrap execution in control loops with retry policies. A timeout on one system can trigger a burst of retries, amplifying pressure on already-strained dependencies.
- Bursty, machine-paced load: Without human think time between turns, agents generate continuous bursts of work constrained mainly by hardware limits.
The core problem: when a request from the same conversation lands on a different replica, it can lose prior context. The system still returns HTTP 200, but answers without the right history. The failure is silent.
The naïve approach that fails silently#
A typical first attempt stores conversation history in process memory, protected by a single shared concurrency semaphore:
SESSIONS: dict[str, list] = {}
SLOTS = asyncio.Semaphore(32) # one pool for all requests
@app.post()
():
SLOTS:
history = SESSIONS.setdefault(session_id, [])

