Function: selectNaiveTurns()
function selectNaiveTurns<M, TC>(
turns: readonly HistoryTurn<M, TC>[],
historyBudget: number,
options: SelectNaiveTurnsOptions,
): HistoryTurn<M, TC>[];Defined in: src/batteries/context/thrift/relevance.ts:354
The recency (FIFO) baseline: keep the newest turns, oldest-first-dropped, until historyBudget is exhausted — walking backward from the newest turn and stopping (WITHOUT including) the first turn that would push the running total over budget. The single newest turn is always kept even if it alone exceeds historyBudget.
Type Parameters
| Type Parameter | Default type |
|---|---|
M extends RelevanceMessage | RelevanceMessage |
TC extends RelevanceToolCall | RelevanceToolCall |
Parameters
| Parameter | Type | Description |
|---|---|---|
turns | readonly HistoryTurn<M, TC>[] | The full grouped history, chronological. |
historyBudget | number | The token budget to fit turns into, newest-first. |
options | SelectNaiveTurnsOptions | See SelectNaiveTurnsOptions. |
Returns
HistoryTurn<M, TC>[]
The surviving turns, in their original chronological order.
Remarks
This function exists as an honest COMPARISON BASELINE, not a recommended default — it is the "before" arm the flagship reference agent's evaluation measured selectRelevantTurns against. The evaluation's own honest finding: naive recency is not merely worse in the general case, it can COLLAPSE entirely on a reasoning-heavy model under enough context pressure — one matrix cell observed the naive baseline degrade to keeping essentially nothing useful (effectively floor 0.08 / 3 turns of real signal) once the window filled, while relevance selection kept answering correctly at the same pressure. Use selectRelevantTurns unless you specifically need a recency-only policy or are reproducing that comparison yourself.