Python SDK for Rubric — runtime governance for AI agents
Project description
rubric-app
Runtime governance for AI agents — Python SDK.
rubric-app is the official Python SDK for Rubric. Wrap a tool call with one decorator and every invocation is evaluated against your central policy bundle and logged to a tamper-evident audit trail. Built for teams running LangChain, MCP, the Claude Agent SDK, or anything else that calls tools on behalf of an LLM.
Install
Requires Python 3.10+.
pip install rubric-app
Optional adapter extras:
pip install 'rubric-app[langchain]' # LangChain callback
pip install 'rubric-app[claude-agent]' # claude_agent_sdk PreToolUse hook
pip install 'rubric-app[mcp]' # MCP ClientSession wrapper
Quickstart
You'll need an enrollment token from your Rubric dashboard at https://app.rubric-app.com. Tokens start with enr_.
import os
import rubric
# 1. Bootstrap once at process startup.
os.environ["RUBRIC_ENROLLMENT_TOKEN"] = "enr_…" # or pass enrollment_token=...
rubric.init(agent_name="payments-bot")
# 2. Decorate any tool function. The decorator calls evaluate() before
# invoking it; if the policy denies, GovernanceDeniedError is raised.
@rubric.tool
def delete_file(path: str) -> str:
return _do_delete(path)
# 3. Optional: group calls under a session so audit rows can be filtered
# by conversation in the dashboard.
with rubric.session("conv-42"):
try:
delete_file("/tmp/foo")
except rubric.GovernanceDeniedError as e:
print(f"blocked by policy: {e}")
Adapters
End-to-end examples live under examples/ in the source repo:
| Example | Integrates with |
|---|---|
examples/decorator_quickstart.py |
Plain Python functions (the shortest possible governed agent) |
examples/langchain_quickstart.py |
LangChain BaseTool subclasses — denies raise GovernanceDeniedError |
examples/claude_agent_quickstart.py |
claude_agent_sdk — installs a PreToolUse permission callback |
examples/mcp_quickstart.py |
Raw mcp.ClientSession — denies surface as CallToolResult(isError=True) |
How it works
- Bundle poller — a background thread pulls
GET /v1/bundle?since=<hash>every 30s. New bundles atomically replace the in-process evaluator state. - Evaluator — pure-Python by default. ReDoS-immune (
regexlibrary with a per-match timeout) and fail-closed (a detector crash or regex compile failure denies). - Audit sink — events queue without blocking the hot path, ship in batches, retry on transient failures, and pass through
scrub_secrets()before egress. - DLP — optional
Detectorfor inline scanning of tool inputs and outputs; same scrubber covers JWTs,Bearerheaders, postgres credentials, AWS / OpenAI / GitHub / Slack provider keys, and 64-char hex tokens.
Environment variables
| Variable | Purpose |
|---|---|
RUBRIC_ENROLLMENT_TOKEN |
Token from the dashboard. Required unless passed via enrollment_token=. |
RUBRIC_AGENT_NAME |
Stable name for this agent in the dashboard. Required unless passed via agent_name=. |
RUBRIC_API_URL |
Override the default https://api.rubric-app.com. Must be https:// and on rubric-app.com or a subdomain — the SDK refuses everything else at construction. |
RUBRIC_DLP |
DLP mode override: off, regex, presidio, auto. |
License
Apache-2.0. See LICENSE.
Links
- Dashboard: https://app.rubric-app.com
- Documentation: https://docs.rubric-app.com
- Issues: https://github.com/getrubric/sdk/issues
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rubric_app-0.1.0.tar.gz.
File metadata
- Download URL: rubric_app-0.1.0.tar.gz
- Upload date:
- Size: 52.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8f5f38fcfc05140eb6b45f3aedd735b67f5f57f4e6d6177fca091b3f699ec21
|
|
| MD5 |
4f150e80e8987e7d563219d8191c0202
|
|
| BLAKE2b-256 |
5d8fa87caa05ce99a54f0280e8a73c343cb46cdc90dedb72278dc4ab4278c560
|
File details
Details for the file rubric_app-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rubric_app-0.1.0-py3-none-any.whl
- Upload date:
- Size: 55.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d9132c95ad26194d2f9f3c2a79417405007760f4c84c645d68dd4af0a765178
|
|
| MD5 |
0a9da63e128f4211bedc17e3775613b1
|
|
| BLAKE2b-256 |
0b3e789b4e51bdf1ecacc472755dfe9c1bbfe5e2e79a148063a0c1406acc7c93
|