---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/context/thrift/relevance/functions/selectRelevantTurns.md
---

# 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](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/context/thrift/relevance.ts#L295)

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](relevanceToQuery.md) 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](scaledRelevanceFloor.md)). 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](selectNaiveTurns.md)) can never do.

## Type Parameters

| Type Parameter                                                           | Default type                                              |
| ------------------------------------------------------------------------ | --------------------------------------------------------- |
| `M` *extends* [`RelevanceMessage`](../interfaces/RelevanceMessage.md)    | [`RelevanceMessage`](../interfaces/RelevanceMessage.md)   |
| `TC` *extends* [`RelevanceToolCall`](../interfaces/RelevanceToolCall.md) | [`RelevanceToolCall`](../interfaces/RelevanceToolCall.md) |

## Parameters

| Parameter   | Type                                                                        | Description                                                                                      |
| ----------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| `turns`     | readonly [`HistoryTurn`](../interfaces/HistoryTurn.md)<`M`, `TC`>\[]       | The full grouped history, chronological, from [groupHistoryIntoTurns](groupHistoryIntoTurns.md). |
| `queryText` | `string`                                                                    | The current user query (or turn text) to score every older turn against.                         |
| `options`   | [`SelectRelevantTurnsOptions`](../interfaces/SelectRelevantTurnsOptions.md) | See [SelectRelevantTurnsOptions](../interfaces/SelectRelevantTurnsOptions.md).                   |

## Returns

[`HistoryTurn`](../interfaces/HistoryTurn.md)<`M`, `TC`>\[]

The surviving turns, in their original chronological order.
