Skip to content

Convert CoreMessage to UIMessage where it makes sense #27

@ianmacartney

Description

@ianmacartney

When interacting with AI SDK frontend code, there's a preference for UIMessage. There may also be benefits to passing that into the AI SDK (Mastra mentioned the AI SDK choking on "role: tool" messages).

It's mostly a matter of rearranging messages into a friendlier format, with a few differences:

  • The id field which is assigned by AI SDK (currently populated for response messages but not for the initial user message).
  • The sources field which is in our steps model but not on each message.
  • The annotations field which I'm not sure the origin of (it mentions StreamData so maybe it's an internal signal for marking the start/end/segment of streaming text/objects)

Some references:
vercel/ai#3161 (comment)
https://github.com/mastra-ai/mastra/pull/3230/files

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions