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
Add documentation for chat processing modes and typing indicators
Documents new features from cloudflare/agents#685:
- Chat processing modes (sequential and batch) for AIChatAgent
- Typing indicator support via onInputChange and inputProps
- Configuration options: chatProcessingMode, chatIdleTimeout, chatTypingTimeout
- Updated useAgentChat API reference with new return values
- Added comprehensive examples for both processing modes
Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
// Chat processing mode - how to handle multiple incoming messages
814
+
// - "sequential": Process each message one-by-one (default)
815
+
// - "batch": Combine multiple rapid messages into one response
816
+
chatProcessingMode:"sequential"|"batch";
817
+
818
+
// Idle timeout in milliseconds (batch mode only)
819
+
// How long to wait after a message is sent before processing
820
+
// Default: 5000ms (5 seconds)
821
+
chatIdleTimeout:number;
822
+
823
+
// Typing timeout in milliseconds (batch mode only)
824
+
// How long to wait after user stops typing before processing
825
+
// Default: 1500ms (1.5 seconds)
826
+
chatTypingTimeout:number;
812
827
}
813
828
```
814
829
@@ -865,6 +880,106 @@ class CustomerSupportAgent extends AIChatAgent<Env> {
865
880
866
881
</TypeScriptExample>
867
882
883
+
#### Chat processing modes
884
+
885
+
The `AIChatAgent` supports two modes for handling multiple incoming chat messages:
886
+
887
+
-**Sequential mode** (default): Processes each message one-by-one, with each message getting its own response. Messages are queued and processed in order, waiting for each response to complete before starting the next.
888
+
889
+
-**Batch mode**: Combines multiple rapid messages into a single response. Uses debounce timing and optional typing indicators to intelligently batch messages, providing a better conversational experience when users send multiple short messages in quick succession.
chatIdleTimeout =3000; // 3 seconds - wait for user to start typing
922
+
chatTypingTimeout =1500; // 1.5 seconds - wait after typing stops
923
+
924
+
async onChatMessage(onFinish) {
925
+
// Messages sent within the batching window are combined
926
+
// Only the latest message (with full conversation) is processed
927
+
}
928
+
}
929
+
```
930
+
931
+
</TypeScriptExample>
932
+
933
+
**Batch mode with typing indicators:**
934
+
935
+
For the best user experience in batch mode, use typing indicators to intelligently delay processing until the user finishes typing. This requires client-side integration:
0 commit comments