Skip to content
1 min read · 253 words

Function: selectNaiveTurns()

ts
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 ParameterDefault type
M extends RelevanceMessageRelevanceMessage
TC extends RelevanceToolCallRelevanceToolCall

Parameters

ParameterTypeDescription
turnsreadonly HistoryTurn<M, TC>[]The full grouped history, chronological.
historyBudgetnumberThe token budget to fit turns into, newest-first.
optionsSelectNaiveTurnsOptionsSee 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.