Verdict Python SDK
The official Python SDK for Verdict Guard (tryverdictguard-sdk, imported as tryverdictguard_sdk). It evaluates proposed AI agent actions against Verdict Core with sub-15ms latency, enforces 5-layer hierarchical policies, provides human-in-the-loop escrow holds, and executes 1-click compensating Saga rollbacks.
Requires Python 3.10 or newer.
Install
pip install tryverdictguard-sdk
Configure credentials via environment variables:
export VERDICT_BASE_URL="https://api.tryverdictguard.com"
export VERDICT_CLIENT_ID="your_client_id"
export VERDICT_CLIENT_SECRET="your_client_secret"
export VERDICT_DPOP_PRIVATE_KEY="your_base64_ed25519_key"
1. Declarative Guardrail with Saga Rollback
Wrap sensitive agent tool functions using @verdict.guard. If rollback_fn is provided, Verdict arms a compensating inverse delta hook. If downstream steps fail or leadership triggers a rollback from the Console, the compensating transaction executes surgically.
import os
from tryverdictguard_sdk import VerdictClient, VerdictPolicyBlockedError
verdict = VerdictClient(
base_url=os.environ.get("VERDICT_BASE_URL", "https://api.tryverdictguard.com"),
client_id=os.environ["VERDICT_CLIENT_ID"],
client_secret=os.environ["VERDICT_CLIENT_SECRET"],
agent_id="payments-agent",
)
# Start background saga worker to process leadership console rollbacks
verdict.start_rollback_worker(interval=2.0)
def refund_transfer(original_args, execution_output):
"""Compensating Saga Inverse Delta (e.g., after 5 hours or on failure)."""
transfer_id = execution_output.get("transfer_id")
print(f"Executing surgical refund for transfer {transfer_id}...")
stripe.Refund.create(charge=transfer_id)
return {"status": "REFUNDED", "transfer_id": transfer_id}
@verdict.guard(
tool_name="payments.create_transfer",
risk_category="FINANCIAL",
value_field="amount",
rollback_fn=refund_transfer,
rollback_on_exception=True, # Auto-compensates if downstream tool fails!
)
def create_transfer(amount: float, recipient_id: str, currency: str = "USD"):
# Real-world external side-effect
return {"status": "SUCCESS", "transfer_id": f"txn_{recipient_id}", "amount": amount}
try:
result = create_transfer(amount=125.00, recipient_id="vendor_4821")
print("Action executed:", result)
except VerdictPolicyBlockedError as err:
print(f"Action blocked by policy ceiling: {err}")
2. Programmatic Exception Recovery & Multi-Step Pipelines
When orchestrating multi-step agent journeys, if step 3 fails, seamlessly revert steps 1 and 2 with an audit reason:
try:
step1_out = create_invoice(vendor_id="v_101", amount=2500.0)
step1_id = verdict.last_execution_id
step2_out = reserve_gpu_instances(nodes=4)
step2_id = verdict.last_execution_id
# Downstream failure (e.g. invalid checkpoint or container crash)
raise RuntimeError("Storage bucket unmounted during initialization")
except Exception as exc:
# Surgically rollback in reverse order (LIFO)
verdict.execute_rollback(step2_id, reason=f"Pipeline aborted: {exc}")
verdict.execute_rollback(step1_id, reason=f"Pipeline aborted: {exc}")
raise
3. 5-Hour State Safety: Saga vs Physical Database Restore
Why Compensating Deltas? If an agent executed an action 5 hours ago and leadership requests a rollback, physical database restoration (e.g.,
pg_restoreor disk snapshots) would wipe out all 5 hours of subsequent transactions created by every user across the company. Verdict uses the Saga Compensating Pattern: it invokesrollback_fn(original_args, execution_output)to apply an exact, surgical inverse delta (e.g., issuing a refund or releasing a reservation), keeping all other data untouched.
4. Manual Low-Level Evaluation
For custom agent loops or manual policy checks:
decision = verdict.evaluate(
tool_name="refund_payment",
original_args={"payment_id": "pay_123", "amount_usd": 25.00},
session_id="checkout-session-1001",
end_user_id="user_456",
risk_category="FINANCIAL",
monetary_value_usd=25.00,
pre_flight_snapshot={"payment_status": "captured"},
)
if decision.verdict_status == "ALLOWED":
# Execute tool
pass
elif decision.verdict_status == "ESCROW_PENDING":
# Wait for human reviewer
pass
Authenticated Endpoints & Security
Every request uses an RFC 9449 Ed25519 DPoP proof:
POST /v1/telemetry/intent- Record raw LLM intentPOST /v1/guard/evaluate- Sub-15ms policy & velocity evaluationGET /v1/guard/escrow/{id}/wait- Escrow human review long-pollPOST /v1/guard/commit-snapshot- Downstream execution outcome recordingPOST /v1/guard/executions/{id}/rollback- Trigger compensating rollbackPOST /v1/guard/rollback/claim- Claim pending rollback tasksPOST /v1/guard/rollback/{id}/report- Report compensation status
Metadata
Release files for tryverdictguard-sdk 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tryverdictguard_sdk-1.1.0.tar.gz | 22.1 kB | Without provenance | Details for tryverdictguard_sdk-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tryverdictguard_sdk-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for tryverdictguard_sdk-1.1.0-py3-none-any.whl |
Total release size: 39.2 kB
Release files / tryverdictguard_sdk-1.1.0.tar.gz
| Download URL | tryverdictguard_sdk-1.1.0.tar.gz |
|---|---|
| Size | 22.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9d46e3abc96d20b47862ab1a54878b828d16ea83166a57415bc1ebe153d084eb
|
|
BLAKE2b-256 checksum How to use checksums |
19055f63de80290ad29e1d292561a9c352f3fb5b76a139cff7535b1cdd4fe3f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Release files / tryverdictguard_sdk-1.1.0-py3-none-any.whl
| Download URL | tryverdictguard_sdk-1.1.0-py3-none-any.whl |
|---|---|
| Size | 17.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
97455d2742721d055521a11c02eda44b90b4836317da5cde2d295f137e51750e
|
|
BLAKE2b-256 checksum How to use checksums |
a0983a2b755761843e5205067f9cc4ad300e0edfd596867c6a9c4699495dddfa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Security for tryverdictguard-sdk 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.