Skip to main content
Snapshot hooks capture the exact state of messages and tools at the LLM call boundary, enabling verification that snapshots match actual payloads.

Quick Start

1

Capture at the LLM boundary

2

Register a snapshot callback

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:#fff

SnapshotHookData

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:

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

  1. Debugging - Verify exact state sent to LLM
  2. Auditing - Log all LLM calls with hashes
  3. Testing - Assert snapshot == expected payload
  4. Replay - Reproduce exact LLM calls

Best Practices

Compare snapshot hashes in CI to detect unintended context changes between releases.
Log hashes and token counts when compliance requires proof of what was sent to the model.
Avoid heavy I/O inside snapshot hooks — queue writes asynchronously when possible.
Verify tool output formatting matches what the model receives, not just user messages.

Context Monitor

Write snapshots to disk

Context Observability

Optimisation event history