Skip to main content

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=True for non-critical workflows.
  • strict=True turns integration warnings (misconfiguration) into a raised KernevaConfigError — useful in development/CI to catch a broken integration.
  • Async: decorating an async def returns 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

kerneva_runtime_trust-0.3.0.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kerneva_runtime_trust-0.3.0-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

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

Hashes for kerneva_runtime_trust-0.3.0.tar.gz
Algorithm Hash digest
SHA256 31930d7e39187df7e61818334495041dd7137ac7e70e42e3a8a34fc8f4062d3f
MD5 a5adbaafbc800da0d436895e6a2125f9
BLAKE2b-256 d321f128e9fbd3803f54d616d3de76a43a0b9fd51ae3ea5256cb8483122a2460

See more details on using hashes here.

File details

Details for the file kerneva_runtime_trust-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for kerneva_runtime_trust-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 33dda1d9fe16cff1ecab0ad2b34ca6e0c652b55c1d94a0ba675212536f12f5a0
MD5 ae91cc357331e97460c0f08e6602b125
BLAKE2b-256 51ac5ef6010c25331476a8fdbf80644142521ec6f95ddd236b45370123f98b3c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page