AgentLattice governance wrapper for LangChain tools — gate() before every tool execution.
Project description
langchain-agentlattice
AgentLattice governance wrapper for LangChain tools. Gates every tool invocation through AgentLattice's audit trail, policy engine, and approval flow.
Install
pip install langchain-agentlattice
Quickstart
import os
from agentlattice import AgentLattice
from langchain_agentlattice import govern
from langchain_community.tools import DuckDuckGoSearchRun
al = AgentLattice(api_key=os.environ["AL_API_KEY"])
search = DuckDuckGoSearchRun()
# Wrap any LangChain tool — gate() runs before every invocation
governed_search = govern(search, al=al)
# Drop-in replacement — same name, description, interface
tools = [governed_search]
Handle denials:
from agentlattice import AgentLatticeDeniedError, AgentLatticeTimeoutError
try:
result = await governed_search._arun("latest AI news")
except AgentLatticeDeniedError as e:
print(f"Denied: {e.reason}, policy: {e.policy}")
except AgentLatticeTimeoutError as e:
print(f"Approval timed out: {e.approval_id}")
How it works
govern() wraps any BaseTool in a GovernedTool that:
- Calls
al.gate(action_type)before executing - If approved → delegates to the wrapped tool's
_arun()/_run() - If denied → raises
AgentLatticeDeniedError(tool does not execute) - If timed out → raises
AgentLatticeTimeoutError
This is a tool wrapper, not a callback handler. LangChain callbacks are notifications — they cannot block tool execution. Only the wrapper pattern preserves the gate() semantics.
Custom action types
# Default: "tool.{tool.name}"
governed = govern(my_tool, al=al)
# Override
governed = govern(my_tool, al=al, action_type="search.web.execute")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_agentlattice-0.1.0.tar.gz.
File metadata
- Download URL: langchain_agentlattice-0.1.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3cc9873a6f5596719fee381fb0da7f78b787861f299245e3523ca5d4a3c3963
|
|
| MD5 |
cbb3a34c49cd747eef960804d3d5041d
|
|
| BLAKE2b-256 |
17f6c961ef885c31a6c71240470a1114a57022e11de8c54efd022d7994e91d64
|
File details
Details for the file langchain_agentlattice-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_agentlattice-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb826e2919ef9717025d671e791dee88a40b4d6c8cd3c743fea8c9b5460fa6f9
|
|
| MD5 |
d6df94f58869e169753d6b4a16aed371
|
|
| BLAKE2b-256 |
90662e44f3f08e74198e55a87a936ffaa5c9c2cc8d2fb1d5da37f460b280c735
|