Cloudflare Computer agents can now resume after deploys and crashes, and wait for approval!
Hi everyone, Shii-chan here! Today's news is an update for agents on Cloudflare. Being able to pick up where you left off after an interruption sounds really reassuring!
Cloudflare ChangelogWhat was announced?
According to the Cloudflare Changelog, @cloudflare/computer gives your agent a workspace to run code in. From v0.7.0, that code can:
- Resume after a deploy or crash
- Pause on an external action, for example to approve a tool call
The story so far
The announcement does not describe the previous behavior. Since this feature is about resuming interrupted runs and waiting for approval, an interrupted run probably needed its own recovery logic before. That part is my inference.
What changes
Long agent runs are easier to recover after a deploy or crash, and you can put a human approval step before risky operations using a built-in mechanism.
Dive Deep
Resume interrupted runs
Set onInterrupt: "replay" on WorkerJavaScriptBackend, or on a single run. In the announcement's example, a Durable Object class MyAgent holds a Workspace that uses the Durable Object's storage and a WorkerJavaScriptBackend with onInterrupt: "replay".
When recovery is triggered, the JavaScript runs again from the beginning. Completed calls reuse their recorded results, and previously recorded output is not printed again.
One caveat: if a call's result was not recorded before the interruption, recovery may repeat the call, even if its action already succeeded. For operations that cannot safely repeat, see unsafeToRepeat() in the linked docs.
- Recovery starts on the next call to
workspace.runtime - To recover without waiting for traffic, call
workspace.runtime.recover()from a Durable Object alarm
Wait for approvals
Expose application functions through custom modules. A function calls ctx.interrupt() to pause the run until your application supplies a decision.
The announcement's example gates posting a GitHub comment:
- A
postCommentfunction lives in aws:githubmodule - It passes the issue and body to
ctx.interrupt()and reads theapprovedflag - If
approvedis false, it throws an error saying the comment was rejected - Otherwise it calls
github.comment(issue, body)withidempotencyKeyset toctx.callId, which prevents duplicate comments on replay
The agent code just imports postComment from ws:github and calls it. The run pauses at ctx.interrupt().
Respond to approval requests
- Call
workspace.runtime.pending()to get the pending calls - For each one, call
workspace.runtime.respond()with itsid, itscallId, and a response such as{ approved: true } - The run continues once all pending calls are resolved
Time spent waiting does not count toward the run's timeout, and the wait survives deploys. For setup, limitations, and how replay works, see the "Resume runs after a restart" docs.
Wrap-up
@cloudflare/computerv0.7.0 adds resumable runs and approval waitsonInterrupt: "replay"reruns from the start and reuses recorded results for completed calls- Calls without a recorded result may repeat, so use
unsafeToRepeat()where needed ctx.interrupt()pauses for approval, and waiting does not count toward the timeout
This is for anyone who wants agents with human checks and the ability to continue after a crash!