# `PhoenixAI.Store.Memory.Strategies.TokenTruncation`
[🔗](https://github.com/franciscpd/phoenix-ai-store/blob/v0.1.0/lib/phoenix_ai/store/memory/strategies/token_truncation.ex#L1)

A memory strategy that removes oldest messages until the total token count
fits within a budget.

Sums tokens from newest to oldest, keeping the newest messages that fit.

## Options

  * `:max_tokens` - the maximum token budget (required)

## Token counting

Uses `token_count` from the message struct when available. Falls back to
the token counter provided in context (`:token_counter`) or
`PhoenixAI.Store.Memory.TokenCounter.Default`.

## Priority

Returns 200.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
