Persist & Replay
Install
pip install "briefcase-ai[storage,replay]" Live observability (@capture + observe()) only needs the base package. Persistence and replay import briefcase.storage and briefcase.replay, which are gated behind extras — see Installation.
Persist a snapshot
Build a typed DecisionSnapshot, then save it with a storage backend. SqliteBackend.in_memory() is fine for a notebook; use a file path to keep decisions across runs.
-
Build and save a DecisionSnapshot
from briefcase import (DecisionSnapshot,Input,ModelParameters,Output,init,)from briefcase.storage import SqliteBackendinit() # start the native runtimedecision = DecisionSnapshot("classify_ticket")decision.add_input(Input("ticket_text", "My invoice is wrong", "string"))params = ModelParameters("gpt-4o-mini")params.with_provider("openai")params.with_parameter("temperature", 0.0)decision.with_model_parameters(params)output = Output("category", "billing", "string")output.with_confidence(0.93)decision.add_output(output)decision.with_execution_time(12.0)backend = SqliteBackend.in_memory() # or SqliteBackend("./decisions.db")decision_id = backend.save_decision(decision)print(f"Recorded decision {decision_id}") -
Replay and compare
from briefcase.replay import ReplayEngineengine = ReplayEngine(backend)result = engine.replay(decision_id, "strict")print("status:", result.status)print("outputs match:", result.outputs_match)print("execution time (ms):", result.execution_time_ms) -
Verify the result
ReplayResultexposes.status,.outputs_match,.replay_output,.execution_time_ms, and.policy_violations. Valid replay modes are"strict"and"tolerant".
What’s next
You now have a reloadable, replayable record. Continue into governance and audit when you need controls before the action or proof after the fact.
Core Concepts Inputs, outputs, parameters, and how snapshots group decisions.
Storage Adapters Choose where persistent decisions live.
Deterministic Replay Go deeper on replay modes and comparison.
Audit a Decision Seal evidence, policy, and outcome into a verifiable bundle.