Restate Harness
A TypeScript agent harness built for durable execution on Restate.
Run an agent inside a service handler, alongside ordinary application code.
Restate records its progress, so a crash, deploy, or long wait does not mean
starting the work over.
- Survive the real world. Model calls, tool results, and approvals are
journaled; completed work is reused when an invocation resumes.
- Stay in control while it runs. Steer or interrupt an agent, check tool
calls with guardrails, and pause for human approval.
- Compose agents like services. Call other handlers through durable RPC,
delegate to sub-agents, or hand a conversation to a specialist.
- Bring the tools you need. Use async functions, Restate services, MCP,
tool search, background work, and code mode (programmatic tool calling).
Start from the template ·
Run the tutorial · Explore the capabilities ·
Browse the numbered examples
The shape of an agent
An agent runs inside your Restate service. Your handler decides when to run it
and what happens before and after. The agent can call a model, use tools, wait
for a person, and continue from the journal when the invocation resumes.
flowchart LR
Caller[Caller] --> Handler[Restate handler]
Handler --> Agent[Agent run]
Agent <--> Model[Model]
Agent <--> Tools[Tools and services]
Agent -. progress .-> Journal[(Restate journal)]
Journal -. replay .-> Agent
Install the harness next to the Restate SDKs it builds on, or use the
project template, then start
with one agent and one handler:
npm install @restatedev/harness @restatedev/restate-sdk @restatedev/restate-sdk-gen @ai-sdk/openai
import * as restate from "@restatedev/restate-sdk-gen";
import {agent} from "@restatedev/harness";
import {openai} from "@ai-sdk/openai";
import {aiModel} from "@restatedev/harness/provider";
const assistant = agent({model: aiModel({model: openai("gpt-5.6-luna")})});
export const hello = restate.service({
name: "Hello",
handlers: {
*ask(question: string) {
const result = yield* assistant.run(question);
// A stopped or interrupted run may still carry a summary in output.
return result.status === "completed" ? result.output : (result.output ?? result.reason);
},
},
});
This is lesson 01 without its input schema, on a fixed OpenAI model. Each request starts with no
conversation history. Add a conversation
when the agent needs to remember earlier requests, or add
tools when it needs to act.
Try it
The numbered tutorial starts with this smallest
agent and builds toward approvals, multi-agent workflows, and a support session
with live controls. Start a Restate server, for example with
pnpm dlx @restatedev/restate-server, then run the example endpoint:
pnpm install --frozen-lockfile
export OPENAI_API_KEY=...
# Each lesson defines its model locally; edit that definition to change providers.
# Lessons that need other keys say so.
pnpm dev
In another terminal:
pnpm dlx @restatedev/restate deployments register http://localhost:9080
curl localhost:8080/Hello/ask --json '{"message":"Say hello in one sentence."}'
TypeScript callers can use Restate's typed client instead, as the
example integration tests do:
import {connect} from "@restatedev/restate-sdk-clients";
import {hello} from "@restatedev/harness-examples/hello";
const answer = await connect({url: "http://localhost:8080"})
.client(hello)
.ask({message: "Say hello in one sentence."});
console.log(answer);
pnpm dev compiles packages/core once at startup. After changing it, restart
pnpm dev and run the register command again so Restate sees changed services.
What you can build