search_messages
Find iMessage conversations by searching with keywords or semantic meaning, filtering by sender, date, or chat type for precise results.
Instructions
Search messages using hybrid keyword + semantic search.
Combines FTS5 full-text search with OpenAI embedding-based semantic search, merged using Reciprocal Rank Fusion (RRF) for optimal relevance.
This function is designed to handle partial failures gracefully:
If sync fails, search uses existing index
If semantic search fails, falls back to keyword search
If keyword search fails, returns empty results rather than crashing
Returns error information in response for visibility
Args: query: Search query text sender: Filter by sender phone/email (exact match after normalization) chat_id: Filter by specific conversation ID participants: Filter by chat participants (for group chats) after_date: Only messages after this date (ISO8601 format) before_date: Only messages before this date (ISO8601 format) service: Filter by "iMessage" or "SMS" search_mode: "hybrid" (default), "keyword" (FTS5 only), or "semantic" (vector only) limit: Results per page (default 100) offset: Pagination offset (default 0)
Returns: Dictionary with messages, pagination, and index_status including: - messages: List of matching messages with relevance scores - search_mode: The search mode that was used - fts5_matches: Number of keyword matches found - semantic_matches: Number of semantic matches found - pagination: Pagination metadata (total, limit, offset, has_more, next_offset) - index_status: Current state of the search index - errors: List of error messages encountered (if any) - warning: Warning message if partial results (optional)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| sender | No | ||
| chat_id | No | ||
| participants | No | ||
| after_date | No | ||
| before_date | No | ||
| service | No | ||
| search_mode | No | hybrid | |
| limit | No | ||
| offset | No |