Expand description
Compaction: summarize older context when the window fills, keeping a recent tail. Also branch summarization support for /tree navigation.
Structs§
- Compaction
Plan - Cut-point decision for a compaction pass.
- Summary
Outcome
Constants§
Functions§
- estimate_
context_ tokens - Estimated context size: prefer the last assistant usage (input+output+ cache) and add estimates for everything after it.
- estimate_
message_ tokens - estimate_
tokens_ text - chars/4 heuristic, matching pi’s estimator for messages without usage.
- extract_
file_ ops - Extract read/modified file paths from tool calls in the messages.
- file_
ops_ details - Details payload stored on compaction/branch-summary entries.
- generate_
summary - Generate a structured summary with the LLM. One-off prompt: fresh session id and no cache writes wanted, so it’s a plain request.
- plan_
compaction - Choose the cut point: walk back from the newest message accumulating
estimates until
keep_recent_tokens, then snap to a turn boundary. - serialize_
agent_ messages - Serialize agent messages for summarization (convert then serialize).
- serialize_
conversation - Serialize a conversation to labeled text for the summary prompt. Tool results are capped so summarization stays cheap.
- should_
compact - Whether auto-compaction should trigger.