Skip to content

saving messages in onFinish #1390

@idobenamram

Description

@idobenamram

In the chat route you guys save the chat with a pretty complicated section in the onFinish callback:
https://github.com/vercel/ai-chatbot/blob/22de9232982d4f8bc06e54d5fe637fe9e35647ac/app/(chat)/api/chat/route.ts#L221C8-L266C1

could this not be simplified by using responseMessage (which only gives the final message) in the onFinish function? is there a reason/flows where responseMessage is not enough?

the only scenario i could think of was: when waiting for a tool approval (input-available) but then the user sends another message (essentially skipping the request), in this case the assistant message part needs to be updated.

would love to understand your reasoning for this,
thanks for all the great work.

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