Governance middleware for AI agents. One line before every action.
Project description
Epistemic Handshake - Python SDK
Governance middleware for AI agents. One line before every action.
Install
pip install epistemic-handshake
Quick Start
from epistemic_handshake import EH
eh = EH(api_key="eh_xxx", policy_id="your-policy-id")
# One-line check
if eh.allow("Send refund of 350 pounds to customer"):
send_refund()
else:
print("Action blocked by policy")
Full Verification
result = eh.verify("Apply 25% discount to order #4521")
print(result.verdict) # APPROVE, DENY, or ESCALATE
print(result.confidence) # 0.0 - 1.0
print(result.reasoning) # Why this verdict
print(result.approved) # True/False
print(result.blocked) # True if DENY or ESCALATE
Decorator
@eh.guard("Send email to {recipient}")
def send_email(recipient, body):
# Only executes if EH approves
smtp.send(recipient, body)
@eh.guard() # Auto-generates intent from function name + args
def delete_user(user_id):
db.delete(user_id)
Observe Mode
Start without blocking anything. See what EH would catch.
eh = EH(api_key="eh_xxx", policy_id="xxx", mode="observe")
# Everything passes, but violations are logged
result = eh.verify("Apply 50% discount")
# result.approved == True (observe mode)
# But logs: "[OBSERVE] Would have blocked: Apply 50% discount"
Environment Variables
export EH_API_KEY=eh_xxx
export EH_POLICY_ID=your-policy-id
# Optional:
export EH_API_URL=https://your-custom-deployment.com
# No args needed if env vars are set
from epistemic_handshake import EH
eh = EH()
Error Handling
eh = EH(
api_key="eh_xxx",
policy_id="xxx",
on_error="escalate", # If API is down: "escalate", "approve", or "deny"
)
With LangChain
from epistemic_handshake import EH
from langchain.tools import tool
eh = EH(api_key="eh_xxx", policy_id="xxx")
@tool
def send_refund(amount: float, customer_id: str) -> str:
"""Send a refund to a customer."""
result = eh.verify(f"Send refund of {amount} pounds to customer {customer_id}")
if result.blocked:
return f"Action blocked: {result.reasoning}"
# proceed with refund
return f"Refund of {amount} sent to {customer_id}"
Free During Early Access
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 epistemic_handshake-0.2.0.tar.gz.
File metadata
- Download URL: epistemic_handshake-0.2.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f006b77496cd22c317d2715115799f7550d6d3375c92fbd9d65eb965d02f4dde
|
|
| MD5 |
41127b3a63a5006b8afd75395e6a1c16
|
|
| BLAKE2b-256 |
edd91773711b994810a7408da0b209e57f19b078302f92aaa22807abab5b54b0
|
File details
Details for the file epistemic_handshake-0.2.0-py3-none-any.whl.
File metadata
- Download URL: epistemic_handshake-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99f876d2c39cb2613fe21a1b82111e69eb2278017d53f3e159f962a7a9f6a06b
|
|
| MD5 |
b24ce77fc4dd55f5d843380526ce46ce
|
|
| BLAKE2b-256 |
34dfbfdc0f315fb47a069f0cff4804fefdd1ffa8e4bf6a19ca52c0ce496b8e4d
|