Kerneva Runtime Trust
Behavioral safety for financial AI agents.
from kerneva_runtime_trust import guard, RuntimeTrustBlock
@guard(action_type="refund")
def process_refund(amount, customer_id):
return billing_api.refund(customer_id, amount)
try:
process_refund(amount=150.0, customer_id="cust_123")
except RuntimeTrustBlock as e:
print(f"Blocked: {e}")
guard (also available as with_runtime_trust) evaluates every call through
Kerneva's /evaluate before the function body runs. On BLOCK the function
never executes and RuntimeTrustBlock is raised.
Install
pip install kerneva-runtime-trust
Setup
export KERNEVA_API_KEY="krv_test_abc123"
export KERNEVA_API_URL="https://api.kerneva.com" # or http://localhost:8080
Getting good signals
Kerneva reasons over an agent's trajectory — within a session and across your end-customers. A single function call doesn't carry that context, so declare it. The two that matter most:
action_type— match a configured threshold (e.g."refund"). If it has no threshold the call is observation-only; the SDK logs a warning so you know.customer_id— the end-customer, so one customer's trajectory doesn't bleed into another's.
Set them per-call, or ambiently for a whole interaction with session(...):
import kerneva_runtime_trust as kerneva
with kerneva.session(session_id=ticket_id, agent_id="refund-bot",
customer_id="cust_123"):
process_refund(amount=40.0, customer_id="cust_123")
process_refund(amount=75.0, customer_id="cust_123") # shares one trajectory
Without a session, each call gets its own session id (so unrelated calls are never merged) and the SDK warns once that session-scoped analysis is off.
Handling REVIEW
By default a REVIEW decision emits a Python warning and proceeds. To route it
to a human (hold, queue, escalate), pass an on_review hook — it may raise to
halt execution:
def hold_for_approval(ctx):
if ctx.recommended_decision == "REVIEW":
raise NeedsApproval(ctx.reason) # stops the wrapped function
@guard(action_type="refund", on_review=hold_for_approval)
def process_refund(amount, customer_id): ...
Reliability
- Fail-closed by default: if the API is unreachable the action does not run.
Pass
fail_open=Truefor non-critical workflows. strict=Trueturns integration warnings (misconfiguration) into a raisedKernevaConfigError— useful in development/CI to catch a broken integration.- Async: decorating an
async defreturns an async wrapper.
Low-level client
from kerneva_runtime_trust import KernevaClient
client = KernevaClient(api_key="krv_test_abc123")
result = client.evaluate(
agent_id="refund-bot", session_id="ticket-8842",
action_type="refund", amount=82.0, customer_id="cust_123",
)
# In Observation Mode nothing is blocked; recommended_decision is the shadow
# verdict — what enforcement WOULD do.
print(result.decision, result.recommended_decision, result.warnings)
See https://github.com/kerneva/runtime-trust for full documentation.
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 kerneva_runtime_trust-0.3.0.tar.gz.
File metadata
- Download URL: kerneva_runtime_trust-0.3.0.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31930d7e39187df7e61818334495041dd7137ac7e70e42e3a8a34fc8f4062d3f
|
|
| MD5 |
a5adbaafbc800da0d436895e6a2125f9
|
|
| BLAKE2b-256 |
d321f128e9fbd3803f54d616d3de76a43a0b9fd51ae3ea5256cb8483122a2460
|
File details
Details for the file kerneva_runtime_trust-0.3.0-py3-none-any.whl.
File metadata
- Download URL: kerneva_runtime_trust-0.3.0-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33dda1d9fe16cff1ecab0ad2b34ca6e0c652b55c1d94a0ba675212536f12f5a0
|
|
| MD5 |
ae91cc357331e97460c0f08e6602b125
|
|
| BLAKE2b-256 |
51ac5ef6010c25331476a8fdbf80644142521ec6f95ddd236b45370123f98b3c
|