Python SDK
The Python SDK is the primary implementation path for server-side agents, scheduled workers, and async services.
Client
from haltstate import HaltStateClient
client = HaltStateClient(
tenant_id=os.environ["HALTSTATE_TENANT_ID"],
api_key=os.environ["HALTSTATE_API_KEY"],
)Context manager guard
with client.guard("refund.create", params={"amount": 89, "currency": "USD"}, idempotency_key="refund:lge_123"):
ledger.execute_refund()Service pattern
Long-running workers should claim work, mark it as guarding, call the guard path, execute only when allowed or later approved, create proof evidence before final success, and report success or error back to HaltState. If HaltState is unavailable for a high-risk action, the worker should fail closed.
Implementation notes
Keep the HaltState call as close as possible to the side effect. The agent may plan and draft freely, but the wrapper around the actual action should be the place where authority is checked. That wrapper should send only the context required for policy evaluation: safe identifiers, normalized amounts, action names, risk flags, schedule windows, and redaction status. Raw customer payloads and secrets should stay in the business system or protected operator tooling.
Operational evidence
For each action, preserve the decision, the worker outcome, the idempotency key, safe resource references, latency, proof status, and redaction status. This evidence supports incident response and control narratives because it shows what the system did at runtime rather than only describing what the policy document intended. HaltState supports alignment work; it is not a substitute for legal advice or a compliance certification.