ctx.run() within the agent handler), see Durable Agents.
Why expose workflows as tools?
As your agent tools grow more complex, you can extract them into separate Restate services and expose them as tools:- Scale independently: Tools can run on different infrastructure, scale separately from the agent
- Any language: Write tools in a different language than the agent (e.g., Python tool called from TypeScript agent)
- Long-running and async: Remote workflows can be started asynchronously without blocking the agent execution and can take minutes or hours (human approval, external processing)
Example: human approval workflow as a tool
This example shows a human approval workflow exposed as an agent tool. The workflow creates an awakeable, sends a review request, and suspends until a human responds. The agent treats this like any other tool call.1. Define the sub-workflow
Extract the tool logic into a separate Restate service: The sub-workflow usesctx.awakeable() to create a durable promise that can be resolved externally via HTTP. The agent suspends while waiting, freeing compute resources.
2. Call it from the agent
The agent exposes the sub-workflow as a tool. When the LLM picks it, the agent calls the remote service via Restate’s service client: