github cloudflare/agents @cloudflare/ai-chat@0.3.0

latest release: @cloudflare/think@0.1.1
12 hours ago

Minor Changes

  • #1192 28925b6 Thanks @whoiskatrin! - Add AIChatAgent.messageConcurrency to control overlapping sendMessage()
    submits with queue, latest, merge, drop, and debounce strategies.
    Enhance saveMessages() to accept a functional form for deriving messages
    from the latest transcript, and return { requestId, status } so callers
    can detect skipped turns.

  • #1228 53f27b1 Thanks @threepointone! - Add onChatResponse hook and client-side server-streaming indicators.

    Server: onChatResponse hook on AIChatAgent

    New protected method that fires after a chat turn completes and the assistant message has been persisted. The turn lock is released before the hook runs, so it is safe to call saveMessages from inside. Responses triggered from onChatResponse are drained sequentially via a built-in drain loop.

    protected async onChatResponse(result: ChatResponseResult) {
      if (result.status === "completed") {
        this.broadcast(JSON.stringify({ streaming: false }));
      }
    }

    New exported type: ChatResponseResult with message, requestId, continuation, status, and error fields.

    Client: isServerStreaming and isStreaming on useAgentChat

    isServerStreaming is true when a server-initiated stream (from saveMessages, auto-continuation, or another tab) is active. Independent of the AI SDK's status which only tracks client-initiated requests.

    isStreaming is a convenience flag: true when either the client-initiated stream (status === "streaming") or a server-initiated stream is active.

    Behavioral fix: stream error propagation

    Non-abort reader errors in _streamSSEReply and _sendPlaintextReply now propagate correctly instead of being silently swallowed. The client receives error: true on the done message, and partial messages are not persisted. Previously, stream errors were silently treated as completions and partial content was persisted.

Patch Changes

  • #1225 599390c Thanks @threepointone! - Fix useAgentChat cache key including query params, which broke stream resume with cross-domain auth. Auth tokens (and other query params) change across page loads, causing cache misses that re-trigger Suspense and interrupt the stream resume handshake. The cache key now uses agent identity only (origin + pathname + agent + name), keeping it stable across token rotations.

Don't miss a new agents release

NewReleases is sending notifications on new releases.