CODE
Three lines to protect any agent
Aegis wraps your agent framework with zero friction. Drop it in, ship it safe.
Basic
Anthropic
Policy Rules
Compliance
from aegis import Aegis
# Three lines. Full protection.
shield = Aegis(agent_name="deploy-bot")
with shield.session("deploy-task") as s:
s.tool_call("bash", command="npm run build")
s.shell_exec("npm test", output="All 42 tests passed")
s.file_write("./dist/bundle.js")
s.http_request("POST", "https://api.deploy.io/v1", status_code=200)
# Full summary: security, metrics, policy, compliance
print(shield.summary())
import anthropic
from aegis import Aegis
client = anthropic.Anthropic()
shield = Aegis(
agent_name="code-assistant",
agent_model="claude-sonnet-4-20250514",
agent_framework="anthropic-sdk",
)
with shield.session("code-review") as s:
# Track LLM request
s.llm_request("Review this PR for security issues",
model="claude-sonnet-4-20250514", tokens=1200)
# Track tool usage
s.tool_call("read_file", path="src/auth.py")
s.file_read("src/auth.py")
# Track LLM response
s.llm_response("Found 2 issues...",
model="claude-sonnet-4-20250514", tokens=800)
# Cost tracking included
print(shield.summary()["metrics"]["total_cost_usd"])
from aegis import Aegis
from aegis.policy.rules import RuleSet
# Define policy rules in YAML
rules = RuleSet.from_yaml("""
rules:
- name: no-production-writes
description: Block writes to production database
event_types: [tool.call, exec.shell]
pattern: "production.*write|prod.*delete"
action: block
severity: critical
- name: require-approval-for-deploy
description: Escalate deployment actions
event_types: [tool.call]
pattern: "deploy|publish|release"
action: escalate
severity: high
- name: alert-on-external-api
description: Alert on external API calls
event_types: [exec.http.request]
pattern: "https?://(?!internal\\\\.)"
action: alert
severity: medium
""")
shield = Aegis(agent_name="deploy-bot", policy=rules)
from aegis import Aegis
import json
shield = Aegis(agent_name="data-pipeline")
# ... run agent sessions ...
# Generate SOC 2 compliance evidence
soc2 = shield.compliance_report("soc2")
print(json.dumps(soc2, indent=2))
# Generate EU AI Act conformity assessment
eu = shield.compliance_report("eu_ai_act")
# Generate ISO 42001 audit evidence
iso = shield.compliance_report("iso42001")
# Reports include:
# - Agent identity + fingerprint
# - Access control evidence
# - Threat detection records
# - Policy enforcement audit trail
# - Monitoring evidence
# - Incident response documentation