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

Patch Changes

  • #967 c128447 Thanks @threepointone! - Follow-up to #956. Allow addToolOutput to work with tools in approval-requested and approval-responded states, not just input-available. Also adds support for state: "output-error" and errorText fields, enabling custom denial messages when rejecting tool approvals (addresses remaining items from #955).

    Additionally, tool approval rejections (approved: false) now auto-continue the conversation when autoContinue is set, so the LLM sees the denial and can respond naturally (e.g. suggest alternatives).

    This enables the Vercel AI SDK recommended pattern for client-side tool denial:

    addToolOutput({
      toolCallId: invocation.toolCallId,
      state: "output-error",
      errorText: "User declined: insufficient permissions",
    });
  • #958 f70a8b9 Thanks @whoiskatrin! - Fix duplicate assistant message persistence when clients resend full history with local assistant IDs that differ from server IDs.

    AIChatAgent.persistMessages() now reconciles non-tool assistant messages against existing server history by content and order, reusing the server ID instead of inserting duplicate rows.

  • #977 5426b6f Thanks @dmmulroy! - Expose requestId in OnChatMessageOptions so handlers can send properly-tagged error responses for pre-stream failures.

    Also fix saveMessages() to pass the full options object (requestId, abortSignal, clientTools, body) to onChatMessage and use a consistent request ID for _reply.

  • #973 969fbff Thanks @threepointone! - Update dependencies

  • #983 2785f10 Thanks @threepointone! - Fix abort/cancel support for streaming responses. The framework now properly cancels the reader loop when the abort signal fires and sends a done signal to the client. Added a warning log when cancellation arrives but the stream has not closed (indicating the user forgot to pass abortSignal to their LLM call). Also fixed vitest project configs to scope test file discovery and prevent e2e/react tests from being picked up by the wrong runner.

  • #979 23c90ea Thanks @mattzcarey! - Fix jsonSchema not initialized error when calling getAITools() in onChatMessage

  • #980 00c576d Thanks @threepointone! - Fix _sanitizeMessageForPersistence stripping Anthropic redacted_thinking blocks. The sanitizer now strips OpenAI ephemeral metadata first, then filters out only reasoning parts that are truly empty (no text and no remaining providerMetadata). This preserves Anthropic's redacted_thinking blocks (stored as empty-text reasoning parts with providerMetadata.anthropic.redactedData) while still removing OpenAI placeholders. Fixes #978.

  • #953 bd22d60 Thanks @mattzcarey! - Moved /get-messages endpoint handling from a prototype override onRequest() method to a constructor wrapper. This ensures the endpoint always works, even when users override onRequest without calling super.onRequest().

  • #956 ab401a0 Thanks @whoiskatrin! - Fix denied tool approvals (CF_AGENT_TOOL_APPROVAL with approved: false) to transition tool parts to output-denied instead of approval-responded.

    This ensures convertToModelMessages emits a tool_result for denied approvals, which is required by providers like Anthropic.

    Also adds regression tests for denied approval behavior, including rejection from approval-requested state.

  • #982 5a851be Thanks @threepointone! - Undeprecate client tool APIs (createToolsFromClientSchemas, clientTools, AITool, extractClientToolSchemas, and the tools option on useAgentChat) for SDK/platform use cases where tools are defined dynamically at runtime. Fix spurious detectToolsRequiringConfirmation deprecation warning when using the tools option.

Don't miss a new agents release

NewReleases is sending notifications on new releases.