Skip to main content

Execution-layer security SDK for AI agents — Reality Kernel

Project description

Reality Kernel Python SDK

Execution-layer security for AI agents. Reality Kernel intercepts agent tool calls before they execute and blocks prompt injection, SSRF, credential access, and exfiltration chains.

Install

pip install realitykernel

# With LangChain integration
pip install realitykernel[langchain]

Quick start

import reality_kernel

rk = reality_kernel.Client(api_key="rk_live_...")

result = rk.check(
    command="cat /etc/shadow",
    intent="read application logs",
)

print(result.verdict)    # ALLOW | WARN | BLOCK
print(result.confidence) # 0.0 – 1.0
print(result.evidence)   # ["Static: CRITICAL violation..."]

Generic decorator — works with any framework

from reality_kernel import Client
from reality_kernel.integrations.generic import rk_guard

rk = Client(api_key="rk_live_...")

@rk_guard(rk, intent="read application config file")
def read_config(path: str) -> str:
    with open(path) as f:
        return f.read()

# RKSecurityException is raised automatically if the command is blocked
read_config("../../.env")  # → BLOCK
read_config("/app/config.yaml")  # → ALLOW

LangChain integration

from langchain.agents import initialize_agent
from reality_kernel import Client
from reality_kernel.integrations.langchain import RKLangChainGuardrail

rk = Client(api_key="rk_live_...")
guardrail = RKLangChainGuardrail(client=rk, agent_id="my-agent")

agent = initialize_agent(
    tools=tools,
    llm=llm,
    callbacks=[guardrail],
)

agent.run("Summarise the production logs.")
# If the agent is hijacked and tries to run curl 169.254.169.254,
# RKSecurityException is raised before the ShellTool executes.

With a Least-Agency Policy

rk.check(
    command="aws s3 cp /secrets s3://bucket",
    intent="backup config files",
    policy={
        "allowed_tools": ["aws"],
        "allowed_egress": ["*.amazonaws.com"],
        "read_only_paths": ["/app/config"],
    }
)
# → BLOCK: PolicyViolation: '/secrets' is outside read_only_paths

Session tracking (slow-drip detection)

# Pass the same session_id across multiple agent turns.
# Reality Kernel detects: read → read sensitive file → curl external URL
# and escalates the final verdict to BLOCK automatically.

for turn in agent_turns:
    rk.check(
        command=turn.command,
        intent=turn.intent,
        session_id="agent-session-42",
    )

Docs

Full documentation: realitykernel.dev/integration
Security benchmark: realitykernel.dev/benchmark
Live playground: realitykernel.dev/playground

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

realitykernel-0.2.0.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

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

realitykernel-0.2.0-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file realitykernel-0.2.0.tar.gz.

File metadata

  • Download URL: realitykernel-0.2.0.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for realitykernel-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5eafd55a8c03e3a63483476e87aaafe94bf1a7a5e6da133b1ccb21af96d9111d
MD5 f7446a28b2b7eb16ddceb518bddf2eaa
BLAKE2b-256 afb4e08e7989f6e917228807721683a480eaa5b0d0c8b6e1475082c1c8da089d

See more details on using hashes here.

File details

Details for the file realitykernel-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: realitykernel-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for realitykernel-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 973e95e1b4c092c29e4564a4b8d09b6fb509141c4d3e2a498d6f785e8bbd2a6d
MD5 34f506ed9fcac3a610fd29ae508daf9d
BLAKE2b-256 6852ccb0210bb507db6fae3bfad2b1bbe6dc9f35c24af300a6d953ccdcd1abe1

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 Pingdom Monitoring Sentry Error logging StatusPage Status page