Skip to main content

NullRun

Ship AI agents with real-time budget, policy, and human-approval gates.

Zero-refactor cost control, tool policy enforcement, and audit trail for any LLM-powered agent - works with OpenAI, Anthropic, LangGraph, CrewAI, AutoGen, LlamaIndex, and your own stack.

Quickstart · Docs · Examples

PyPI version Python versions License Downloads
CI Coverage Stars Last commit
protocol v4 Zero-code instrumentation Server-authoritative cost

⚠️ Status: alpha (v0.16.4). The public API may shift between minor versions. Pin your dependency and read the CHANGELOG before upgrading.


Why NullRun?

AI agents can overspend, call dangerous tools, and act without audit trails. Existing observability tools tell you after the fact. NullRun enforces before the action.

Without NullRun With NullRun
Agent calls gpt-4o 10,000 times → surprise $5,000 invoice Hard budget cap → SDK blocks at 402 before invocation
Agent runs bash rm -rf / Tool policy → SDK blocks at 403 before execution
Sensitive action with no human in the loop Approval flow → SDK pauses and waits for WS approval_resolved push
Cost & calls scattered across 4 libraries Single source of truth: per-org, per-workflow, per-execution
Runaway SDK loop calling /gate without /track Per-reservation rate cap → 402 budget error (see docs/errors/NR-R001.md)

Features

Hard & soft budget gates — atomic Redis-enforced Tool policy enforcement — block dangerous tools before execution
Human-in-the-loop approvals — pause agent and await approval_resolved via WS push Immutable audit trail — every decision, every tool call, every cent
Zero-code instrumentationnullrun.init() patches httpx once for any vendor LangGraph, CrewAI, AutoGen, LlamaIndex — first-class integrations
Memory-safe streaming — 16 MiB response body; full body for usage extraction Lightweight — no LLM-key storage, no proxy required
Server-authoritative cost — server-minted execution IDs MCP support — expose tools to agents via Model Context Protocol

Architecture

%%{init: {
'flowchart': {
    'curve': 'basis',
    'htmlLabels': true,
    'nodeSpacing': 80,
    'rankSpacing': 90
}
}}%%

flowchart LR
%% =========================
%% AI RUNTIME
%% =========================
subgraph USER ["👤 AI Runtime"]
direction TB
A["🤖 Agent"]
end

%% =========================
%% NULLRUN LAYER
%% =========================

subgraph LIB ["📦 NullRun Enforcement Layer"]
direction TB
B["NullRun SDK<br/>Interceptor"]
C["🚦 Runtime Gate"]
P["📜 Policy Engine"]
H["👤 Human Approval"]

end

%% =========================
%% PRODUCTION
%% =========================

subgraph PROD ["⚙️ Production Actions"]
direction TB

T["🛠 Tools"]
API["🌐 External APIs"]
DB["🗄 Databases"]
end

STATE["🗂 Audit + Runtime State"]

%% =========================
%% FLOW
%% =========================

A -->|"protected action"| B
B -->|"authorize"| C
C --> P
P -->|"allow"| T
P -->|"allow"| API
P -->|"allow"| DB
C -->|"require approval"| H
H -->|"approved"| T
C --> STATE

%% =========================
%% COLORS
%% =========================
classDef user fill:#dbeafe,stroke:#2563eb,color:#0f172a
classDef sdk fill:#dcfce7,stroke:#16a34a,color:#0f172a
classDef srv fill:#fed7aa,stroke:#ea580c,color:#0f172a
classDef store fill:#f5d0fe,stroke:#a21caf,color:#0f172a
classDef ok fill:#bbf7d0,stroke:#16a34a,color:#0f172a
classDef wait fill:#fef08a,stroke:#ca8a04,color:#0f172a

class A user
class B sdk
class C,P,H srv
class STATE store
class T,API,DB ok
class H wait

style USER fill:#f8fafc,stroke:#64748b,stroke-width:1px
style LIB fill:#f8fafc,stroke:#64748b,stroke-width:1px
style PROD fill:#f8fafc,stroke:#64748b,stroke-width:1px

The gate is server-authoritative — the SDK never trusts client-supplied cost. Redis is the source of truth for budget and tool-policy state; Postgres holds the immutable audit log.


sequenceDiagram

participant Agent
participant SDK
participant Gate
participant Policy
participant Human
participant Tool


Agent->>SDK: execute(tool)
SDK->>Gate: authorize(action)
Gate->>Policy: evaluate rules

alt Allowed
Policy-->>Gate: allow
Gate-->>SDK: continue
SDK->>Tool: execute
else Approval required
Policy-->>Gate: approval_required
Gate-->>SDK: wait
Gate->>Human: request approval
Human-->>Gate: approved
Gate-->>SDK: resume
SDK->>Tool: execute
else Blocked
Policy-->>Gate: deny
Gate-->>SDK: exception
end

Quickstart

Install:

pip install nullrun
export NULLRUN_API_KEY="nr_..."   # get one at https://nullrun.io/control-center/api-keys

Option — decorator (3 lines)

from nullrun import protect

@protect
def my_agent(prompt: str) -> str:
    return call_llm(prompt)

How NullRun compares

NullRun LangChain callbacks Helicone Portkey OpenLLMetry
Enforce before execution ⚠️ async ⚠️ async
Server-authoritative budget
Tool-call policy ⚠️ limited
Human-in-the-loop approvals
Zero-code instrumentation
Immutable audit trail ⚠️
Streaming memory cap (anti-OOM) ⚠️ ⚠️
MCP support ⚠️ ⚠️

NullRun is the only option that blocks expensive or dangerous calls before they happen, not just observes them.


Querying the audit log

