Quick Start
Architecture
The user registers snapshot hooks; each context change triggers a callback for auditing or custom pipelines. classDef agent fill:#8B0000,color:#fff classDef tool fill:#189AB4,color:#fffSnapshotHookData
Snapshot Callbacks
Register callbacks to be notified at every LLM boundary:Hash Verification
Verify snapshot matches actual payload:Snapshot Timing
Configure when snapshots are taken:| Timing | Description |
|---|---|
pre_optimization | Before any optimization |
post_optimization | After optimization (default) |
both | Capture both states |
Drift Detection
Detect if context drifted between snapshot and LLM call:Integration with Monitor
Snapshots are automatically included in monitor output:CLI Usage
Use Cases
- Debugging - Verify exact state sent to LLM
- Auditing - Log all LLM calls with hashes
- Testing - Assert snapshot == expected payload
- Replay - Reproduce exact LLM calls
Best Practices
Hash payloads for regression tests
Hash payloads for regression tests
Compare snapshot hashes in CI to detect unintended context changes between releases.
Use hooks for audit trails
Use hooks for audit trails
Log hashes and token counts when compliance requires proof of what was sent to the model.
Keep hooks lightweight
Keep hooks lightweight
Avoid heavy I/O inside snapshot hooks — queue writes asynchronously when possible.
Include tool results in snapshots
Include tool results in snapshots
Verify tool output formatting matches what the model receives, not just user messages.
Related
Context Monitor
Write snapshots to disk
Context Observability
Optimisation event history

