# `PtcRunner.SubAgent.Compaction.Context`
[🔗](https://github.com/andreasronge/ptc_runner/blob/main/lib/ptc_runner/sub_agent/compaction/context.ex#L1)

Read-only context passed to compaction strategies.

Locks in the shape that future custom-strategy APIs will receive so that
strategies never see the full loop `%State{}`. Phase 1 has only one internal
caller (the loop's `build_llm_messages/3`), but the struct shape is fixed
here intentionally.

Fields:

- `turn` — the turn that is about to start (1-indexed).
- `max_turns` — agent's `max_turns` setting.
- `retry_phase?` — `true` while the loop is in a retry/validation phase.
- `memory` — the agent's accumulated memory (read-only view).
- `token_counter` — 1-arity function from message content to estimated tokens.

# `t`

```elixir
@type t() :: %PtcRunner.SubAgent.Compaction.Context{
  max_turns: pos_integer(),
  memory: map() | nil,
  retry_phase?: boolean(),
  token_counter: (String.t() -&gt; non_neg_integer()),
  turn: pos_integer()
}
```

---

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