Skip to main content

LangChain governance middleware for Aegis ACP

Project description

aegis-langchain

Drop-in LangChain middleware that routes every tool invocation through Aegis's runtime governance pipeline before execution.

PyPI Python License

pip install aegis-langchain

What it does

Wraps a LangChain agent (AgentExecutor / Runnable) so every tool the agent decides to call is pre-checked by Aegis (POST /execute) before the tool actually runs. Blocked calls return a descriptive message back to the agent loop; allowed calls pass through unchanged.

Aegis decides what to block based on action semantics — the DROP TABLE, rm -rf, kubectl delete, external-PII-egress patterns in services/policy/policies/action_semantics_deny.rego. The deny is earned from the content of the action, not from a hardcoded "critical" tag on the agent. So a buyer flipping the agent's risk level can't accidentally bypass it.

Every check produces a signed audit row in the Aegis chain. Verify any of them offline with aegis-verify (the tools/aegis_verify/ CLI).

Three-line install

from aegis_langchain import AegisMiddleware

agent = AegisMiddleware(
    my_langchain_agent,
    api_key="acp_...",        # or AEGIS_API_KEY env var
    aegis_url="https://ha.aegisagent.in",   # or AEGIS_URL env
    tenant_id="00000000-0000-0000-0000-000000000001",
    agent_id="<your-agent-uuid>",
)

result = agent.invoke({"input": "analyze the customer table and clean up old rows"})
# Each tool invocation is pre-checked. Blocked tools return a message
# explaining the deny; the agent reasons over it like any other tool
# observation.

Works with any LangChain agent that uses tools (AgentExecutor, structured-chat agents, custom runnables that invoke tools via tool_call).

Fail-closed by default

If the Aegis gateway is unreachable, tool invocations return deny with reason aegis_unreachable_fail_closed. Letting unchecked calls through because the security plane was down defeats the integration's purpose.

What you can verify offline

After any allowed (or denied) tool call:

  1. GET /receipts/key — ed25519 PEM
  2. GET /compliance/export/eu-ai-act?period_start=…&period_end=… — signed bundle
  3. aegis-verify --bundle bundle.json — V1–V6 checks pass without any network call back to Aegis

Requirements

  • Python 3.10+
  • langchain-core>=0.1 (auto-pulled with pip install "aegis-langchain[langchain]")

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_langchain-1.1.1.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

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

aegis_langchain-1.1.1-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aegis_langchain-1.1.1.tar.gz
Algorithm Hash digest
SHA256 a9dc57815f3e322183eac83cfe768e21684c0900eda401c09e0c2b2901a1e0b9
MD5 558a95f128f94340fe2e16ecd1dcba60
BLAKE2b-256 48a94235cc99dc94d44adcde365da88ce35b5d2ff374dabc9282b66907692c6e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aegis_langchain-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 45b157f5e65b3fdddc0ca52dbe54a73a0d30bc106b266bcca2d21bf168fd6d6f
MD5 3e59732c89de84036c7a0aed6871e502
BLAKE2b-256 ddcef377b5e5b31f06a84a2874e86650942a09d45cab70572040a0e698b2efe3

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