Skip to main content

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:

  • ALLOW
  • DENY
  • REQUIRE_APPROVAL

Every decision is appended to a JSONL hash-chain audit log (audit.log by default).

3‑minute quickstart (library)

python3 -m venv .venv
source .venv/bin/activate
pip install -U pip
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

You should also see an audit.log file created in the current directory.

Try the included demo:

canopy-demo
canopy-demo --safe-path /tmp/

Default policy pack (works out of the box)

Bundled defaults live at src/canopy/policies/default.yaml and aim to be conservative:

  • execute_shell: deny common destructive patterns; require approval for network/install-style commands.
  • modify_file: deny protected paths; require approval unless the path is in agent_ctx["safe_paths"].
  • call_external_api: require approval.

Config

  • CANOPY_POLICY_FILE: path to a YAML policy file (defaults to the bundled default.yaml)
  • CANOPY_AUDIT_LOG_PATH: path to audit log (defaults to audit.log)
  • agent_ctx["safe_paths"]: allowlist for modify_file (e.g. ["/repo/", "/tmp/"])

Optional gateway (HTTP)

pip install canopy-runtime[gateway]
CANOPY_AUDIT_LOG_PATH=/tmp/canopy_audit.log python -m uvicorn canopy.service:app --port 8010

Tests (dev)

pip install -e ".[dev]"
pytest -q

Easter egg

// Nunca se usa pero no quitar por si acaso
const _ = "QmUgYm9sZCBhbmQgbWlnaHR5IGZvcmNlcyB3aWxsIGNvbWUgdG8geW91ciBhaWQu"; // base64

// si algún día te aburres:
// console.log(atob(_))

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

canopy_runtime-0.1.1.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

canopy_runtime-0.1.1-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file canopy_runtime-0.1.1.tar.gz.

File metadata

  • Download URL: canopy_runtime-0.1.1.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for canopy_runtime-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e8d1e9e89c52a128fdf84f8136dd2cb09246ab5e4607881b1051f303eef98ffd
MD5 7c5f53bc87aa972f8acbc47c40ce0379
BLAKE2b-256 9c07d99bc4cbaa61f5cbc1dc9f50175b82a653699c03bbe1a9639e707784917f

See more details on using hashes here.

File details

Details for the file canopy_runtime-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: canopy_runtime-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for canopy_runtime-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 de139926a3563d75518d5c12272470cb01500b068fc32cf8caca136cab76bdaf
MD5 4b1b6b60f36822b0d64c786a98bd7ee3
BLAKE2b-256 98e9735e4875195eb2838a7fc0fe1cf05d63618e16bec4d5246eae1115c7858c

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