Canopy Agent Safety Runtime: policy enforcement for tool-using agents
Project description
Canopy Runtime
Minimal Agent Safety Runtime focused on a single primitive:
authorize_action(agent_ctx, action_type, action_payload) → {decision, reason, avid}
Decisions:
ALLOWDENYREQUIRE_APPROVAL
Every decision is appended to a JSONL hash-chain audit log (audit.log by default).
Quickstart
pip install canopy-runtime
from canopy import authorize_action
decision = authorize_action(
agent_ctx={"env": "production"},
action_type="execute_shell",
action_payload={"command": "rm -rf /tmp/logs"},
)
print(decision["decision"]) # DENY
print(decision["reason"]) # Denied by policy: matched /rm\s+-rf/
print(decision["avid"]) # AVID-...
An audit.log file is created automatically in the current directory.
Default policy pack
Works out of the box — no configuration required:
execute_shell: denies destructive patterns; requires approval for network/install commands.modify_file: denies protected paths; requires approval unless path is inagent_ctx["safe_paths"].call_external_api: requires approval.
Config
| Variable | Default | Description |
|---|---|---|
CANOPY_POLICY_FILE |
bundled default.yaml |
Path to a custom YAML policy file |
CANOPY_AUDIT_LOG_PATH |
audit.log |
Path to audit log |
Pass agent_ctx["safe_paths"] as a list to allowlist paths for modify_file:
agent_ctx = {"env": "production", "safe_paths": ["/tmp/", "/repo/"]}
Optional HTTP gateway
pip install canopy-runtime[gateway]
CANOPY_AUDIT_LOG_PATH=/tmp/canopy_audit.log python -m uvicorn canopy.service:app --port 8010
Demo CLI
canopy-demo
canopy-demo --safe-path /tmp/
Development
git clone https://github.com/Mavericksantander/Canopy
cd Canopy
pip install -e ".[dev]"
pytest -q
License
MIT
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 canopy_runtime-0.1.2.tar.gz.
File metadata
- Download URL: canopy_runtime-0.1.2.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d581c47ad40f5d5b90bd693ede575d110ed5b02daf5ecce2874d16053f968ea0
|
|
| MD5 |
77a9a1e3a7d61aa9d22fcb14754bd9df
|
|
| BLAKE2b-256 |
e327a3917516be7f11aca417614dfcf12b096446c630d987701e5864bedc2a8f
|
File details
Details for the file canopy_runtime-0.1.2-py3-none-any.whl.
File metadata
- Download URL: canopy_runtime-0.1.2-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbb0d1e263bdb8b1b9480769e123da326d07024da547e7b18abb0405d72c0443
|
|
| MD5 |
a992fe1b7073703b0fb3ffc4a3fdeadd
|
|
| BLAKE2b-256 |
ed584d44a8fef132a060e54eca00becfe41b4e3c1d86cdf5b0346c9300219b54
|