Cloudflare Workflows Integration
Agents SDK v0.3.7 now provides first-class support for Cloudflare Workflows, creating a powerful combination where agents handle WebSocket connections and real-time state management while workflows manage durable execution, retries, and human-in-the-loop approval flows.
The new AgentWorkflow class allows you to define typed workflows with direct access to your agent:
- Define workflows that can call agent methods via RPC and merge agent state
- Use the
stepAPI for durable, idempotent operations that won't repeat on retry - Call non-durable methods like
broadcastToClients()for real-time progress reporting
Start workflows directly from your agent using runWorkflow() and handle lifecycle events with callbacks like onWorkflowProgress(), onWorkflowComplete(), and onWorkflowError(). Additional workflow control methods include approveWorkflow(), pauseWorkflow(), and terminateWorkflow() for human-in-the-loop and orchestration patterns.
Synchronous State Management and Task Scheduling
State updates are now synchronous with a new validateStateChange() hook that lets you reject or transform state changes before they're applied. This provides immediate feedback and validation without asynchronous round trips.
The SDK also introduces scheduleEvery() for fixed-interval recurring tasks with built-in overlap prevention, making it simple to schedule operations like data syncs without complex cron configuration.
Callable System Improvements
The callable system now supports:
- Client-side RPC timeout — Specify timeout values on callable method invocations
- Stream error signaling — Use
StreamingResponse.error()for graceful error handling in streaming responses - Method introspection — Discover available callable methods with
getCallableMethods() - Connection close handling — Pending calls are automatically rejected when clients disconnect
Security and Routing Enhancements
Email replies are now secured with HMAC-SHA256 signed headers to prevent unauthorized routing of emails to agent instances. A new basePath option allows custom URL routing by bypassing default URL construction.