Cloudflare Agents
Render a Cloudflare Agent conversation with its existing connection and durable history.
Connect the Cloudflare chat hook
Add the tested Cloudflare packages and their required peers.
Set up the server-side chat Agent using the Cloudflare Agents guide. Ghost reads the existing client hook. Follow view setup for styles and dependencies.
isStreaming includes server-pushed continuations; isRecovering reports a durable turn being restored. Using only the underlying AI SDK status would miss those states. The native stop implementation also aborts tool continuations; retain it when binding the hook. Compose input/actions with runtime.controller and inspect current capabilities.
Server state and tools
Cloudflare owns websocket connection/recovery, durable turns and native message synchronization. Read application Agent state through the native connection and validate it for your UI. Browser tool callbacks and addToolOutput are application execution paths; do not connect arbitrary tool data to privileged execution. Approval acknowledgement remains distinct from a tool result.
Troubleshooting
If the view appears frozen, check whether the connection is recovering. A server turn can still be busy while the client is idle. Keep the hook’s connection and lifecycle state available, and replace the hook when the thread changes.