Function: summariseTurns()
function summariseTurns(
historyText: string,
priorSummary: string | null,
options: SummariseTurnsOptions,
): Promise<string>;Defined in: src/batteries/context/compact/summarizer.ts:142
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, 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'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 | See SummariseTurnsOptions. |
Returns
Promise<string>
The new summary text, trimmed. Falls back to priorSummary ?? '' only when SummarizeFn 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 promise propagate UNCAUGHT (see SummarizeFn'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 When options.summarize or options.estimateTokens is not a function.