No history yet

Agentic Microservices

From Services to Agents

In traditional microservice architecture, each service is like a specialized, predictable tool. You call an endpoint with a specific payload, and it executes a predefined function. It's deterministic. An order service creates an order; a payment service processes a payment. You're calling a function.

Agentic microservices introduce a fundamental shift. Instead of calling a function, you delegate a goal. An agent is a self-contained service, but at its core is a reasoning engine, typically a Large Language Model (LLM). This engine allows the agent to plan, make decisions, and use tools to achieve a high-level objective.

Think of it as the difference between a vending machine and a personal assistant. The vending machine follows a rigid process (insert money, press B4, receive soda). The assistant can handle a vague request like, "Get me a refreshing drink, I'm feeling a bit tired."

This changes the interaction model entirely. You don't tell the agent how to do something; you tell it what you want to achieve. The agent autonomously determines the necessary steps, interacts with other systems, and handles exceptions along the way. It transforms a passive function into an active, goal-oriented participant in your system.

Defining Agent Boundaries

Just like with standard microservices, defining clear boundaries is critical. Each agentic service should have a distinct purpose and a well-defined set of capabilities. This concept is similar to the idea of a in Domain-Driven Design, where each part of the system has its own vocabulary and responsibilities.

For an agent, this boundary encapsulates two key components:

  1. Reasoning Engine: The LLM that provides the agent with its planning and decision-making abilities.
  2. Tools: The specific functions, APIs, and data sources the agent can use to interact with its environment and take action.

An agent responsible for user onboarding, for example, would have tools to create a database record, send a welcome email, and maybe check an analytics service. It would not, and should not, have access to tools for processing financial transactions. This encapsulation makes agents modular, replaceable, and prevents context leakage, where one agent's internal logic becomes tangled with another's.

Goal-Oriented API Contracts

The shift from function calls to goal delegation requires a new way of thinking about API contracts. A traditional, rigid contract specifies exact fields and data types. An agentic contract is more flexible, focusing on intent.

Instead of a POST /shipments endpoint that requires packageId, sourceAddress, destinationAddress, and carrier, you might define a goal-oriented endpoint like POST /logistics/tasks. The body of the request would describe the desired outcome:

{
  "goal": "Ensure package p_1a2b3c is delivered to customer c_4d5e6f by Friday.",
  "constraints": {
    "max_cost_usd": 50,
    "priority": "high"
  },
  "context": {
    "reason": "Customer changed address post-purchase."
  }
}

The agent receives this task. It then uses its internal reasoning to formulate a plan. It might first use a tool to look up the customer's new address, then another to check available shipping options that meet the time and cost constraints, and finally a third to book the shipment and notify the customer. The contract defines the 'what', not the 'how'. This approach provides enormous flexibility and resilience, as the agent can adapt its plan if one of its tools fails or an unexpected issue arises.

Modular and Composable

The true power of this architecture emerges when you compose multiple, specialized agents into a larger system. Each agent acts as an independent, intelligent node. They don't need to know about each other's internal workings, only the goals they can accept.

Imagine a complex e-commerce process: a customer wants to return a product. This single request might trigger a workflow orchestrated between several agents:

  • Customer Service Agent: Receives the initial request. It validates the user and the order.
  • Logistics Agent: Is delegated the goal of generating a return label and scheduling a pickup.
  • Inventory Agent: Once the return is received, it's tasked with inspecting the item and updating the stock levels.
  • Finance Agent: Finally, it's given the goal of processing the refund to the customer's original payment method.
Lesson image

In this model, there isn't a rigid, hard-coded orchestration layer telling each service what to do. Instead, agents delegate goals to one another, forming a dynamic, distributed system of intelligent actors. This makes the overall system more robust, adaptable, and easier to modify. If you want to change how refunds are processed, you only need to update the Finance Agent's tools or reasoning; the other agents remain untouched.

Quiz Questions 1/5

What is the core difference between interacting with a traditional microservice versus an agentic microservice?

Quiz Questions 2/5

The concept of a well-defined boundary for an agentic service, which encapsulates its reasoning engine and tools, is most similar to which concept from Domain-Driven Design?