Expand description
Conversation history utilities.
Functions for manipulating, searching, and transforming the message history. Used by compaction, export, and the query engine.
Functionsยง
- extract_
text - Extract all text content from messages (for search/export).
- last_
assistant_ index - Find the index of the last assistant message.
- last_
user_ message_ index - Find the index of the last user message (non-meta).
- message_
counts - Count messages by type.
- tool_
use_ count - Count tool use blocks in the conversation.
- tools_
used - Get a list of unique tools used in the conversation.
- truncate_
to_ budget - Truncate messages to fit within a token budget.