Agents SDK levels up to v0.7.0 — keepAlive() finally stops your Durable Object from getting evicted!
Hey everyone, it's me! Cloudflare just leveled up the Agents SDK again, and I'm pretty excited about this one.
Cloudflare ChangelogWhat was announced?
Cloudflare's Changelog introduced Agents SDK v0.7.0. There are three big pieces this time: a from-scratch rewrite of observability, a new keepAlive() that stops long-running work from getting your Durable Object evicted, and waitForMcpConnections, which makes sure MCP connections are ready before onChatMessage runs. These sound small, but they fix exactly the kind of "it just disappeared mid-run" or "the tools weren't all there yet" problems developers actually run into.
The story so far
Observability used to rely on console.log() plus a custom Observability.emit(). That meant you were mostly reading raw logs instead of working with structured, filterable events.
Durable Objects also have a built-in behavior: they get evicted after a period of inactivity, roughly 70 to 140 seconds. If that inactivity timer fired in the middle of a long computation or a streaming response, the object could be torn down before the work finished.
And on the MCP side, onChatMessage could sometimes fire before MCP server connections had fully finished establishing, which meant this.mcp.getAITools() wouldn't return the complete set of tools you were expecting.
What changes
Starting with observability: v0.7.0 replaces the old logging with structured events published to diagnostics_channel. It's silent by default and adds zero overhead when nobody is listening. In production, all diagnostic messages are automatically forwarded to Tail Workers, so you don't even need to write subscriber code inside the agent itself. Events are routed to seven named channels:
agents:state— state updatesagents:rpc— RPC calls and errorsagents:message— message processingagents:schedule— schedulingagents:lifecycle— connect and destroyagents:workflow— workflow eventsagents:mcp— MCP connection events
A typed subscribe() helper is now available from agents/observability, giving you type-safe access to these events.
Next, keepAlive(). Calling it sets up a 30-second heartbeat schedule, and each time the alarm fires, it resets the inactivity timer. You get a way to keep signaling "still alive" for as long as your long-running work needs. AIChatAgent already calls this automatically while streaming a response, so you don't need to add it yourself for chat use cases.
Finally, waitForMcpConnections. Configuring this makes the agent wait for MCP server connections to fully establish before onChatMessage runs, so your chat logic starts with the complete tool set already in place.
Dive Deep
Here's what using subscribe() looks like:
const unsub = subscribe("rpc", (event) => {
if (event.type === "rpc") {
console.log(`RPC call: ${event.payload.method}`);
}
});
unsub();
Every event carries a type, payload, and timestamp, which keeps them easy to work with.
keepAlive() comes in two flavors: a manual-dispose version and an auto-cleanup keepAliveWhile().
const dispose = await this.keepAlive();
try {
const result = await longRunningComputation();
} finally {
dispose();
}
waitForMcpConnections accepts three configurations:
{ timeout: 10_000 }— the default; wait up to 10 seconds, then proceedtrue— wait indefinitely until connections finishfalse— don't wait at all before runningonChatMessage
A handful of smaller improvements shipped alongside these:
- Duplicate MCP server registrations are now detected by name and normalized URL
callbackHostis no longer required for MCP servers that don't use OAuth- URL security was tightened to block private IP ranges and other SSRF-risk targets
- Custom rejection messages are supported via
errorTextin theoutput-errorstate - A
requestIdfield was added to chat options for logging purposes
Upgrading is as simple as running npm i agents@latest @cloudflare/ai-chat@latest.
Wrap-up
- Observability was rebuilt around structured
diagnostics_channelevents, with seven channels and a typedsubscribe()helper keepAlive()/keepAliveWhile()stop Durable Objects from being evicted (after roughly 70-140 seconds of inactivity) during long-running workwaitForMcpConnectionsletsonChatMessagewait for MCP connections to finish, so the tool list is never incomplete- Smaller fixes cover MCP deduplication, optional
callbackHost, SSRF protection, custom rejection messages, and request-level logging IDs
If you're building long-running tasks or chat agents on Cloudflare's Agents SDK, this is a quiet but genuinely useful update to grab.