Blog

An adaptable durable harness for reactive agents

December 3, 2026

Igal Shilman, Giselle van Dongen, Stephan Ewen

Restate Harness is an agent harness built natively on durable execution. It is compact and offers fine-grained durability similar to pi-durable, persisting every call, tool, and guardrail. It runs on Restate's durable execution runtime, with low-millisecond overhead per durable step. Restate's event-driven execution model makes this harness a good fit for always-on agents that react to events and manage many concurrent sessions.

The harness was developed based on lessons learned from how Restate is used in production by companies such as Replit. The harness can be used as a library, or serve as a reference architecture for anyone building their own durable harnesses on journaled durable execution.

Lines 9–20 of 47
const coder = agent({
  model: aiModel({model: openai("gpt-6.1-terra")}),
  instructions: "You are a coding agent. Change the code, run the tests, and deploy when they pass.",
  tools: {
    runTests: asyncTool({
      description: "Run the test suite.",
      input: z.object({}),
      background: true, // the agent keeps working while the tests run
      async execute() {
        return await sandbox.exec("npm test");
      },
    }),

Two parts are particularly interesting about this harness:

First, it remains very easy to customize and adapt. Because durability, concurrency, queuing, and flow control (some of the hardest parts!) come from the durable execution runtime, the harness remains quite simple, relative to its capabilities. That allowed us to quickly add and customize features like in-turn steering, code mode, background tools, background compactions. That also makes it easy to just treat the harness as a template and use similar patterns in your own codebase, rather than forking and maintaining a harness library.

Second, the event-driven durable execution runtime can run the entire stack, from the orchestrator/control plane (session management, sandbox lifecycles, prompt queuing, sub-agent routing), through the agent loop, to the external tools or workflows spawned by the agent. All agents, sub-agents, workflows, session manager, etc. communicate via the durable event-driven runtime and handle queuing, limits, and suspensions together. This shines especially in sophisticated multi-agent setups and reactive always-on agents.

The harness is a TypeScript library, @restatedev/harness, which runs agents inside your Restate services. Next to it, the agent reference architecture is a complete agent application serving as a template which you can run, extend, or take apart to build your own harness.

An agent loop on durable coroutines

Our industry is moving towards fine-grained durability inside agent loops, but durable execution (journaling) has often been perceived as too rigid, high overhead, and expensive to use for every LLM call or tool. That was true for traditional workflow/activity-oriented durable execution systems, like Temporal, but changes with systems like Restate. In production deployments, Restate adds on average 2.5 ms latency per step at more than 10,000 steps/sec (sync replication across three availability zones), making fine-grained durable agent loops feasible.

Restate Harness builds heavily on durable coroutines. They provide structured concurrency inside a durable function, which comes in handy for concurrent tools, background tools, mid-turn steering, etc. Below is a small example of how coroutines can be used. The deep dive on coroutines has more detail.

Lines 8–18 of 39
  // Durable agent loop
  while (true) {
    // 1. Durable LLM call
    const action = yield* restate.run(async () => llm(messages));
    if (action.type === "final") {
      return action.message;
    }
    messages.push({role: "assistant", calls: action.calls});

    // 2. Spawn parallel tool calls (each of them possibly a multi-step sequence)
    for (const call of action.calls) {

A striking observation is how simple the durability code is: In about 500 lines, it handles every model call, guardrail check, tool result, and signal, down to the individual tool calls of a code-mode program. In two other open-source TypeScript agent harnesses, which implement durability themselves, about 13,700 and 6,800 lines go to storing state, recovering after crashes, and waking up work that waits1.

Lines of durability code
Code lines without comments and blank lines. Tests, database adapters and schema migrations are not counted.
Other harnesses
Restate Harness
Restate Harness, magnified: 516 lines of 4,846 in the library
  • Core agent loop
  • Conversation storage
  • Tools and integrations
Lines of durability code per agent harness
HarnessLines
Other harness13659
Other harness6770
Restate Harness516
Restate Harness: Core agent loop93
Restate Harness: Conversation storage143
Restate Harness: Tools and integrations280
Durability code in three agent harnesses, without comments and blank lines. The footnotes describe how each count was made.

This simplicity makes the code so easy to evolve and adapt. We believe this harness can be a blueprint and template that applications can adapt and change to their own specific needs.

The control plane and workflows around the agent

The harness inherits not only the durability of the loop from Restate, but also the event-driven execution model, with queuing, flow control, and the composability of durable functions. These are crucial for everything that happens around the agent: the orchestration and control planes that manage sessions and sandboxes and handle prompt queuing, approvals, sub-agent routing, etc.

Because our runtime supports both that complex orchestration logic, as well as the fast durability required by agent loops, we can build all these different parts using the same building blocks (durable functions, Virtual Objects) and run them on the same durable runtime. That means all calls between orchestrators/agents/sub-agents/workflows are transported through Restate (not needing a separate network path), reliable by default, adhere to flow control, and let the caller suspend when awaiting the callee.

A control plane, an agent, and a workflow on one durable execution runtimeA client sends a prompt to the control plane of tenant acme, which starts agent run 1 in the tenant's scope and returns right away. A concurrency limit of 1 gives the tenant one agent slot, and run 1 takes it and calls the model. While the model call runs, a second prompt asks to investigate order 1234 and starts run 2, which queues because the slot is taken. The model asks to refund order 4711, so run 1 calls the refund workflow and waits for it. Restate suspends run 1, which is only waiting, and hands the slot to run 2, which calls the model and answers. Meanwhile, the workflow checks the order, waits for a person's approval and suspends. When the person approves, the workflow resumes and issues the refund, and its result reaches run 1. Run 1 takes the slot back, replays its journal, calls the model again and answers.ClientRestate ServerAgentRefundWorkflow← run 1← run 2LIMITS acmeconcurrency: 1queueemptystarted by refund_orderslot
The control plane runs one agent per tenant. When run 1 waits for its refund workflow, which waits for a person, Restate suspends both and hands the tenant's agent slot to the next prompt.

In the example above, the agent platform allows each tenant to run one concurrent agent. A prompt for a second agent is queued while the first one is still running. When the first agent waits on a workflow tool, it suspends and releases the concurrency token to the other agent and re-requests it once the workflow completes.

It also gives us great observability for free, because we see journals organized across durable functions.

The Restate UI showing the journal of a ResearchSession turn: state reads, model calls, and calls to Researcher.research. One call is expanded to show the sub-agent's own steps (a model call, two searches, another model call, and its return). Another call shows as cancelled, and a steering signal and a cancel call appear later in the turn. A timeline on the right shows how long each step took.
One turn of a research session in the Restate UI. Each call to the Researcher sub-agent expands into the sub-agent's own journal, next to a cancelled sub-agent call and a steering signal that arrived during the turn.

What can I use this for?

Restate's event-driven execution model makes this harness a good fit for long-running agents that react to events, work in turns, and manage many concurrent sessions.

The example below is an always-on multi-agent app built this way. Each persona (for example a chief of staff or an issue triager) is a Virtual Object that holds its own memory and runs one turn at a time, with new work queued in Restate. Turns start from a schedule, a Slack or GitHub webhook, or a user message. Personas call each other with durable RPC and wait for the reply, or hand work off and continue. The app runs fully on top of Restate and Restate Harness.

Restate Harness also fits cloud-based coding agents, software factories, deep research agents, chat bots with many concurrent conversations, and company-wide agent platforms that connect agents, MCP servers, model gateways, and internal APIs through durable RPC, with concurrency limits per team or tenant.

What else is in the harness?

The harness has the features you'd expect from today's coding-agent harnesses, each relying on Restate for durability and persistence:

  • Parallel and background tools: functions, MCP servers, and Restate handlers or workflows. Restate adds only milliseconds per step, so you can journal every model call, guardrail check, step inside a tool, and parallel branch separately, and recover them after failures.
  • Code mode: every tool call inside the model's program gets journaled and recovered after a crash.
  • Context management: compaction, previews of large tool results, tool search, and skills. Restate's Virtual Objects let you isolate context per session, and queue messages per session.
  • Steering, interrupts, and approvals: durable signals can either steer or interrupt a running turn. While waiting on an approval, the agent can suspend. Restate resumes it when the approval comes in.
  • Sub-agents, forks, and handoffs: either running inside the turn and sharing its journal or as separate services via durable RPC. Interrupts propagate from the parent to all nested agents.

Check the README for the full list of features.

How good is this?

We ran Restate Harness on Terminal-Bench 2.1 to compare it with the harnesses on the Harness Leaderboard, which runs them all on the same open model. Restate Harness is on par with the leading coding-agent harnesses on pass rate, and close to Pi on cost and time per trial in the same setup: it passed 75.5% of the tasks at $0.030 and 4.3 minutes per trial, against 75.1%, $0.026, and 4.4 minutes for Pi.

We kept our setup as close as we could to the leaderboard's: we used its own code, its sandboxes on Hugging Face, its route to DeepSeek-V4.1-Flash, and its scoring. Restate Harness ran inside each task's sandbox, like the other harnesses, and journaled every step to Restate Cloud. To check our setup, we also ran Pi the way the leaderboard runs it. It scored 75.1%, against 73.2% on the leaderboard, a gap well within either run's 95% interval.

Pass rate and cost per trial
  • Restate Harness (our run)
  • Pi, as the leaderboard runs it (our run)
  • Harness Leaderboard
65%70%75%80%85%$0.020$0.025$0.030$0.035$0.040Pass rateCost per trialRestate HarnessPi (our run)Claude CodeCodexOpenCodeDeepSeek HarnessGrok Build, Kimi CodeAntigravity CLImini-swe-agentfxQwen CodePi (leaderboard)oh-my-piHermes AgentOpenClaw
Show the numbers
HarnessPass rate95% intervalCost per trialMedian minutes
Grok Build78.2%68.4–85.5%$0.03535.7
Kimi Code78.2%68.4–85.5%$0.03564.7
Claude Code76.2%66.3–84.0%$0.03077.4
Codex75.9%65.9–83.6%$0.02493.7
Restate Harness (our run)75.5%65.5–83.3%$0.02974.3
Antigravity CLI75.1%65.1–83.0%$0.03904.5
Pi (our run)75.1%65.1–83.0%$0.02584.4
OpenCode74.7%64.7–82.7%$0.02534.2
fx74.7%64.7–82.7%$0.04116.0
Qwen Code74.3%64.3–82.3%$0.03614.6
DeepSeek Harness74.0%63.8–82.0%$0.03085.7
Pi (leaderboard)73.2%63.0–81.4%$0.02085.9
mini-swe-agent72.4%62.2–80.7%$0.038010.6
oh-my-pi68.2%57.8–77.0%$0.04014.9
Hermes Agent66.3%55.9–75.3%$0.03254.8
OpenClaw65.5%55.1–74.7%$0.03546.0
Terminal-Bench 2.1, 87 tasks with three attempts each, on DeepSeek-V4.1-Flash at reasoning effort high. Restate Harness 0.4.0 and Pi ran in our setup; the other dots are the leaderboard's published results. All costs are at the leaderboard's model prices. Our setup ran faster and used more tokens per trial than the leaderboard's, so compare the time and cost of our two runs mainly with each other.

The FAQ and restatedev/harness-bench have the details, including the results per task.

If you run independent benchmarks of agent harnesses and would like to include Restate Harness, we'd love to hear from you on Discord or Slack.

Using other harnesses

We believe fine-grained durability is becoming the default for agents, and that running the agent and its orchestration on one runtime removes most of the complexity that's left. To make it possible to run any harness on Restate, such as Pi or OpenCode, and to give more flexibility in how you store state, we're also working on session objects: Virtual Objects with their own SQLite-compatible database, backed by Restate's state. More on that soon.

Let us know what you think!

The quickest way to try Restate Harness is with your coding agent. Copy this prompt into Claude Code, Codex, or another coding agent. Your coding agent then downloads the Restate Harness template, installs the Restate skills, starts a local Restate Server, and runs the template's weather agent.

Set up and run the Restate Harness template on a local Restate Server.

The skills teach your coding agent Restate Harness and the Restate SDKs, so from there you can describe the agent you want to build. To add them to an existing project in Claude Code:

/plugin marketplace add restatedev/skills
/plugin install restatedev@restatedev-plugin

To learn what you can do, look at the example lessons, which go from a first agent to approvals, multi-agent workflows, and a support session with live controls.

For a fully managed Restate, use Restate Cloud, which can also run in your own cloud account with BYOC.

Restate Harness is open source on GitHub and available for TypeScript. We'd love to hear your feedback on Discord or Slack.

Restate is open, free, and available at GitHub. Star the project if you like what we're doing and tell your friends about it!

FAQ

How is this different from running agents on a workflow engine?

A workflow engine schedules each step as an activity on a worker, which on Temporal Cloud adds about 50 ms per activity. That overhead is acceptable for a control plane. An agent loop makes a model call or a tool call at every step, though, so teams keep the loop in a harness that checkpoints on its own. A durable step on Restate adds a few milliseconds, so one runtime journals the agent loop step by step and runs the sessions and workflows around it.

Do I need Restate Harness to get these guarantees?

No. The guarantees come from Restate: the journal, Virtual Objects, durable calls, and signals. Restate Harness packages an agent loop on top of them. To build your own harness on Restate instead, with or without parts of Restate Harness, start from the reference architecture.

What happens to side effects in my tools after a crash?

Replay returns the journaled result of every tool call that finished. Only the call that the crash interrupted runs again, so a tool with side effects needs an idempotency key or a durable step around the side effect.

How did you run the benchmark?

We ran Restate Harness 0.4.0 with the leaderboard's code (Space revision 3eca6ef, Harbor 0.24.0), its sandboxes on Hugging Face, its model route to DeepSeek-V4.1-Flash, and its scoring. Restate Harness ran inside each task's sandbox with its default settings and journaled each step to a Restate Cloud environment outside the sandbox. We kept the agent's prompt short and generic on purpose, with nothing specific to Terminal-Bench, and did not tune Restate Harness itself. To check our setup, we also ran Pi as the leaderboard runs it: it scored 75.1%, against 73.2% on the leaderboard. As on the leaderboard, a trial in which the model received the task's answer counts as a failure, and trials that failed on infrastructure were run again.

How should I read the results?

As groups, not as a ranking. With 87 tasks, each pass rate has a 95% interval of about 18 points, and the Restate Harness interval contains every result on the leaderboard. Compare time and cost mainly with our own run of Pi, because our setup ran faster and used more tokens than the leaderboard's. Restate Harness cost about 15% more per trial than Pi: it used 48% more tokens, but the prompt cache served 98.8% of its input tokens. For everything else, see restatedev/harness-bench, which has the code and the result of every trial.

Footnotes

  1. Counted without comments and blank lines; tests, database adapters, and schema migrations are excluded. For Restate Harness, we counted the lines in each file that handle durability: about 515 of its 4,846 lines. For the two other harnesses, we counted the whole files that store state, recover after crashes, or wake up waiting work: 13,659 and 6,770 lines. Which files count is an approximate classification. ↩

Keep reading