Skip to main content

Module history

Module history 

Source
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.