Skip to main content

Aegis governance integration for LangChain — add policy enforcement, risk assessment, and audit logging to any LangChain tool.

Project description

langchain-aegis

Aegis governance integration for LangChain. Add policy enforcement to any LangChain tool with one function call.

Installation

pip install langchain-aegis

Quick Start

from langchain_aegis import govern_tools

# Wrap your existing tools — no other code changes needed
governed = govern_tools(tools, policy="policy.yaml")
agent = create_react_agent(model, governed)

What It Does

langchain-aegis evaluates every tool call against an Aegis YAML policy before execution. Blocked actions return a governance message instead of running.

Tool call → Aegis policy check → allowed? → execute
                                  blocked? → return "[BLOCKED by Aegis] ..."

Policy Example

# policy.yaml
version: "1"
defaults:
  risk_level: medium
  approval: auto
rules:
  - name: allow_reads
    match:
      type: "read_*"
    risk_level: low
    approval: auto

  - name: block_deletes
    match:
      type: "delete_*"
    risk_level: critical
    approval: block

API

govern_tool(tool, policy)

Wrap a single tool:

from langchain_aegis import govern_tool

governed_search = govern_tool(search_tool, policy="policy.yaml")
result = governed_search.invoke({"query": "AI governance"})

govern_tools(tools, policy)

Wrap multiple tools with the same policy:

from langchain_aegis import govern_tools

governed = govern_tools(
    [search_tool, calculator_tool, delete_tool],
    policy="policy.yaml",
)

Policy as object

from aegis import Policy

policy = Policy.from_yaml("policy.yaml")
governed = govern_tools(tools, policy=policy)

How It Works

  • Tool name maps to Action.type in Aegis policy matching
  • Tool input parameters map to Action.params
  • Glob patterns in policy rules match tool names (delete_*, *)
  • First matching rule wins — same as Aegis core
  • Supports sync and async tool execution

Requirements

  • Python 3.11+
  • agent-aegis >= 0.1.3
  • langchain-core >= 0.2

License

MIT — same as Aegis.

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

langchain_aegis-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

langchain_aegis-0.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file langchain_aegis-0.1.0.tar.gz.

File metadata

  • Download URL: langchain_aegis-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for langchain_aegis-0.1.0.tar.gz
Algorithm Hash digest
SHA256 be48a85cec02390497441176547d124c54506e57e6d4e4ab66f108347ff94d5a
MD5 bb49155b1228a8444964d98fc704caf9
BLAKE2b-256 cabcad3af6e02a934cb45bae93ec4394b4f29af61970d3fd7ed778e7cd606531

See more details on using hashes here.

File details

Details for the file langchain_aegis-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_aegis-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 610db4e07dc1f5d54dbb98f0d9b2b247db6de28bef136a86be1787db765fc0cb
MD5 d18664347de79eff3980f2babcb38c0f
BLAKE2b-256 d11451ffbfa74fabcbbcb0fd7f78018eb59d14c26c11e217dc6d470f35c212f5

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