From microservices to agents: orchestrating decisions, not just services
Microservices split up functionality. Agents split up decisions. This page covers what changes in control flow, state and failure, and four patterns that keep the result manageable.
Microservices to agents in 60 seconds
- Core shift: microservices divide functionality, agents divide decisions. The path is picked at run time from context, goals and intermediate results.
- Three differences: control flow is no longer fixed in code, state becomes a growing execution context, and failure is a drop in decision quality rather than a clean error.
- Four patterns: separate planning from deterministic execution, use specialised agents, put evaluation inside the loop, and build a tool layer that becomes a capability platform.
- Theme: from orchestrating services to orchestrating decisions.
- Still true: clear boundaries, observability, reliability engineering and platform thinking.
The problem it solves
Teams that run many services know how to build for scale and fault isolation. They split a system along business lines, give each part an API, and let teams ship on their own schedule. That model assumes that the logic is known in advance. A checkout service always does the same steps in the same order, so you can test it, time it and alert on it.
Many valuable tasks are not like that. A search for a suitable appointment, a recommendation, a support answer or an investigation all depend on what is found on the way. Writing every case as code leads to branching that nobody can maintain. An agent offers another route: let a model decide the next step, and let your services be the things it can call.
That is a real change in how a system is designed. It is more useful to see it as an extra layer than as a rewrite. The services remain. A new part sits above them and decides which to call, in what order, and when to stop.
Dividing decisions instead of functions
In a microservice design you ask: which capability does this team own? In an agentic design you also ask: which decisions does this component make, and with what information? A decision might be which candidates to shortlist, whether a result is good enough, or which tool to try next. Each can be given to a component with its own prompt, tools and limits.
This changes how you draw boundaries. A boundary now says what an agent may decide and what it may touch. The same discipline you use for service ownership applies: small interfaces, clear contracts and no hidden coupling.
Three things that change
Control flow is no longer fixed
In a service flow the sequence lives in code. In an agentic flow the sequence lives in the model's choices. Two requests that look alike may take different routes, with a different number of calls. That makes tracing, testing and cost forecasting harder, because you can no longer read the path off the source.
State becomes a growing context
A stateless service reads a request and returns a response. An agent builds up an execution context as it works. That context holds the history of steps, the current plan, retrieved documents and the output of every tool. It grows with each step, and it is what the model reads before it chooses again.
This needs a home. Some designs keep the context in a shared store so that a run can resume or be inspected. Others use memory scoped to a single execution, so that one customer's details never leak into another run. Either way, the context is state that you must size, secure and expire, much like a session store.
Failure is lower quality, not an error
A failing service returns a status code, and you alert on it. A weak agent still returns a status 200. It simply picks a worse tool, ranks a poorer candidate or stops too soon. Nothing in a standard dashboard turns red. The failure modes page goes through this in detail, and it is the main reason decision-level observability matters.
Four patterns that help
1. Keep planning apart from deterministic execution
Let the model propose a plan, then let ordinary code carry out each step. The plan is data, such as a list of tool calls with arguments. The executor checks each call against a schema and a permission list, runs it, and records the result. This keeps the creative part small and the risky part, which touches real systems, under normal engineering control. It is the idea behind a plan and execute agent.
2. Use specialised agents, and accept the cost
Instead of one agent that does everything, split the work by role: retrieval, ranking, evaluation and orchestration. Each has a short prompt and a few tools, so each is easier to test and improve. The cost is coordination overhead and variable latency, since several model calls now happen in sequence and the number depends on the request. A supervisor with workers is one way to organise this.
3. Put evaluation inside the loop
Do not wait for an offline report to find out that an answer was poor. Add a step in which a checker scores the intermediate or final result, and let the loop act on the score: accept, retry with a change, or fall back. This only works when bounded. Set a latency budget for the whole run, a cap on the number of iterations, and a confidence threshold that says when the result is good enough. Without those, evaluation becomes an engine for endless retries.
4. Build a tool layer that grows into a platform
Agents reach services through tools. A tool abstraction layer wraps each service with a clear description, a typed input and output, access control and logging. At first it is a helper library. As more teams add tools, it becomes a capability platform: a catalogue of things agents can do, with owners, versions and usage data. See tool calling and MCP for how tools are exposed.
What stays the same
The move from orchestrating services to orchestrating decisions does not retire the old rules. Clear boundaries still limit the blast radius. Observability still comes before scale. Reliability work such as timeouts, circuit breakers and rate limiting matters more, because an agent can generate far more calls than a human user. Platform thinking still pays off, since shared tooling stops each team from solving the same problems.
A worked example
Acme Retail runs a store-finder feature. A customer writes: "I need a left-handed guitar, under 400, close to my office." The old design calls inventory, then distance, then price filter, then a sort. It cannot read "left-handed" or "close to my office" well, and it returns nothing when no store has an exact match.
- Planner: reads the request and proposes: look up the office address, search stock for left-handed guitars, filter by price, rank by distance, and check the result.
- Executor: runs each step as ordinary code. It validates that the price filter is a number and that the tool is on the allowed list.
- Retrieval agent: finds three stores with matching stock, but only one is within 10 km.
- Ranking agent: orders the three by distance and price, and flags that one guitar is 20 over budget.
- Evaluator: scores the result as weak, because only one option is fully within the limits. Confidence is 0.55, below the 0.7 threshold.
- Loop decision: one retry is allowed. The planner widens the radius to 20 km, and a new store appears with a matching guitar for 380.
- Output: two good options, with the reason for each and a note that the radius was widened.
Three limits kept this safe: one retry, a 4-second budget for the whole run, and a rule that the evaluator cannot trigger a second widening. If the retry had also scored low, the system would have returned the best option with a plain note, or handed off to a deterministic search.
Building it
import time
MAX_ITERATIONS = 2 # one initial pass plus one retry
LATENCY_BUDGET_S = 4.0 # for the whole run
CONFIDENCE_MIN = 0.7 # below this, try again or fall back
ALLOWED_TOOLS = {"lookup_address", "search_stock", "rank_stores"}
def execute(plan: list[dict]) -> dict:
"""Deterministic executor: plain code checks and runs each step."""
state = {}
for step in plan:
if step["tool"] not in ALLOWED_TOOLS:
raise ValueError("tool not allowed") # never trust the plan blindly
state[step["tool"]] = TOOLS[step["tool"]](**step["args"])
return state
def find_store(request: str) -> dict:
started = time.monotonic()
feedback = None
best = None
for attempt in range(MAX_ITERATIONS):
# Placeholder: the planner model returns a list of tool calls as data.
plan = planner.propose(request=request, feedback=feedback)
result = execute(plan)
# Placeholder: the evaluator returns a score and a short reason.
verdict = evaluator.score(request=request, result=result)
if best is None or verdict["score"] > best["score"]:
best = {"result": result, "score": verdict["score"]}
if verdict["score"] >= CONFIDENCE_MIN:
return best
if time.monotonic() - started > LATENCY_BUDGET_S:
break
feedback = verdict["reason"] # tell the planner what to change
# Out of attempts or time: use a fixed, non-model search as the fallback.
return {"result": fallback_search(request), "score": None}
planner, evaluator, TOOLS and fallback_search are placeholders. Notice that the model only proposes. The executor decides what actually runs, and every loop has a count and a clock.
Design decisions
- Decision boundaries: write down what each agent may decide and which tools it can reach. Treat this like an API contract.
- Plan format: use a typed, validated plan, not free text. It makes the executor simple and the logs readable.
- Context store: choose between a shared store that supports resume and audit, and memory scoped to a single run. Set a size cap and an expiry in both cases.
- Number of agents: start with the fewest roles that make sense. Every extra agent adds a hop, a prompt and a failure point.
- Evaluation budget: set the latency budget, iteration cap and confidence threshold together, and give the platform team ownership of the defaults.
- Tool catalogue: require an owner, a schema, a permission scope and a log format for every tool before an agent can use it.
Measuring it
- Decision quality: on sampled runs, how often the shortlist, ranking or tool choice was right, judged by a person or a trusted grader.
- Evaluator agreement: how well in-loop scores match human judgement. A poor checker makes retries pointless.
- Iterations per run: mean and 95th percentile, plus the share of runs that hit the cap.
- Fallback rate: how often the deterministic path was used, and whether it is rising.
- Latency and cost per run: end-to-end and per agent, so you can see where the time goes.
- Tool usage mix: the share of calls to each tool. A sudden shift often points to a prompt or model change.
When to use it, and when not to
| Situation | Use agents? | Why |
|---|---|---|
| Search, recommendation or investigation where steps depend on findings | Yes | A model can adapt the path, which fixed code cannot do cleanly. |
| A transaction with strict rules and a known sequence | No | Keep it as a normal service flow. Its guarantees are the point. |
| A task that needs several skills, such as finding, ranking and checking | Yes | Specialised agents are easier to improve one at a time. |
| Strict latency under a second | Rarely | Several model calls rarely fit. Use a fixed path, with a model off the critical route. |
| Actions that move money or change records | With care | Let a model plan, but have code validate and execute, with a human checkpoint where needed. |
Trade-offs
| Dimension | Effect | What to do about it |
|---|---|---|
| Adaptability | Handles varied requests without new branches. | Keep a measured set of supported goals and review misses. |
| Latency | Specialised agents add hops, and the count varies. | Set a latency budget and cap iterations. |
| Cost | Each agent and each retry adds model calls. | Budget per run and track the 95th percentile. |
| Testability | Paths differ between runs, so exact-output tests fail. | Test properties and scores on a fixed evaluation set. |
| Operations | New state, new traces and new failure types. | Share tooling through a platform instead of one-off builds. |
Compared with a plain service flow
A service flow gives you a fixed path, exact tests, loud errors and predictable cost. An agent gives you a variable path, score-based tests, quiet failures and variable cost. In return you get reach, because one design covers a wide range of requests. Many teams end up with a hybrid: a deterministic backbone for the steps that must be exact, and an agent for the parts that need judgement. The orchestration hub shows how that mix looks in practice.
What this means for your role
Common mistakes
- Letting the model call services directly with no executor, schema check or allow list.
- Creating many tiny agents, so coordination costs more than the work they do.
- Adding an evaluator with no iteration cap, latency budget or confidence threshold.
- Keeping context in an unbounded store that grows and leaks between runs.
- Relying on status codes and latency to judge health.
- Skipping the deterministic fallback, so a model outage becomes a feature outage.
Further reading
- Agentic AI architecture: an overview: the map of this section.
- Failure modes: how decision-driven systems degrade, and how to catch it.
- Plan and execute agent: the planning and execution split in more depth.
- Distributed tracing: the base for decision-level traces.
Moving from services to agents means designing around decisions. Keep the planning loose and the execution strict, bound every loop, and carry the old habits of clear boundaries and good observability into the new layer.