What it does
Retrieves recent messages from the short-term memory (STM) store, optionally filtered by channel, session, or time range. Messages are returned in chronological order with timestamps and role information, making this ideal for context injection before AI responses or for reviewing conversation history.Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| limit | number | No | 20 | Maximum number of messages to return. Range: 1-100. |
| channel | string | No | — | Filter messages by channel identifier. |
| sessionKey | string | No | — | Filter messages by session key. |
| sinceMs | number | No | — | Only return messages with timestamp >= this Unix millisecond value. |
Returns
messages— Array of recent STM messages, up tolimititemsrole— The speaker role (user, assistant, system, or custom)content— Message text (truncated to 200 chars in formatted output, full in JSON)timestamp— Unix milliseconds when message was recordedquery— Echo of the request parameters for verification
Examples
Basic usage
Advanced usage
When to use this vs alternatives
crystal_recent— When you need recent conversation context before responding; lightweight and fastcrystal_recall— When you need semantically relevant memories across all time, not just recent onescrystal_search_messages— When you want to search message content by keyword, not time range
Error handling
| Error | Cause | Resolution |
|---|---|---|
| Invalid limit (non-numeric, ≤0, >100) | Malformed input | Tool auto-clamps to [1, 100]; default is 20 if unparseable |
| Invalid sinceMs (non-numeric) | Malformed timestamp | Tool silently ignores; omit if unsure of Unix ms format |
| API connection error | Convex or HTTP endpoint unavailable | Retry; check CONVEX_URL environment variable |
| Authentication failed | Invalid Convex JWT or API key | Verify auth configuration in Convex client setup |
Notes
- Messages are returned in chronological order (oldest first within the result set)
- Message content is sanitized to strip markup and prevent injection
- The formatted output includes a defense header to prevent accidental instruction injection
- Full message data is always available in the JSON block, including untruncated content
- Channel and sessionKey filters are optional AND-combined (both must match if provided)
- If no messages match the filter, returns empty array (not an error)
