Skip to content

Conversation

@iTrooz
Copy link

@iTrooz iTrooz commented Dec 29, 2025

Currently, doing

  async onChatMessage(
    onFinish: StreamTextOnFinishCallback<ToolSet>,
    _options?: { abortSignal?: AbortSignal }
  ) {
    return new Response("Hello !");
  }

from an AIChatAgent creates an error on the frontend, because doing so is only generating a text-delta event, and not the text-start and text-end events that should go in-between, according to https://ai-sdk.dev/docs/ai-sdk-ui/stream-protocol#text-start-part (from my understanding ?)

This PR fixes it by adding these 2 events.

@changeset-bot
Copy link

changeset-bot bot commented Dec 29, 2025

🦋 Changeset detected

Latest commit: 1e8d4f7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@cloudflare/ai-chat Patch
agents Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@iTrooz iTrooz force-pushed the respond_with_raw_string branch from 9fe6f2a to 6e83bfe Compare December 30, 2025 00:04
@iTrooz iTrooz force-pushed the respond_with_raw_string branch from 6e83bfe to 1e8d4f7 Compare December 30, 2025 00:14
@iTrooz iTrooz changed the title fix: allow returning a normal reponse from onChatMessage() fix: allow returning a non-streaming reponse from onChatMessage() Dec 30, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 30, 2025

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/agents@761

commit: 1e8d4f7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant