HaltState Sentinel Python SDK - Compliance & Policy Checks for AI Agents
Project description
HaltState Sentinel SDK
Compliance & policy checks for AI agents. Perform pre-action checks, approvals, and post-action reporting with minimal code.
Installation
pip install haltstate-sdk
Quickstart (sync)
from haltstate import HaltStateClient
client = HaltStateClient(tenant_id="your_tenant_id", api_key="janus_xyz", fail_open=False)
decision = client.check(
action="payment.process",
params={"amount": 5000, "currency": "USD"},
agent_id="payment-bot-01",
)
if decision.allowed:
process_payment(...)
client.report(decision, status="success", result={"transaction_id": "tx_123"}, action="payment.process", agent_id="payment-bot-01")
elif decision.requires_approval:
print(f"Approval required: {decision.reason}")
else:
print(f"Action denied: {decision.reason}")
Backward Compatibility
Existing code using janus imports continues to work:
from janus import JanusClient # Still works!
Guard Pattern (SDK 0.5.0+)
For actions requiring human approval, use the idempotent guard pattern:
from haltstate import AsyncHaltStateClient, ActionPending, ActionRejected
async def process_high_value_payment(invoice_id: str, amount: float):
client = AsyncHaltStateClient(tenant_id="acme", api_key="janus_xxx")
try:
async with client.guard(
action="payment.process",
agent_id="payment-bot",
params={"invoice_id": invoice_id, "amount": amount},
idempotency_key=f"payment-{invoice_id}", # Retry-safe
timeout_seconds=300
) as permit:
# Only executes after human approval
result = await execute_payment(amount)
print(f"Approved by {permit.approver} at {permit.approved_at}")
return result
except ActionPending:
print("Awaiting human approval...")
return {"status": "pending"}
except ActionRejected as e:
print(f"Rejected by {e.rejected_by}: {e.reason}")
raise
Key features:
- Idempotency keys: Same key = same approval request, safe for retries
- Process restart safety: Approved actions can be executed after restart
- Audit trail: Full record of who approved and when
Decorators
from haltstate import HaltStateClient, haltstate_guard
client = HaltStateClient(tenant_id="acme", api_key="janus_xxx")
@haltstate_guard(client, action="email.send", agent_id="email-bot")
def send_email(to, subject, body):
return mailer.send(to, subject, body)
Async
from haltstate import AsyncHaltStateClient
async def main():
async with AsyncHaltStateClient(tenant_id="acme", api_key="janus_xxx") as client:
res = await client.check("database.drop", params={"table": "users"})
if res.allowed:
await client.report(res, status="success", action="database.drop", agent_id="ops-bot")
Exceptions
from haltstate import (
HaltStateError, # Base error
HaltStateAuthError, # Invalid API key
HaltStateConnectionError, # Network/timeout
ActionPending, # Awaiting approval (guard pattern)
ActionRejected, # Human rejected (guard pattern)
ActionTimeout, # Approval expired (guard pattern)
)
Docs
Full documentation at haltstate.ai/docs:
- Quickstart - 5-minute setup
- Guard Pattern - HITL approval flow
- API Reference - All methods
- Error Handling - Exception handling
- SB-53 Compliance - Regulatory mapping
Migration from janus-sdk
If upgrading from janus-sdk:
# Old (still works)
from janus import JanusClient, janus_guard
# New
from haltstate import HaltStateClient, haltstate_guard
Both import styles work - no code changes required for existing users.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file haltstate_sdk-0.6.0.tar.gz.
File metadata
- Download URL: haltstate_sdk-0.6.0.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d49271b61242a6fe0fd2c3f61da77878ca5964d195aceb79d553802245a42d2d
|
|
| MD5 |
b392a5ea73ce09225ea4a04744984baf
|
|
| BLAKE2b-256 |
06acbbadceb29a433ca7881192c394e47b7014b71bc79db5c65d4dec7600e52c
|
File details
Details for the file haltstate_sdk-0.6.0-py3-none-any.whl.
File metadata
- Download URL: haltstate_sdk-0.6.0-py3-none-any.whl
- Upload date:
- Size: 18.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69d596247b1c2499d997eb878c96fb6b28f5e64958edb77d940588cdb6b2260f
|
|
| MD5 |
77fb58914e60fb35f5ab9d5fecd6af3b
|
|
| BLAKE2b-256 |
0109fb394238bc6e8a54e723c3123c9e06cd2ee5bc2cc8d2d85551a16a6f4fd4
|