Cordum Safety Guard — @guard decorator for LangChain, LlamaIndex, and plain Python functions
Project description
cordum-guard
Safety governance for Python AI agents. Add Cordum safety checks to existing Python code with a single decorator — no rewrite required.
Install
pip install cordum-guard
With LangChain or LlamaIndex support:
pip install cordum-guard[langchain]
pip install cordum-guard[llamaindex]
Quick Start
from cordum_guard import CordumClient, guard
client = CordumClient("http://localhost:8081", api_key="your-api-key")
@guard(client, policy="financial_ops", risk_tags=["write", "financial"])
def execute_transfer(amount: float, to_account: str):
bank_api.transfer(amount, to_account)
The @guard decorator intercepts every call to execute_transfer:
- Evaluates the safety policy via the Cordum Safety Kernel
- allow — function runs normally
- deny — raises
CordumBlockedError - require_approval — waits for human approval in the dashboard
- throttle — delays execution per policy
LangChain Integration
from cordum_guard import CordumClient
from cordum_guard.langchain import CordumToolGuard
client = CordumClient("http://localhost:8081", api_key="your-api-key")
guarded_tools = CordumToolGuard(client, policy="agent_ops").wrap(tools)
agent = initialize_agent(guarded_tools, llm)
LlamaIndex Integration
from cordum_guard import CordumClient
from cordum_guard.llamaindex import CordumToolGuard
client = CordumClient("http://localhost:8081", api_key="your-api-key")
guarded_tools = CordumToolGuard(client, policy="agent_ops").wrap(tools)
Async Support
The @guard decorator works with both sync and async functions:
@guard(client, policy="ops")
async def async_operation():
return await some_api_call()
Configuration
CordumClient
| Parameter | Default | Description |
|---|---|---|
gateway_url |
— | Cordum gateway URL |
api_key |
— | API key for authentication |
tenant_id |
"default" |
Tenant identifier |
timeout |
30.0 |
HTTP request timeout (seconds) |
@guard decorator
| Parameter | Default | Description |
|---|---|---|
client |
— | CordumClient instance |
policy |
"" |
Policy name (label for traceability) |
risk_tags |
[] |
Risk tags sent to the Safety Kernel |
capability |
function name | Override the capability identifier |
topic |
"job.guard" |
NATS topic for policy evaluation |
timeout |
300.0 |
Max wait for approval decisions (seconds) |
CordumToolGuard (LangChain / LlamaIndex)
| Parameter | Default | Description |
|---|---|---|
client |
— | CordumClient instance |
policy |
"" |
Policy name |
risk_tags |
[] |
Risk tags for all wrapped tools |
topic |
"job.guard" |
NATS topic for evaluation |
License
Apache-2.0
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 cordum_guard-2.5.2.tar.gz.
File metadata
- Download URL: cordum_guard-2.5.2.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fdbcc9fe4f525941c5add59441dec39d85f6b32ac15e5ab6fe6ed39377589f0
|
|
| MD5 |
8dda3e9645799da9043aa2a37aaa5d32
|
|
| BLAKE2b-256 |
c9e550a33a7a091cd0c008f487c24f45ac593d9c5e60c299d6083f1f8c5438b2
|
Provenance
The following attestation bundles were made for cordum_guard-2.5.2.tar.gz:
Publisher:
publish-python-guard.yml on cordum-io/cap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cordum_guard-2.5.2.tar.gz -
Subject digest:
5fdbcc9fe4f525941c5add59441dec39d85f6b32ac15e5ab6fe6ed39377589f0 - Sigstore transparency entry: 955646209
- Sigstore integration time:
-
Permalink:
cordum-io/cap@583975e4661320c8ed8ca3c27f25715402795de5 -
Branch / Tag:
refs/tags/v2.5.2 - Owner: https://github.com/cordum-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python-guard.yml@583975e4661320c8ed8ca3c27f25715402795de5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file cordum_guard-2.5.2-py3-none-any.whl.
File metadata
- Download URL: cordum_guard-2.5.2-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47bcc5a0117b75a9981d08c90608d3aca115a744999ecc0261eee92358b27023
|
|
| MD5 |
4a3472ce267e7eb3c49c1c21285e7001
|
|
| BLAKE2b-256 |
065853814a5a068833aa38dc2928090edaa54d625946c9f787615f7a9615a69f
|
Provenance
The following attestation bundles were made for cordum_guard-2.5.2-py3-none-any.whl:
Publisher:
publish-python-guard.yml on cordum-io/cap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cordum_guard-2.5.2-py3-none-any.whl -
Subject digest:
47bcc5a0117b75a9981d08c90608d3aca115a744999ecc0261eee92358b27023 - Sigstore transparency entry: 955646221
- Sigstore integration time:
-
Permalink:
cordum-io/cap@583975e4661320c8ed8ca3c27f25715402795de5 -
Branch / Tag:
refs/tags/v2.5.2 - Owner: https://github.com/cordum-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python-guard.yml@583975e4661320c8ed8ca3c27f25715402795de5 -
Trigger Event:
release
-
Statement type: