Expand description
Structured conversation compaction for context overflow handling
When conversation history exceeds context limits, this module provides tools to compact the history while preserving key information like:
- User’s original intent and requirements
- Important decisions made
- Code changes and their rationale
- Error messages and debugging information
Structs§
- Code
Change - A code change with metadata
- Compaction
Result - Compaction result with statistics
- Compaction
Strategy - Compaction strategy for preserving different types of information
- Error
Solution - An error and its solution
- Parsed
Compaction Summary - Parse a structured compaction summary
Functions§
- build_
compaction_ prompt - Build a structured compaction prompt for the LLM
- compact_
messages - Compact messages based on the given strategy
- parse_
compaction_ summary - Parse a structured compaction summary from LLM output
- parse_
compressed_ sections - Parse
### File: …subsections from the Code Changes section. - parse_
preserved_ sections - Parse
### Error: …subsections from the Errors and Solutions section. - parse_
summary_ field - Parse a named text field from the summary (joins non-empty lines, trims).
- parse_
token_ counts - Parse bullet-list items (
-prefix) from section text. - summary_
to_ message - Convert a parsed compaction summary back to a message