vercel / ai

Build AI-powered applications with React, Svelte, Vue, and Solid
https://sdk.vercel.ai/docs
Other
10.18k stars 1.53k forks source link

Tool results no longer being streamed to client in v4 #3797

Closed ian-pascoe closed 19 hours ago

ian-pascoe commented 1 day ago

Description

  1. Set up a streaming AI agent using SolidStart
  2. Have the agent invoke a tool.
  3. Observe as no tool results are streamed in

Code example

My repository is here: https://github.com/spirit-led-software/theaistudybible

See:

  1. apps/www/src/server/api/secure/chat.ts for the api
  2. apps/www/src/hooks/use-chat.ts for the client

AI provider

@ai-sdk/solid 1.0.1

Additional context

No response

lgrammel commented 1 day ago

Hi! I just tried this solid js example and it works for me:

https://github.com/vercel/ai/blob/main/examples/solidstart-openai/src/routes/use-chat-tools/index.tsx

Can you inspect the data that's being transferred to the client in the chrome network tab?

ian-pascoe commented 1 day ago

So after some playing around, the way the SDK stores the messages (in a signal) is not optimal for Solidjs. If you display the messages in the <For/> control flow primitive, the entire list rerenders every time it changes (very anti-solid).

I have been trying to stop this by transferring the messages signal into a store in my code OR use @solidjs-primitives/keyed, but this causes things like the message annotations and message tool invocations not to update at all. The message content does update, however.

lgrammel commented 1 day ago

Feel free to submit a PR that changes this behavior in our solid implementation.

ian-pascoe commented 23 hours ago

@lgrammel please review the PR attached