Integrations

Zero-Code Setup

sitecustomize.py and sidecar patterns for governance without code changes.

Zero-Code Setup

Overview

Configure AgentTrust governance without modifying application source code using environment variables, PYTHONSTARTUP, and autoload. Ideal for third-party tools, legacy systems, and containerized deployments.

Why It Matters

Some environments prohibit code changes. Zero-code setup injects governance at the Python interpreter level.

Prerequisites

pip install "agentrust-sdk[embedded,autoload]"

Step-by-Step Guide

Option 1: PYTHONSTARTUP + env vars

export AGENTRUST_ENABLED=true
export AGENTRUST_AUTOLOAD_EMBED=true
export AGENTRUST_AUTOLOAD_AGENT_ID=my-agent
export AGENTRUST_AUTO_INSTRUMENT=true
export PYTHONSTARTUP=$(python -c "import agentrust_sdk, os; print(os.path.join(os.path.dirname(agentrust_sdk.__file__), 'autoload.py'))")

python your_app.py

Option 2: sitecustomize.py

Place in your virtualenv's site-packages or PYTHONPATH:

# sitecustomize.py
import os
if os.environ.get("AGENTRUST_ENABLED", "true").lower() == "true":
    try:
        from agentrust_sdk.autoload import bootstrap
        bootstrap()
    except ImportError:
        pass

Option 3: Docker/K8s env injection

env:
  - name: AGENTRUST_ENABLED
    value: "true"
  - name: AGENTRUST_GATEWAY_URL
    value: "http://localhost:8765"
  - name: AGENTRUST_AUTOLOAD_EMBED
    value: "true"
  - name: AGENTRUST_AUTOLOAD_AGENT_ID
    value: "payment-agent"

Rollback

export AGENTRUST_ENABLED=false
# No code change; restart process

Examples

Sidecar pattern (K8s):

# App container: AGENTRUST_GATEWAY_URL=http://localhost:8765
# Sidecar: embedded or full gateway on port 8765

Best Practices

  • Document env vars in your deployment runbook
  • Test zero-code setup in staging before production
  • Use meaningful AGENTRUST_AUTOLOAD_AGENT_ID values
  • Monitor with agentrust status after deploy

Common Mistakes

  • Forgetting [embedded] extra when using AGENTRUST_AUTOLOAD_EMBED
  • PYTHONSTARTUP not executing in some IDE debug configurations
  • Zero-code setup in production without gateway monitoring

Troubleshooting

IssueFix
No governance activityagentrust status; check AGENTRUST_ENABLED
PYTHONSTARTUP ignoredUse -S flag check; some embedders skip it
Wrong agent ID in auditSet AGENTRUST_AUTOLOAD_AGENT_ID explicitly