Skip to main content

Module compaction

Module compaction 

Source

Structs§

CompactionPreparation
Result of prepare_compaction — what to summarise and what to keep.
CompactionResult
Result of compact() — ready to append to the session.
CompactionSettings
Per-session config for compaction behaviour.
FileOps
File operations accumulator, matching pi’s FileOperations / createFileOps.

Enums§

CompactionReason
Why compaction was triggered.

Functions§

compact
Execute compaction: send messages to the provider for summarisation and return the result ready to append to the session.
estimate_context_tokens
Estimate context tokens for a slice of messages. Uses recorded usage from the last non-aborted assistant message as the baseline, then adds estimated tokens for any messages after it.
estimate_tokens
Estimate token count for a single message (chars/4 heuristic, conservative).
get_model_context_window
Look up the context window for a model name.
prepare_compaction
Analyse the session branch and determine what should be compacted.
should_compact
Determine whether compaction should trigger.
summarize_text
Call yoagent’s provider for a simple text completion (no tools, no streaming).