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:Vercel AI
OpenAI Agents
Google ADK
Pydantic AI
LangChain
sub-workflow-agent.ts
ctx.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:Vercel AI
OpenAI Agents
Google ADK
Pydantic AI
LangChain
sub-workflow-agent.ts
Try out workflows as tools
Try out workflows as tools
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 that triggers the human approval sub-workflow:In the UI, you can see the agent calling the sub-workflow and suspending while waiting for approval:
Resolve the approval by executing the curl request printed in the service logs, similar to:

