Skip to main content

Chain-Receipt SDK — emit, verify, replay, and chain Receipts (v1.0.0) from LangChain runnables, agent loops, or any Python callable.

Project description

chain-receipt-sdk

Emit, verify, replay, and chain Chain-Receipts (v1.0.0) from any Python LLM-agent loop. Drop-in callback for LangChain, plus a framework-agnostic ReceiptBuilder for raw API loops.

This is the methodology dependency for the Calibrated Chain-Determinism paper. Reviewers reproduce any cited Receipt with:

pip install chain-receipt-sdk
chain-receipt verify sha256:<hash>
chain-receipt replay sha256:<hash> --n 10

60-second demo

from chain_receipt_sdk import ReceiptBuilder, ClientInfo, Interaction
from chain_receipt_core import compute_text_hash, compute_tool_calls_hash, generate_keypair

sk, pub = generate_keypair()
client = ClientInfo(
    name="my-agent",
    version="0.1.0",
    platform="python-3.12",
    emitter_pubkey=f"ed25519:{pub}",
)
b = ReceiptBuilder(client=client, private_key=sk, chain_seed=pub.encode())

inter = Interaction(
    vendor="anthropic",
    model="claude-sonnet-4-5",
    temperature=0.0,
    system_prompt_hash=compute_text_hash("you are helpful"),
    prompt_hash=compute_text_hash("hello"),
    response_hash=compute_text_hash("hi"),
    tool_calls_hash=compute_tool_calls_hash([]),
    n_tool_calls=0,
    latency_ms=120,
)
r = b.build(interaction=inter)
print(r.receipt_id, r.chain.sequence_number)

LangChain callback

from langchain_core.runnables import RunnableLambda
from chain_receipt_sdk.callback import ReceiptCallback

cb = ReceiptCallback(
    client_name="my-langchain-agent",
    vendor="anthropic",
    model="claude-sonnet-4-5",
)
chain = RunnableLambda(lambda x: f"echo: {x}")
chain.invoke("hello", config={"callbacks": [cb]})

receipts = cb.receipts
print(f"emitted {len(receipts)} Receipts")

CLI

chain-receipt status                       # local chain head + count
chain-receipt verify sha256:<hash>         # validate signature + chain link
chain-receipt replay sha256:<hash> --n 10  # re-run captured prompt N times
chain-receipt chain --since 2026-04-25     # list Receipts since timestamp
chain-receipt publish sha256:<hash>        # push to chain-determinism.org

Local chain storage

Receipts are written to ~/.chain-receipt/chain.jsonl (one JSON per line) when emitted via ReceiptCallback or ReceiptBuilder.build(persist=True). The chain_receipt_sdk.chain.LocalChain reader/writer is the public API for that file.

Replay determinism

chain_receipt_sdk.replay re-runs the captured prompt against the same vendor + model + temperature N times and reports final_answer_consistent, tool_seq_identical, tool_args_identical, and a Wilson 95% CI for the divergence rate. The hash logic is byte-identical to scripts/paper5_multivendor_replay.py — that is the integration test gate in tests/test_replay.py.

Citation

@misc{calibrated_chain_determinism_2026,
  title  = {Calibrated Chain-Determinism for Production LLM Agent Loops},
  author = {Ausili, Mars},
  year   = {2026},
  note   = {Methodology: \texttt{chain-receipt-sdk} 0.1.0},
}

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chain_receipt_sdk-0.1.1-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file chain_receipt_sdk-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for chain_receipt_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3878bd2e53fc2b2ffda122f63d3c05574221420ab157578d2b4a1d906fa8fb48
MD5 b4dfe04fcca859d745b0f1550b942bf3
BLAKE2b-256 7cfcdf97dca40a350538489d9be82ed7dd86f85f4b70516e60c59cac9b2f3bf5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page