Function: selectRelevantTurns()
ts
function selectRelevantTurns<M, TC>(
turns: readonly HistoryTurn<M, TC>[],
queryText: string,
options: SelectRelevantTurnsOptions,
): HistoryTurn<M, TC>[];Defined in: src/batteries/context/thrift/relevance.ts:295
Select which turns to replay by RELEVANCE to the current query: always keep the most recent keepRecent turns, and among the OLDER turns keep any whose relevanceToQuery score against the query's content words clears a floor that scales with how much of the older-history budget is already spoken for (see scaledRelevanceFloor). Walks the ENTIRE history — there is no turn-count cap — so a turn from far in the past survives if it is genuinely relevant, which a recency-only policy (see selectNaiveTurns) can never do.
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, from groupHistoryIntoTurns. |
queryText | string | The current user query (or turn text) to score every older turn against. |
options | SelectRelevantTurnsOptions | See SelectRelevantTurnsOptions. |
Returns
HistoryTurn<M, TC>[]
The surviving turns, in their original chronological order.