---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/context/compact/contracts/interfaces/CompactionCostEvent.md
description: >-
  One summarization call's estimated token cost — reported via [`OnCostFn`](https://adk.nht.io/api/@nhtio/adk/batteries/context/compact/contracts/type-aliases/OnCostFn)
  so a caller can total up the real overhead this battery pays (the cost profile
  a `thrift`-only pipeline never incurs).
---

# Interface: CompactionCostEvent

Defined in: [src/batteries/context/compact/contracts.ts:94](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/context/compact/contracts.ts#L94)

One summarization call's estimated token cost — reported via [OnCostFn](../type-aliases/OnCostFn.md) so a caller can total
up the real overhead this battery pays (the cost profile a `thrift`-only pipeline never incurs).

## Remarks

`inTok`/`outTok` are ESTIMATES, not metered usage: when the injected [SummarizeFn](../type-aliases/SummarizeFn.md)'s transport
doesn't report real token usage back (many don't — a bare `Promise<string>` return carries no usage
envelope), the battery has no other way to know what the call cost. It measures what it CAN measure
— the exact text it sent (`system + text`) and the exact text it got back (the summary) — via the
same injected [EstimateTokensFn](../../../thrift/contracts/type-aliases/EstimateTokensFn.md) the caller already supplies for its own token accounting, so
these numbers are at least self-consistent with whatever budget arithmetic the caller runs
elsewhere. A caller whose `SummarizeFn` DOES have access to real usage counts can ignore this
estimate and total its own numbers from inside the function instead.

## Properties

| Property                              | Type     | Description                                                                                                                                                                                                             | Defined in                                                                                                                                            |
| ------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|  `calls`   | `number` | How many summarization calls this event represents — always `1` per [OnCostFn](../type-aliases/OnCostFn.md) firing (one call, one event); a caller totals `calls` across events to get the run's summarizer call count. | [src/batteries/context/compact/contracts.ts:97](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/context/compact/contracts.ts#L97)   |
|  `inTok`   | `number` | Estimated input token cost: `estimateTokens(system + text, encoding)` for the exact request sent to [SummarizeFn](../type-aliases/SummarizeFn.md) this call (system prompt plus the history/prior-summary text).        | [src/batteries/context/compact/contracts.ts:100](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/context/compact/contracts.ts#L100) |
|  `outTok` | `number` | Estimated output token cost: `estimateTokens(summary, encoding)` for the text [SummarizeFn](../type-aliases/SummarizeFn.md) returned.                                                                                   | [src/batteries/context/compact/contracts.ts:103](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/context/compact/contracts.ts#L103) |
