---
title: "Discussion on \"Vercel AI SDK: fixing 'The messages must be a ModelMessage[]' after loading a saved chat\" | Hashnode"
description: "Discussion on \"Vercel AI SDK: fixing 'The messages must be a ModelMessage[]' after loading a saved chat\". The error says you passed a UIMessage[]. With saved chats, the usual cause is null or Date values your database wrote into stored messages. Here's how to find the field, clean old rows, stop writing new ones and validate on load, on AI SDK 5, 6 and 7."
url: "https://hashnode.com/posts/vercel-ai-sdk-messages-must-be-a-modelmessage-saved-chat-history/6af09fd1a74e37bbbc89be6b"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Vercel AI SDK: fixing 'The messages must be a ModelMessage\[\]' after loading a saved chat](https://memorysync.hashnode.dev/vercel-ai-sdk-messages-must-be-a-modelmessage-saved-chat-history?utm_source=hashnode&utm_medium=feed)

The error says you passed a UIMessage\[\]. With saved chats, the usual cause is null or Date values your database wrote into stored messages. Here's how to find the field, clean old rows, stop writing new ones and validate on load, on AI SDK 5, 6 and 7.

3d ago · 16 min read · memorysync.hashnode.dev  
Read the article

-   [#ai](https://hashnode.com/tag/ai)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#nextjs](https://hashnode.com/tag/nextjs)
-   [#vercel](https://hashnode.com/tag/vercel)
-   [#llm](https://hashnode.com/tag/llm)

## Written by

[MemorySync](https://hashnode.com/@memorysync)

@memorysync · San Francisco, USA

  
[View profile](https://hashnode.com/@memorysync)

Building MemorySync (memorysync.io) — persistent memory infrastructure for AI agents, Cursor, and Claude Code.

Building MemorySync (memorysync.io) — persistent memory infrastructure for AI agents, Cursor, and Claude Code.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
