Production examples for the Briefcase AI SDK across financial services, e-commerce, and criminal justice. The repo is organized in two tiers — primitives (domain-neutral, one per file) and compositions (SDK primitives assembled into realistic stories).
pip install briefcase-aiOr use the automated setup: ./setup.sh | Docker: ./docker-run.sh build && ./docker-run.sh run
Single-file, domain-neutral demonstrations of each SDK primitive. Each .py has a sibling .ipynb for notebook users; patterns_walkthrough.ipynb is the unified tour.
| # | Pattern | What it shows |
|---|---|---|
| 01 | Decision capture | @capture + DecisionSnapshot — the audit atom |
| 02 | Bitemporal evidence | BitemporalRecord + InMemoryBitemporalStore |
| 03 | Correction append | append_correction — corrections never mutate originals |
| 04 | Temporal replay | AsOfView — clamp reads to a historical instant |
| 05 | Versioned policy | PolicyRegistry — bitemporal policy as-of |
| 06 | Examiner bundle | ExaminerBundle — content-addressed, verifiable artifact |
| 07 | Cost attribution | CostCalculator — per-decision cost + monthly projection |
| 08 | Drift detection | DriftCalculator — baseline vs. window comparison |
| 09 | PII sanitization | Sanitizer — detect and redact PII |
| 10 | Guardrail pipeline | GuardrailPipeline — multi-stage allow/deny |
| 11 | Decision replay | Regression-test primitive — re-run candidates on stored inputs |
| 12 | Rate cards | rate_card — price by platform × tier × modifier; batch is half price |
| 13 | Prompt-cache cost | cache-token billing + CostEstimate.cache_cost; warm-cache breakeven |
| 14 | Multi-cloud cost | same model across first-party/Bedrock/Vertex/Azure; tier & region levers |
See patterns/README.md for the full composition matrix.
Primitives assembled into realistic, industry-specific narratives. The Primitives column lists which pattern numbers each suite composes.
| Suite | Run | Primitives | Description |
|---|---|---|---|
| Agentic Payments | python agentic-payments/01_bitemporal_basics.py |
02+03+04+05+06 | 7-script walkthrough: cross-border payment routing with bitemporal evidence, versioned policy, examiner bundles |
| Regulatory Workflows | cd regulatory-workflows && python 01_credit_underwriting/example.py |
01 everywhere; 02+03+04+06 in the five replay-enabled examples | 14 financial compliance workflows (ECOA, BSA, CFPB, SEC, OCC, FINRA). Five include a replay capstone: 01_credit_underwriting, 02_ofac_sanctions, 05_mortgage_fair_lending, 07_aml_transaction_monitoring, 14_algo_trading_surveillance |
| Vantara Commerce | cd vantara-briefcase-demo && python 01_agent_discovery/example.py |
01+07+08+12 | Agent discovery, cost attribution (SDK pricing + rate cards), drift detection, governance reporting |
| Criminal Evidence | cd criminal-evidence-workflow && python experiments/run_experiment.py --fast |
01+09+10+11 | LLM evidence summarization with guardrails, replay, PII sanitization, and data lineage |
Each suite includes Python scripts, Jupyter notebooks, and detailed documentation.
from briefcase import DecisionSnapshot, Input, Output, ModelParameters, init
from briefcase.storage import SqliteBackend
init()
decision = DecisionSnapshot("credit_underwriting")
decision.add_input(Input("bureau_score", "685", "integer"))
output = Output("decision", "approve", "string")
output.with_confidence(0.92)
decision.add_output(output)
params = ModelParameters("gpt-4o")
params.with_provider("openai")
decision.with_model_parameters(params)
backend = SqliteBackend.in_memory()
decision_id = backend.save_decision(decision)
# Per-decision cost. `rate_card` re-prices by platform × tier (batch is ~half);
# cache_read_tokens / cache_cost bill prompt-cache usage (see patterns 12–14).
from briefcase.cost import CostCalculator
calc = CostCalculator()
est = calc.estimate_cost("gpt-4o", input_tokens=1200, output_tokens=350, rate_card="batch")
print(est.total_cost, est.cache_cost)Prefer the decorator? @capture records a function's inputs/outputs/timing automatically — call briefcase.observe("console") (or briefcase.setup(exporter=...)) once so the records are sent somewhere. See patterns/01_decision_capture.py.
See also: @capture decorator, CostCalculator, DriftCalculator, Sanitizer, GuardrailPipeline, ReplayEngine, BitemporalRecord, PolicyRegistry, AgentRouter, ExaminerBundle. Full SDK docs at briefcaseai.io.