A toolkit that provides intelligent context summarization and
management for agents.This toolkit enables agents to compress conversation context through
intelligent summarization, save conversation history to markdown files,
and search through past conversations. It handles all context management
needs in a single toolkit.Key features:
Intelligent context compression with over-compression prevention
Markdown file storage with session management
Simple text-based search through conversation history
Initialize the ContextSummarizerToolkit.Parameters:
agent (ChatAgent): The agent that is using the toolkit. This is required to access the agent’s memory.
working_directory (str, optional): The directory path where notes will be stored. If not provided, a default directory will be used.
timeout (Optional[float]): The timeout for the toolkit.
summary_prompt_template (Optional[str]): Custom prompt template for summarization. If None, a default task-focused template is used. Users can customize this for different use cases.
def search_full_conversation_history(self, keywords: List[str], top_k: int = 4):
Search the conversation history using keyword matching. This is
used when information is missing from the summary and the current
conversation, and can potentially be found in the full conversation
history before it was summarized.Searches through the current session’s history.md file to find the
top messages that contain the most keywords.Parameters:
keywords (List[str]): List of keywords to search for. The keywords must be explicitly related to the information the user is looking for, and not general terms that might be found about any topic. For example, if the user is searching for the price of the flight to “Paris” which was discussed previously, the keywords should be [“Paris”, “price”, “flight”, ”$”, “costs”].
top_k (int): The number of results to return (default 4).