Expand description
Custom compaction algorithm interface (issue #4).
compact() no longer hard-codes one strategy: it dispatches through
CompactAlgorithm, which composes the three classic decision points —
when to trigger, where to cut, and how to summarize.
BuiltinCompactAlgorithmis the shipped default: the 80%-window trigger heuristic, the turn-boundary-safekeep_recent_tokenscut, and LLM summarization (with the overflow-budget retry loop).- Custom algorithms implement the same trait. The TS path is host-wired: the CLI
(
theway-daemon::ts_extensions) discoverskind = "compaction"extensions, adapts them toCompactAlgorithm, and injects the registry viaAgentHarnessOptions.compact_algorithms— the core never loads extensions itself.
The trait methods carry defaults that delegate to the same free functions the builtin
uses, so a custom algorithm that overrides only select_cut_point still gets the builtin
trigger + summarizer for free.
Structs§
- Builtin
Compact Algorithm - The shipped default algorithm. All hooks are the trait defaults (builtin behavior).
- Compact
Algorithm Registry - Resolves
CompactionSettings.algorithmnames to implementations. Holds the custom algorithms (host-injected, e.g. TS extensions); the builtin is always available as fallback. - Summarize
Request - Everything an algorithm needs to produce a summary of the folded prefix.
- Summary
Outcome - Result of a summarize hook (
summarize_prefix).usageis meaningful for LLM-backed algorithms; custom (e.g. TS) algorithms returnUsage::default().
Traits§
- Compact
Algorithm - Custom compaction algorithm — the extension point behind issue #4.