Call-owning middleware · PyPI 0.1.1 · Alpha · Apache-2.0

langchain-acgs for LangChain & LangGraph.

Package Specification · Inspected HEAD 94abeda

Framework maintainer
LangChain · langchain.com
Upstream repository
langchain-ai/langchain
PyPI release
langchain-acgs==0.1.1
Python requirement
>=3.10,<4.0
Framework constraint
langchain>=1.2.15,<2 · langgraph>=1.1.5,<2
Governance engine pin
acgs-lite>=3.0.1,<4
Integration mechanic
Call-owning middleware (wraps tool call)
Hook entry point
ACGSMiddleware.wrap_tool_call / awrap_tool_call

01 · Local Setup & Quickstart

Attach governance to one tool-calling agent.

Install the pinned release from PyPI alongside acgs-lite>=3.0.1,<4. Rule evaluation uses deterministic keyword and regex matching locally in Python—no external model or network call is made by the governance check.

Caveat: Covers tool calls routed through the configured AgentMiddleware; direct tool invocations outside the agent runner are not intercepted.

Shell · PyPI installation

Alpha
pip install "langchain-acgs==0.1.1"

Python · LangChain & LangGraph integration

langchain_acgs/middleware.py#L51
from langchain.agents import create_agent
from langgraph.checkpoint.memory import InMemorySaver
from langchain_acgs import ACGSMiddleware

agent = create_agent(
    model=model,
    tools=[send_email],
    middleware=[ACGSMiddleware()],
    checkpointer=InMemorySaver(),
)

02 · Verdict & Review Mapping

How ACGS-Lite verdicts map to LangChain & LangGraph.

When a tool call is proposed, the adapter formats the tool name and arguments via format_tool_call and evaluates them against the configured Constitution. Blocking rules always take precedence over review rules.

Verdict.ALLOW

Calls matching no blocking or review rules invoke the wrapped tool handler directly.

Verdict.DENY

Returns a ToolMessage with status='error' naming the violated rule without executing the tool.

Verdict.REVIEW

Pauses the graph run with a native LangGraph interrupt(ACGSReviewRequest) and resumes only on explicit approval.

03 · Public API Surface

Exported symbols and source entry points.

Each adapter keeps its public surface minimal and re-exports the shared GovernanceDecision, Verdict, and ToolCallFormatter types alongside the framework-specific hook or middleware class.

__all__ exports · langchain-acgs

langchain_acgs/middleware.py#L51 ↗
ACGSMiddlewareACGSReviewRequestGovernanceDecisionToolCallFormatterVerdictformat_tool_call

Primary hook surface: ACGSMiddleware.wrap_tool_call / awrap_tool_call. Custom ToolCallFormatter functions may be supplied if your tool arguments require custom canonical serialization before rule matching.

04 · Scope & Bypass Boundaries

What this adapter does and does not cover.

Verify these framework-specific boundaries when integrating langchain-acgs into an evaluation workflow.

  1. 01

    Async LangGraph interrupt resume (ainvoke / astream) requires Python 3.11+ and a configured LangGraph checkpointer.

  2. 02

    Only tool calls dispatched through create_agent with ACGSMiddleware attached are governed.

  3. 03

    Any malformed review resume payload or evaluation error fails closed and denies the tool call.

  4. 04

    In the current 0.1.x adapter series, rule evaluation runs through acgs-lite's ToolCallGovernor path. If your workflow requires SignedReceipt, ExecutionGrant, or SQLite EffectStore reservations, wire those contracts explicitly at the tool executor boundary.

Put one real workflow under your control.

Choose one tool. Define what it may do. Inspect what happens when a request crosses the boundary.