Agents SDK now lets you run sub-agents in the background!
Hi, I'm Shii-chan!
Cloudflare ChangelogToday I found an update to Cloudflare's Agents SDK, and I think it's great news for anyone building agents. Let me walk you through it!
What was announced?
According to the Cloudflare Changelog, Agents SDK v0.17.0 has shipped with first-class background sub-agent runs for long-running work, along with a new runTurn entry point that unifies how turns get admitted. On top of that, there's a big round of reliability fixes so chat agents keep working through deploys, evictions, and reconnects.
The story so far
Until now, running a sub-agent in the Agents SDK would block the parent turn until that work finished. If you wanted to hand off a long task, there wasn't a clean way to check its progress along the way.
On top of that, turn admission for saving messages, continuing turns, durable submission, and chat streaming each went through separate code paths, with no shared admission logic. That could lead to nested blocking calls and, in some cases, deadlocks. Reconnecting mid-turn could also leave the agent stuck in an inconsistent state.
What changes
With v0.17.0, you can run sub-agents fully detached from the parent turn, so they no longer block it. Thanks to a self-scheduling reconcile backbone, these runs survive deploys and evictions, so a long import or batch job can keep going in the background while chat keeps responding.
Turn admission is now consolidated behind runTurn, so the logic that used to be scattered across routes is shared in one place, closing off the nested-call paths that could cause deadlocks. For developers, that means fewer edge cases to worry about when building agent logic.
Dive Deep
Here's how the background sub-agent pieces fit together:
- The
detachedoption configures the run, for exampledetached: { onFinish: "onImportDone", maxBudgetMs: 3600000 } maxBudgetMssets a time ceiling for the run (default is 24 hours)cancelAgentTool(runId)lets you cancel a running sub-agent mid-flight- On the child side, calling
this.reportProgress()surfaces fraction, phase, and message details throughAgentToolRunState.progress - An optional
onFinishcallback receives a status of"completed","error","aborted", or"interrupted" - Setting
notify: trueautomatically injects a completion message into chat once the background run finishes
runTurn(options) unifies turn admission across three modes:
"wait"for saving messages or continuing the last turn"submit"for durable message submission"stream"for chat streaming
On the reliability side, several fixes landed too:
- Optional
chatStreamStallTimeoutMswatchdog to detect stalled streams - Repair for transcripts with interrupted tool calls after failed server calls, before re-entering inference
- A fix for stuck state when a reconnect races a mid-flight turn
- Clients that connect mid-recovery now see an accurate
isRecoveringstate - Terminal WebSocket failures now surface via
connectionError/onConnectionError
A few smaller improvements round out the release: a shared React core exposed at the agents/chat/react entry point, the AI SDK becoming an optional peer dependency instead of a hard requirement for the base runtime, the Code Mode executor timeout going from 30 seconds to 60 seconds, MCP callbacks now working outside the agent's async context, and voice turns supporting AI SDK fullStream responses. There's also an experimental server actions and channels framework, though its APIs are still subject to change.
Wrap-up
Here's what stands out about this release:
- Sub-agents can now run in the background and survive deploys and evictions
maxBudgetMsandcancelAgentToolguard against runaway work, whilereportProgresskeeps you informedrunTurnunifies turn admission and closes off the nested calls that used to cause deadlocks- Stream-stall detection and reconnect fixes make chat agents noticeably more stable
If you're building agents on Cloudflare Workers, especially ones that need to run long tasks in the background, this is well worth trying out.