Python SDK · node9 documentation
Python SDK
Govern any Python AI agent — one import, one line of config.
The node9 Python package wraps your agent's tool calls with the same interception layer as the CLI proxy — without requiring hook wiring or MCP. Every tool call is sent to the Node9 firewall before execution, giving you audit logs, approval flows, and shield enforcement for any Anthropic or custom Python agent.
Install
pip
pip install node9
Usage
Configure your agent
from node9 import configure
# Call once at agent startup — before any tool calls
configure(
agent_name="my-agent", # identifies this agent in audit logs
policy="require_approval", # audit | require_approval | block_on_rules
)
# Your existing Anthropic agent code runs unchanged
client = anthropic.Anthropic()
response = client.messages.create(...)Policy modes
audit
Every tool call is logged. Nothing is blocked. Use this for observability before enforcing rules.
require_approvalRecommended
Dangerous tool calls pause and wait for human approval via the Node9 dashboard or Slack before executing.
block_on_rules
Blocks actions that match active shields and smart rules. Everything else is auto-allowed.
Example — CI Code Review Agent
The governed-agent repo contains a complete reference implementation: a CI code review agent that fixes failing tests, posts a review comment, and runs a security scan — all governed by Node9.
ci-code-review-fixer
# governed-agent/ci-code-review-fixer/agent.py from node9 import configure configure(agent_name="ci-code-review", policy="require_approval") # Agent runs autonomously in CI — Node9 intercepts tool calls # and routes dangerous ones for human approval before they execute
Requirements
Python 3.9+. Requires a running Node9 daemon (
node9 daemon start) or a Node9 API key for cloud mode.