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.1.0.tar.gz (14.5 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.1.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for realitykernel-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2af6cd2ded77d8afbb68c7e1d006dc304879362ac70777e58b6a5f2cd5c8aeb6
MD5 56db86047e45fa1c606522b12a02eadc
BLAKE2b-256 a3b7e508a45f163367da51b1f15c9396d35026cbddfe5d7633887b39a5b7ec60

See more details on using hashes here.

File details

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

File metadata

  • Download URL: realitykernel-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 047a4f414aca43dc59c71503a88d1d7d736fee73c853048502f792a7b1e54f30
MD5 4bfb32875bb1a49c69938fdb30233e94
BLAKE2b-256 33f51f69dc0622884804474ce1972ea6c936d553c7db594ea0e9b82f3fcf0586

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