Skip to main content

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

Returns

Field descriptions:
  • messages — Array of recent STM messages, up to limit items
  • role — 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 recorded
  • query — 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 fast
  • crystal_recall — When you need semantically relevant memories across all time, not just recent ones
  • crystal_search_messages — When you want to search message content by keyword, not time range

Error handling

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)