By Sagar Shankaran, Founder of CallSphere
Learn practical criteria for decomposing a monolithic AI agent into microservices, including how to identify service boundaries, choose communication patterns, and execute a safe migration without downtime.
Key takeaways
Most AI agent projects start as a single service. The LLM orchestration, tool execution, memory retrieval, and response formatting all live in one codebase deployed as one container. This works well for prototypes and small-scale production systems.
The problems surface as the system grows. A memory-intensive RAG retrieval step starves the lightweight routing logic of CPU cycles. A slow tool call blocks the entire agent loop. Deploying a fix to the prompt template requires redeploying the tool execution engine. Teams step on each other when three engineers edit the same monolith simultaneously.
These symptoms signal that decomposition into microservices is worth the added complexity.
Not every monolith needs to become microservices. Splitting too early adds operational overhead without proportional benefit. Use these criteria to decide:
flowchart LR
CUR(["On Current Vendor"])
AUDIT["1. Audit current<br/>flows and data"]
EXPORT["2. Export contacts,<br/>scripts, recordings"]
BUILD["3. Build CallSphere<br/>agent and integrations"]
PILOT{"4. Pilot on<br/>10 percent of traffic"}
CUTOVER["5. Forward all<br/>numbers"]
LIVE(["Live on<br/>CallSphere"])
CUR --> AUDIT --> EXPORT --> BUILD --> PILOT
PILOT -->|Pass| CUTOVER --> LIVE
PILOT -->|Issues| BUILD
style CUR fill:#dc2626,stroke:#b91c1c,color:#fff
style PILOT fill:#f59e0b,stroke:#d97706,color:#1f2937
style LIVE fill:#059669,stroke:#047857,color:#fff
Split when the agent has clearly independent scaling requirements. If your RAG retrieval needs 8 GPU-backed pods but your routing logic needs 2 CPU pods, a monolith forces you to over-provision one or under-provision the other.
Split when deployment frequency differs across components. If the prompt engineering team ships daily but the tool integration team ships weekly, coupling their deployment cycles slows everyone down.
Hear it before you finish reading
Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.
Split when fault isolation matters. A crash in the vector database client should not bring down the conversation management layer.
Keep together when the team is small (fewer than four engineers), the agent handles fewer than 100 requests per minute, and operational maturity (logging, tracing, CI/CD) is still developing.
The key principle is to draw boundaries around business capabilities, not technical layers. A common mistake is splitting by technology — one service for "database stuff," another for "LLM stuff." This creates chatty inter-service communication because every request traverses multiple services.
Instead, split by agent capability:
# Service 1: Conversation Manager
# Owns: session state, message history, routing decisions
class ConversationService:
def handle_message(self, session_id: str, user_msg: str) -> dict:
history = self.session_store.get(session_id)
intent = self.router.classify(user_msg, history)
if intent == "tool_call":
result = self.tool_client.execute(intent.tool, intent.params)
return self.format_response(result)
elif intent == "knowledge_query":
context = self.rag_client.retrieve(user_msg)
return self.llm_client.generate(user_msg, context)
return self.llm_client.generate(user_msg, history)
# Service 2: Tool Execution Engine
# Owns: tool registry, execution sandbox, result caching
class ToolExecutionService:
def execute(self, tool_name: str, params: dict) -> dict:
tool = self.registry.get(tool_name)
with self.sandbox.create_context() as ctx:
result = tool.run(params, context=ctx)
self.cache.store(tool_name, params, result)
return result
# Service 3: RAG Retrieval Service
# Owns: vector store, chunking, embedding, reranking
class RAGService:
def retrieve(self, query: str, top_k: int = 5) -> list[dict]:
embedding = self.embedder.encode(query)
candidates = self.vector_store.search(embedding, top_k=top_k * 3)
reranked = self.reranker.rerank(query, candidates)
return reranked[:top_k]
Once boundaries are defined, choose how services talk to each other:
Synchronous (HTTP/gRPC) for request-reply flows where the caller needs an immediate response. The conversation manager calling the RAG service during message handling is inherently synchronous — the user is waiting.
Asynchronous (message queue) for fire-and-forget or long-running operations. Logging analytics events, updating the memory store after a conversation ends, or triggering batch reindexing are all good candidates.
Still reading? Stop comparing — try CallSphere live.
CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.
A Kubernetes deployment manifest for the split services:
apiVersion: apps/v1
kind: Deployment
metadata:
name: conversation-manager
spec:
replicas: 3
selector:
matchLabels:
app: conversation-manager
template:
spec:
containers:
- name: app
image: agent-system/conversation-manager:v2.1
resources:
requests:
cpu: "500m"
memory: "512Mi"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: rag-retrieval
spec:
replicas: 6
selector:
matchLabels:
app: rag-retrieval
template:
spec:
containers:
- name: app
image: agent-system/rag-retrieval:v2.1
resources:
requests:
cpu: "2000m"
memory: "4Gi"
Notice the RAG service has 6 replicas with 4Gi memory, while the conversation manager runs 3 lightweight replicas. This independent scaling is impossible in a monolith.
Never rewrite everything at once. Extract one service at a time, starting with the component that has the clearest boundary and the most to gain from independent scaling. Deploy it alongside the monolith, route a percentage of traffic to it, and verify correctness before extracting the next piece.
If your entire agent codebase is under 5,000 lines, your team has fewer than four engineers, and you handle under 100 requests per minute, the operational overhead of microservices likely outweighs the benefits. Start with a well-structured monolith using clear internal module boundaries. You can extract services later when scaling or team size demands it.
Distributed state management. A monolith can share session state through in-process memory. Once you split into services, session state must be externalized to Redis or a database, and every service that needs it must fetch it over the network. Design your state management strategy before you start extracting services.
For AI agents, an orchestrator (the conversation manager) that coordinates the workflow is usually the right choice. Peer-to-peer communication between services creates a tangled dependency graph that is hard to reason about. The orchestrator pattern keeps the agent's decision flow visible in one place.
#Microservices #AgenticAI #Architecture #Decomposition #Migration #LearnAI #AIEngineering

Written by
Sagar Shankaran· Founder, CallSphere
LinkedInSagar Shankaran is the founder of CallSphere, where he builds production AI voice and chat agents deployed across healthcare, hospitality, real estate, and home services. He writes about agentic AI, LLM engineering, and shipping voice agents that handle real calls in production.
See how AI voice agents work for your industry. Live demo available -- no signup required.
How to design a multi-agent system using MCP for tools and A2A for cross-vendor coordination, with a CallSphere voice agent as a participating node.
The 2026 desktop AI agent landscape — ServiceNow Project Arc, Anthropic Claude offerings, OpenAI agents, and Google Mariner. A buyer's map.
Five proven multi-agent architecture patterns built on A2A — orchestrator, peer mesh, hub-and-spoke, marketplace, and tiered specialist.
Every 100ms of latency costs you. So does every cent per minute. Here is the decision matrix we use across 6 verticals to pick where to spend and where to save on voice AI infrastructure.
When to use Pinecone vs pgvector vs Qdrant vs Weaviate. A decision framework that maps team size and workload to the right pick without endless evaluation loops.
An agentic-AI perspective on Anthropic Skills system, covering orchestration patterns, tool use, and how agent tooling fits production agent stacks.
© 2026 CallSphere Inc. All rights reserved.
Made within San Francisco
Watch how CallSphere handles real customer calls, schedules appointments, and processes payments — live.