compact_session
Compress a session by hiding a source pair and dropping a fraction of remaining pairs based on importance scoring, retaining key context for use in prompts.
Instructions
Assemble a compacted-markdown view of the source pair's session.
Hides the source pair (so it can be used as ground truth in
reconstruction-QA) and returns the remaining session pairs
ranked by the chosen scoring source, truncated to keep
`(1 - k_drop)` of the session.
Args:
source_pair_idx: index into pairs.jsonl identifying the
pair whose session should be compacted. The pair itself
is hidden from the output.
k_drop: fraction of session pairs to drop (0.0 = keep all,
0.9 = aggressive compaction).
ranker: scoring source. Currently only "importance" is
supported here (query-aware rankers belong in
search_pairs).
rem_decay: if True, multiply scores by the nightly REM-decay
map (requires `weighted-compact rem-pass` to have run).
Returns a dict with `markdown` (the compacted context, ready to
paste into a prompt) and `meta` (budget-transparency: pairs_total,
pairs_kept, input_chars, output_chars, tokens_estimate,
compaction_ratio, signals_top3, ranker label).
On invalid input or missing substrate returns a dict with an
`error` key rather than raising.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source_pair_idx | Yes | ||
| k_drop | No | ||
| ranker | No | importance | |
| rem_decay | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||