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")
Release files for langchain-agentlattice 0.1.1
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_agentlattice-0.1.1.tar.gz | 5.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_agentlattice-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.0 kB
Release files / langchain_agentlattice-0.1.1.tar.gz
| Download URL | langchain_agentlattice-0.1.1.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d1d4aaed953caa860d00a3dafb03611b85ede7b0246d5567f4436d34aaed11e
|
|
BLAKE2b-256 checksum How to use checksums |
d7602b7ec34d8ba47cb19a0394138d06398c6e92ad5ea9709af896fc361868b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / langchain_agentlattice-0.1.1-py3-none-any.whl
| Download URL | langchain_agentlattice-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7cb14e900dfcb136ac4f6424a5613761d115cea9ef7f5fec4c007650cb711e72
|
|
BLAKE2b-256 checksum How to use checksums |
4fa458ae7e0888d78da7eb0985115a3e61ad2bef139aa73a57b6bf812017b2af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|