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.typein 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.3langchain-core >= 0.2
License
MIT — same as Aegis.
Release files for langchain-aegis 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langchain_aegis-0.1.0.tar.gz | 5.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_aegis-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.5 kB
Release files / langchain_aegis-0.1.0.tar.gz
| Download URL | langchain_aegis-0.1.0.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be48a85cec02390497441176547d124c54506e57e6d4e4ab66f108347ff94d5a
|
|
BLAKE2b-256 checksum How to use checksums |
cabcad3af6e02a934cb45bae93ec4394b4f29af61970d3fd7ed778e7cd606531
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / langchain_aegis-0.1.0-py3-none-any.whl
| Download URL | langchain_aegis-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
610db4e07dc1f5d54dbb98f0d9b2b247db6de28bef136a86be1787db765fc0cb
|
|
BLAKE2b-256 checksum How to use checksums |
d11451ffbfa74fabcbbcb0fd7f78018eb59d14c26c11e217dc6d470f35c212f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|