diff --git a/backend/open_webui/tools/builtin.py b/backend/open_webui/tools/builtin.py index 0ce3c75004..06f34dd890 100644 --- a/backend/open_webui/tools/builtin.py +++ b/backend/open_webui/tools/builtin.py @@ -1155,7 +1155,7 @@ async def search_chats( # Find a matching message snippet snippet = '' - messages = chat.chat.get('history', {}).get('messages', {}) + messages = (getattr(chat, 'chat', None) or {}).get('history', {}).get('messages', {}) lower_query = query.lower() for msg_id, msg in messages.items():