Skip to content

Cloudflare lets agent code pause for approval and resume after a crash

@cloudflare/computer 0.7.0 adds durability: a run can replay after a deploy, and pause on ctx.interrupt() without burning its timeout budget.

Source: Cloudflare

Cloudflare shipped version 0.7.0 of @cloudflare/computer, its library for letting agents execute code, adding the durability it was missing: a run can now resume after a deploy or crash, and pause on an external action.

Setting onInterrupt: "replay" on WorkerJavaScriptBackend means an interrupted run replays its prior execution instead of repeating API calls or duplicating output. Inside a custom module, calling ctx.interrupt() halts execution until something external approves it, and that wait does not count against the run’s timeout.

postComment: async ([issue, body], ctx) => {
  const { approved } = await ctx.interrupt({ issue, body })
}

A separate call lists what is waiting and resolves it:

workspace.runtime.pending()
workspace.runtime.respond(call.id, call.callId, { approved: true })

Why it matters: human-in-the-loop agent patterns, such as waiting for someone to approve a GitHub comment before it posts, have mostly meant building your own durability layer on top of a stateless function. This gives agents on Workers that for free, including surviving a deploy mid-run, which previously meant losing the run entirely.

Share

Related reading

More from The Wire

All briefs