Files
blogflare/.agents/plugins/cloudflare/skills/agents-sdk/references/streaming-chat.md
T
2026-09-25 12:11:51 +08:00

2.4 KiB

Streaming Chat with AIChatAgent

Use AIChatAgent for persisted conversations with streaming and tools; use callable streaming RPC for non-chat output. Before adapting an existing app, check its installed agents, @cloudflare/ai-chat, and AI SDK versions against the current docs.

Read the relevant documentation before implementing:

Task Documentation
Build a chat agent Chat agent example — setup, provider, server, and UI
Implement or customize chat Chat agents — message format, tools, custom streams, persistence, concurrency, cancellation, and recovery
Connect a client Client guidance — React, vanilla JS, HTTP, and authentication
Stream non-chat results Callable methods — server and client streaming RPC
Trigger background turns Server-driven messages
Add approvals Human-in-the-loop

Forward the request abort signal to the model call so cancellation stops generation. When customizing streams, verify persistence and completion behavior for the installed version. Treat client reconnection and Durable Object eviction as separate recovery cases.