Skip to main content

Module two_pass

Module two_pass 

Source
Expand description

Pure builders for prefire two-pass compaction.

Pass1 summarizes ~95% of history (by estimated-token weight) -> NOTE₁. Pass2 rewrites NOTE₁ + the ~5% tail into the successor-visible NOTE₂. Sampling lives in super; this module has no I/O.

Structs§

TwoPassSplit
Result of splitting a conversation for two-pass compaction.

Constants§

TWO_PASS_DEFAULT_SPLIT_FRACTION
Default history fraction covered by pass1; the remainder is the blocking pass2 tail, so keep it small (prod pass2 latency is dominated by tail prefill).

Functions§

build_two_pass_pass1_history
Pass1 sample history: prefix + compaction instruction user turn.
build_two_pass_pass2_history
Pass2 sample history: system (from prefix) + NOTE₁ carrier + tail + special turn.
fingerprint_prefix
Cheap fingerprint of a conversation prefix for prefire NOTE₁ validity. A mismatch means the prefix changed (edit / rewind / branch) since pass-1, so the cached NOTE₁ no longer summarizes the current prefix.
note_for_two_pass_pass2
Prefer a substantive <summary> inner for NOTE₁; otherwise the full pass1 response.
split_conversation_for_two_pass
Split conversation into pass1 prefix / pass2 tail by estimated-token weight.