mnesis.models.snapshot¶
snapshot
¶
Per-turn context snapshot models for session.history().
ContextBreakdown
¶
Bases: BaseModel
Token counts by component for a single context window state.
All counts are estimates produced by :class:~mnesis.tokens.estimator.TokenEstimator.
They reflect the context window as assembled immediately after a turn is
persisted — that is, the exact token budget breakdown that would be used
on the next LLM call if one were made immediately after this turn.
Attributes:
| Name | Type | Description |
|---|---|---|
system_prompt |
int
|
Tokens consumed by the system prompt. |
summary |
int
|
Tokens consumed by compaction summaries injected into context. |
messages |
int
|
Tokens consumed by raw (non-summary) message history. |
tool_outputs |
int
|
Subset of |
total |
int
|
Grand total — equals |
TurnSnapshot
¶
Bases: BaseModel
Per-turn record of context window state and compaction activity.
One TurnSnapshot is appended to the internal list after every
:meth:~mnesis.session.MnesisSession.send and every
:meth:~mnesis.session.MnesisSession.record call. Retrieve the full list
with :meth:~mnesis.session.MnesisSession.history.
Typical use-cases:
- Debugging — inspect exact context composition at each turn.
- Research — plot sawtooth token-usage curves, measure compaction level distribution, or analyse information-retention across compaction boundaries.
Attributes:
| Name | Type | Description |
|---|---|---|
turn_index |
int
|
0-based counter incremented on every |
role |
Literal['user', 'assistant']
|
The role of the turn that was just completed. Always
|
context_tokens |
ContextBreakdown
|
Token breakdown of the context window after this turn. |
compaction_triggered |
bool
|
|
compact_result |
CompactionResult | None
|
The :class: |