Skip to content

useUIMessages streaming saved tool calls issue #182

@franckdsf

Description

@franckdsf

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:

  1. LLM triggers Tool Call A (started)
  2. Tool A internally triggers custom functions B and C, which each call saveMessage
  3. 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 useUIMessages merges or replaces partial message updates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions