Skip to main content

Anthropic tool_use governance middleware for Aegis ACP

Project description

aegis-anthropic

Drop-in Anthropic SDK wrapper that routes every tool_use call through Aegis's runtime governance pipeline before execution.

PyPI Python License

pip install aegis-anthropic

What it does

Wraps anthropic.Anthropic() so that every tool_use block produced by Claude is pre-checked by Aegis (POST /execute) before the tool actually runs. Blocked tool calls become text blocks that explain the denial. The Claude agent loop handles them naturally — no special error path in your code.

Aegis itself decides what to block based on action semantics (the DROP TABLE, rm -rf, kubectl delete, external-PII-egress patterns from services/policy/policies/action_semantics_deny.rego). The deny is earned from content, not from a hardcoded "critical" tag — so it survives a buyer changing the agent's risk level.

Every check produces a signed audit row in the Aegis chain. Your auditor can verify it offline with aegis-verify (the tools/aegis_verify/ CLI).

Three-line install

from aegis_anthropic import AegisAnthropic

client = AegisAnthropic(
    api_key="sk-ant-...",      # Anthropic key (or ANTHROPIC_API_KEY env)
    aegis_key="acp_...",       # Aegis API key (or AEGIS_API_KEY env)
    aegis_url="https://ha.aegisagent.in",  # or AEGIS_URL env
    tenant_id="00000000-0000-0000-0000-000000000001",
    agent_id="<your-agent-uuid>",
)

response = client.messages.create(
    model="claude-opus-4-7",
    max_tokens=1024,
    tools=[{
        "name": "shell",
        "description": "run a shell command",
        "input_schema": {"type": "object", "properties": {"command": {"type": "string"}}},
    }],
    messages=[{"role": "user", "content": "Clean up /var/log to free disk space."}],
)
# Claude proposes tool_use → Aegis pre-checks each one → destructive
# commands become text blocks explaining the deny. Allowed calls
# return through the normal anthropic SDK path.

Fail-closed by default

If the Aegis gateway is unreachable, every tool call is treated as a deny with reason aegis_unreachable_fail_closed. Letting unchecked tool calls through because the security plane was down defeats the point of the integration.

What you can verify offline

After any allowed (or denied) tool call:

  1. Pull the public key once: GET /receipts/key → ed25519 PEM
  2. Download an evidence bundle: GET /compliance/export/eu-ai-act?period_start=…&period_end=…
  3. Run aegis-verify --bundle bundle.json (the standalone CLI) — V1–V6 checks pass without any network call back to Aegis.

The same chain backs every SDK in the family (aegis-anthropic, aegis-openai, aegis-langchain).

Requirements

  • Python 3.10+
  • anthropic>=0.25 (install with pip install "aegis-anthropic[anthropic]" if you want it pulled in automatically)

See also

License

Apache 2.0.

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

aegis_anthropic-1.1.1.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

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

aegis_anthropic-1.1.1-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file aegis_anthropic-1.1.1.tar.gz.

File metadata

  • Download URL: aegis_anthropic-1.1.1.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for aegis_anthropic-1.1.1.tar.gz
Algorithm Hash digest
SHA256 c8da24e38279ebbc5d7ed8e55b0537d1d7ec39e136ed0afb1c6fb70a487884f0
MD5 e1c2cc6141f9626786c8a54e17c10038
BLAKE2b-256 cef9a1bb01a82ef66cc2693b8a0d76fc60cf2cfab91c9e7c18a72df2364cd8c4

See more details on using hashes here.

File details

Details for the file aegis_anthropic-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for aegis_anthropic-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1e75b22cdb6d48a10a546724bc1ec2b02119367fe63fe65650e78f3c487d9298
MD5 0224b15a11984700f9f523d86049b422
BLAKE2b-256 0f19ee761561dc1e3e2e896217e2f3cb1af39f9d48e23cf39b6a93df7f63a8bc

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