Skip to main content

Module compaction

Module compaction 

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

CodeChange
A code change with metadata
CompactionResult
Compaction result with statistics
CompactionStrategy
Compaction strategy for preserving different types of information
ErrorSolution
An error and its solution
ParsedCompactionSummary
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