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.1.tar.gz (24.4 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.1-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file kerneva_runtime_trust-0.3.1.tar.gz.

File metadata

  • Download URL: kerneva_runtime_trust-0.3.1.tar.gz
  • Upload date:
  • Size: 24.4 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.1.tar.gz
Algorithm Hash digest
SHA256 72ed49a70d397bc9fe13c11cae5a574f4fdb0494ccb1e2c5235ec18f5773958d
MD5 b77fd715ba2c68b26daf7c5f07c659ad
BLAKE2b-256 1709bce7de6e3bb25be372c05b5a09ab39433aaa4fd080a5e9aaa5b4536a1f62

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kerneva_runtime_trust-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 241a7ff806811cea71c0cfd701e8233e7a1cadfdfac9a1a1de68db2c5f00a9bb
MD5 6aeadf9817eaa0d3f592c7944be6bace
BLAKE2b-256 4acaf274edc975e354d57d575244c225d2088659bb90fb2b93fb707bec418929

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