---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/context/compact/summarizer/functions/summariseTurns.md
---

# Function: summariseTurns()

```ts
function summariseTurns(
  historyText: string,
  priorSummary: string | null,
  options: SummariseTurnsOptions,
): Promise<string>;
```

Defined in: [src/batteries/context/compact/summarizer.ts:142](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/context/compact/summarizer.ts#L142)

Run ONE summarization call: fold `priorSummary` (if any) and `historyText` into the request text
exactly as the flagship reference agent's `#summariseTurns` did, dispatch it through the injected
[SummarizeFn](../../contracts/type-aliases/SummarizeFn.md), and report the estimated token cost via `options.onCost`.

## Parameters

| Parameter      | Type                                                              | Description                                                                                                                                                                                                     |
| -------------- | ----------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `historyText`  | `string`                                                          | The older-turn text to summarize (already assembled by the caller, e.g. from [assembleCompactedTurns](assembleCompactedTurns.md)'s older-turns join).                                                           |
| `priorSummary` | `string` | `null`                                                | The prior rolling summary, if one exists, folded into the request text ahead of `historyText` under a `PREVIOUS SUMMARY (extend/merge, do not lose facts)` header — `null` on the first summarization of a run. |
| `options`      | [`SummariseTurnsOptions`](../interfaces/SummariseTurnsOptions.md) | See [SummariseTurnsOptions](../interfaces/SummariseTurnsOptions.md).                                                                                                                                            |

## Returns

`Promise`<`string`>

The new summary text, trimmed. Falls back to `priorSummary ?? ''` only when
[SummarizeFn](../../contracts/type-aliases/SummarizeFn.md) resolves to an empty/whitespace-only string (never on rejection — see above).

## Remarks

**Faithfulness to the original**: this is a line-for-line port of `#summariseTurns`'s request
assembly and prompt shape, with exactly one deliberate behavioral change: the original SWALLOWED a
failed summarizer call and degraded to `priorSummary ?? ''` (never letting a summarizer error
propagate, since it ran inline in a chat turn that had to keep going); this battery instead lets a
rejected [SummarizeFn](../../contracts/type-aliases/SummarizeFn.md) promise propagate UNCAUGHT (see [SummarizeFn](../../contracts/type-aliases/SummarizeFn.md)'s own TSDoc) — a
battery has no chat-turn context to know whether "degrade silently" is the right failure mode for
a given caller, so it surfaces the error and lets the caller decide (their own `SummarizeFn` can
implement the original's degrade-on-failure behavior internally if desired, by catching there
instead). The original's GPU-OOM special-case rethrow is likewise the caller's concern now — it
lived inside the original's own adapter-specific `SummarizeFn` equivalent, not in the algorithm.

## Throws

[@nhtio/adk/batteries/context/exceptions!E\_CONTEXT\_RESOLVER\_MISSING](../../../exceptions/variables/E_CONTEXT_RESOLVER_MISSING.md) When
`options.summarize` or `options.estimateTokens` is not a function.
