You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This documentation covers the new automatic resumable streaming feature in AIChatAgent and useAgentChat, which allows AI chat responses to automatically resume when clients reconnect after disconnection.
Key features documented:
- Automatic stream persistence to SQLite
- Client reconnection handling
- Server-side and client-side implementation examples
- Configuration options for disabling resume
Based on PR cloudflare/agents#673
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
The `AIChatAgent` class provides automatic resumable streaming out of the box. When a client disconnects and reconnects during an active stream, the response automatically resumes from where it left off.
11
11
12
+
This is particularly useful for long-running AI responses from reasoning models (such as OpenAI's o3, DeepSeek R1, or Anthropic's Claude) where users might disconnect due to network issues, page refreshes, or other interruptions.
13
+
12
14
## How it works
13
15
14
16
When you use `AIChatAgent` with `useAgentChat`:
@@ -17,37 +19,81 @@ When you use `AIChatAgent` with `useAgentChat`:
17
19
2.**On disconnect**: The stream continues server-side, buffering chunks
18
20
3.**On reconnect**: Client receives all buffered chunks and continues streaming
Refer to the [resumable-stream-chat example](https://github.com/cloudflare/agents/tree/main/examples/resumable-stream-chat) for a complete working example. Start a long response, refresh the page mid-stream, and watch it resume automatically.
173
+
Refer to the [resumable-stream-chat example](https://github.com/cloudflare/agents/tree/main/examples/resumable-stream-chat) for a complete working implementation. Start a long response, refresh the page mid-stream, and watch it resume automatically.
174
+
175
+
## Related resources
176
+
177
+
-[Using AI Models](/agents/api-reference/using-ai-models/)
178
+
-[WebSockets](/agents/api-reference/websockets/)
179
+
-[Store and Sync State](/agents/api-reference/store-and-sync-state/)
0 commit comments