Skip to main content

Module select

Module select 

Source
Expand description

Message selection for compaction.

Implements turn-based selection: conversation messages are grouped into “turns” (bounded by non-compaction user messages), and the most recent tail_turns turns are preserved. Within the preserved range, a token budget (keep_tokens) is enforced from-back, so the oldest retained messages are dropped if the budget is exceeded.

Ported from OpenCode V1: packages/opencode/src/session/compaction.ts select().

Structs§

SelectionResult
Result of the selection algorithm.

Functions§

select
Selects which messages to compact and which to retain.