-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Description
When saving a custom tool call using the saveMessage function AS PART OF A SUBWORKFLOW triggered by an llm, the message is successfully saved in the database and streamed to the client.
However, the useUIMessages hook overwrites previous tool calls from the current message until the message has finished streaming.
Steps to Reproduce
Consider the following sequence from an LLM message:
- LLM triggers Tool Call A (started)
- Tool A internally triggers custom functions B and C, which each call
saveMessage - Finally, Tool Call A (success) is completed
Expected Behavior
The final UI message content should accumulate all tool calls progressively, like so:
{
content: [ A(started), B, C, A(result) ]
}Actual Behavior
Instead, useUIMessages overwrites prior message states on each saveMessage update.
As a result, the UI briefly displays intermediate states like:
[A] → [B] → [C] → { content: [A(started), B, C, A(result)] }
This causes previously saved tool calls to disappear from the UI until the message fully completes.
Notes
- The issue occurs only during message streaming.
- Once the message is complete, the final combined message is correct.
- Likely related to how
useUIMessagesmerges or replaces partial message updates.
Metadata
Metadata
Assignees
Labels
No labels