Readable State Properties
Both useAgent (React) and AgentClient (vanilla JS) now expose a state property that directly reflects the current agent state. Previously, developers had to manually track state changes through the onStateUpdate callback with separate useState hooks. The new state property is reactive in React components—triggering re-renders when state changes from either server updates or client-side setState() calls. This simplifies state management patterns and reduces boilerplate.
Idempotent Scheduling
The schedule() method now supports an idempotent option to deduplicate schedules by (type, callback, payload), preventing duplicate rows from accumulating across Durable Object restarts. Cron schedules are idempotent by default—calling schedule("0 * * * *", "tick") multiple times returns the existing row instead of creating new ones. Pass { idempotent: false } to override this behavior.
Delayed and date-scheduled types support opt-in idempotency with the { idempotent: true } flag, essential for safe scheduling in onStart() hooks that run on every restart. The SDK now emits helpful warnings when duplicate schedules are detected.
Enhanced TypeScript Support
AgentClient now accepts an optional agent type parameter for full type inference on RPC calls and state, matching the experience already available in useAgent. Method names autocomplete, argument types and return types are inferred, and the new stub proxy enables direct RPC-style method calls with full typing. The state type is automatically inferred from the agent type, so onStateUpdate callbacks are also typed.
Breaking Change: Zod 4 Required
The SDK now requires zod ^4.0.0 and no longer supports Zod v3. This affects agents, @cloudflare/ai-chat, and @cloudflare/codemode packages. Upgrade your dependencies accordingly.
Additional Improvements
- Chat message fixes:
@cloudflare/ai-chatnow queues turn serialization work to prevent concurrent streaming conflicts and eliminate duplicate messages when stopping streams or calling tools. - keepAlive API: The
keepAlive()andkeepAliveWhile()methods are no longer experimental and now use lightweight in-memory ref counting instead of schedule rows. - TanStack AI integration: A new entry point
@cloudflare/codemode/tanstack-aiadds support for TanStack AI'schat()function as an alternative to the Vercel AI SDK.