Skip to main content
Many agent systems need a router that decides which specialist agent should handle a request. Restate makes these routing decisions durable: if the process crashes after the LLM picks an agent but before that agent responds, recovery skips the routing step and resumes the agent call.

How it works

  1. A router agent receives the request
  2. An LLM decides which specialist to delegate to (persisted as a durable step)
  3. The specialist agent processes the request
  4. The router returns the result
Routing decisions, agent calls, and results are all recorded in the journal.

Example: routing to specialist agents

Define specialist agents within the same process. The LLM picks the right one, and Restate ensures the decision sticks.
With the Vercel AI, specialist agents are exposed as tools. The LLM decides which tool to call, and Restate durably persists the routing decision.
multi-agent.ts
Install Restate and launch it:
Get the example:
Export your OpenAI API key and run the agent:
Register the agents with Restate:
Start a request for a claim that needs to be analyzed by multiple agents:
In the UI, in the LLM responses, you can see that the agent called the sub-agents via tools.

Handing off to remote agents

When agents need to scale independently, run on different platforms, or be developed by different teams, you can deploy them as separate Restate services. Restate makes cross-service calls look like local function calls while providing end-to-end durability and failure recovery. See the guide on calling remote agents implementation guide for full examples of remote agent routing.