Every gate decision, approval resolution, and execution lifecycle event is written to the org's hash-chained audit_events table on the backend. The SDK surfaces a typed read API at runtime.audit.* so backends on ADR-009 (schema_version = 3) return typed dataclasses — not raw dicts.

from nullrun import NullRunRuntime, AuditQuery
from datetime import datetime, timezone, timedelta

runtime = NullRunRuntime(api_key="nr_...")

# 1) Last 50 governance decisions in the last 24h.
since = (datetime.now(timezone.utc) - timedelta(hours=24)).isoformat()
page = runtime.audit.list(
    AuditQuery(event_type="authorization_decision", since=since, limit=50)
)
for entry in page.entries:
    print(entry.timestamp, entry.decision, entry.tool_name, entry.reason_code)

Available surfaces:

Method Returns Endpoint
runtime.audit.list(query=...) AuditLogPage (entries + meta) GET /api/v1/orgs/{org}/audit-log
runtime.audit.verify(since=...) AuditVerifyResult (chain head/tail/reason) GET /api/v1/orgs/{org}/audit-log/verify
runtime.audit.list_exports() list[AuditExportJob] GET /api/v1/orgs/{org}/audit-log/export
runtime.audit.create_export() dict (job_id, status) POST /api/v1/orgs/{org}/audit-log/export
runtime.audit.export_status(job_id) AuditExportStatus GET /api/v1/orgs/{org}/audit-log/export/{job_id}/status

AuditQuery filters on the canonical ADR-009 columns: event_type (authorization_decision / approval_decision / execution_lifecycle), decision, policy_id, execution_id, actor, since, until, limit. Pre-ADR-009 backends return legacy fields only — AuditEntry.is_governance is False for those rows, and the 13 governance columns default to None.

If you call runtime.audit.* before nullrun.init() (no org binding), the proxy raises NullRunAuthenticationError — not a silent 404 — so a misconfigured CI step fails loudly at the audit call site rather than silently dropping the query.


Examples

Runnable, copy-pastable examples live in a separate repo so you can adapt without cloning the SDK source:

  • LangGraph — multi-node agent with budget + approval
  • CrewAI — multi-agent crew with shared budget
  • AutoGen — group-chat agent with policy gating
  • LlamaIndex — RAG pipeline with cost-per-query enforcement
  • Custom tools — register your own tools for policy
  • Multi-agent — shared budget across sub-agents

Roadmap

Version Status Highlights
v0.14.x ✅ alpha Wire protocol v3.31, server-minted execution IDs, MCP, anti-OOM streaming cap
v0.15.x ✅ alpha ADR-009 governance audit surface, typed runtime.audit.*, capability probes for /audit-log/verify, fail-OPEN observability closure
v0.16.x (current) ✅ alpha Phase-1+ action_digest on /gate, /execute tools propagation, transient-5xx retry on gate (NR-006), error-code parity (NR-007, 41→56 entries)
v0.17 📋 planned OpenTelemetry exporter, Redis-backed offline queue, hardened init contract
v1.0 🎯 beta target Stable wire contract, full async support, type-safe decisions

Full roadmap & RFCs →


Development setup

git clone https://github.com/nullrunio/nullrun-sdk-python
cd nullrun-sdk-python
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest -q

We follow Conventional Commits, require tests for new public API, and run ruff + mypy in CI.


Security

NullRun does not store or proxy your LLM provider keys — it sits beside your existing clients and observes the calls. The gate is server-authoritative for cost: even a malicious SDK cannot inflate spend by sending a fake cost_cents to /track.

See the security policy for the threat model and disclosure policy.


Community & support


Made with care by NullRun and contributors.

⭐ Star us on GitHub · 📖 Read the docs

Download files

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

Source Distribution

nullrun-0.17.1.tar.gz (764.9 kB view details)

Uploaded Source

Built Distribution

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

nullrun-0.17.1-py3-none-any.whl (315.1 kB view details)

Uploaded Python 3

File details

Details for the file nullrun-0.17.1.tar.gz.

File metadata

  • Download URL: nullrun-0.17.1.tar.gz
  • Upload date:
  • Size: 764.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for nullrun-0.17.1.tar.gz
Algorithm Hash digest
SHA256 ddfc3411d1140a0dfacb58519e5249c23f31e238866b4182c92933e9344fa6bf
MD5 502abb1e0868ae261817439db1e23803
BLAKE2b-256 b63e5a9723e506cb046141309b8d96434d2f45da5674d7147a543728092be336

See more details on using hashes here.

Provenance

The following attestation bundles were made for nullrun-0.17.1.tar.gz:

Publisher: publish.yml on nullrunio/nullrun-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nullrun-0.17.1-py3-none-any.whl.

File metadata

  • Download URL: nullrun-0.17.1-py3-none-any.whl
  • Upload date:
  • Size: 315.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for nullrun-0.17.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1ed11ea25a4d61580f66c7b3e0edea619241c4fbff07f0284bc3ebf4ddadbf63
MD5 bbd0d1674238eb4069647a49a3299154
BLAKE2b-256 52038e919ed269fbbf4ba2d612c76327215f272e8643eb1f03543d6f88e8cf23

See more details on using hashes here.

Provenance

The following attestation bundles were made for nullrun-0.17.1-py3-none-any.whl:

Publisher: publish.yml on nullrunio/nullrun-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.17.1 This release

2 files

0.17.0

2 files

0.16.8

2 files

0.16.7

2 files

0.16.6

2 files

0.16.5

2 files

0.16.4

2 files

0.16.3

2 files

0.15.2

2 files

0.14.6

2 files

0.13.11

2 files

0.13.9

2 files

0.13.5

2 files

0.4.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page