← Back to all tweets

Tweet by @franmoretti_

View original on X

How to stream deep research updates with @aisdk After a few iterations, I've found the best flow: Use a data part that includes the toolCallId and compose it in the frontend. Why not Preliminary Tool Results? It would stream the whole result on every update. Since deep research flows can contain a lot of information, sending everything on each update is inefficient. Network usage would be quadratic with respect to the number of updates. By using data parts, you send only the "new" information as a chunk. The second challenge is how to group these in the frontend. You cannot simply group them by type (e.g. 'data-researchUpdate') because you might have two deep research flows in the same message. Using toolCallId, you can easily get all the chunked updates of a tool call. The toolCallId is available in the execute method. The best part is that I only discovered this when I needed it. Feels like progressive disclosure for APIs, kudos to the AI SDK team.

Image
25
Reply