Skip to main content

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:

  1. Calls al.gate(action_type) before executing
  2. If approved → delegates to the wrapped tool's _arun() / _run()
  3. If denied → raises AgentLatticeDeniedError (tool does not execute)
  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_agentlattice-0.1.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

langchain_agentlattice-0.1.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file langchain_agentlattice-0.1.1.tar.gz.

File metadata

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

File hashes

Hashes for langchain_agentlattice-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0d1d4aaed953caa860d00a3dafb03611b85ede7b0246d5567f4436d34aaed11e
MD5 2ca89e0a7091482673b61d8fef3406c5
BLAKE2b-256 d7602b7ec34d8ba47cb19a0394138d06398c6e92ad5ea9709af896fc361868b6

See more details on using hashes here.

File details

Details for the file langchain_agentlattice-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_agentlattice-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7cb14e900dfcb136ac4f6424a5613761d115cea9ef7f5fec4c007650cb711e72
MD5 333f397f79ac3d6b38b2b633793659bb
BLAKE2b-256 4fa458ae7e0888d78da7eb0985115a3e61ad2bef139aa73a57b6bf812017b2af

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