You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ModelMessage.id is documented as the stable identity used for a persistence and hydration round trip.
modelMessagesToUIMessages() honors that contract and reuses ModelMessage.id, but the reverse uiMessageToModelMessages() conversion does not consistently copy UIMessage.id into the generated model messages.
Bug — UI → model drops IDs:
The one-to-one user-message path returns only role and content in messages.ts#L178-L190.
Assistant segments and derived tool-result messages also omit IDs in messages.ts#L230-L295.
The remaining derived tool-result paths have the same omission in messages.ts#L343-L376.
The asymmetric conversion makes a live UI message lose its identity before its persisted. Hydration must then generate a new ID, which breaks message deduplication, metadata joins, and in-place rendering across reloads.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
const[modelMessage]=uiMessageToModelMessages({id: 'message-1',role: 'user',createdAt: newDate(),parts: [{type: 'text',content: 'Hello'}],})expect(modelMessage.id).toBe('message-1')// currently undefined
The same loss occurs when an assistant UI message is converted into assistant segments and tool-result ModelMessage objects.
Terms & Code of Conduct
I agree to follow this project's Code of Conduct
I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Activity