Call-owning middleware · PyPI 0.1.1 · Alpha · Apache-2.0
langchain-acgs for LangChain & LangGraph.
Wraps sync and async LangChain tool execution and integrates with LangGraph interrupt flows when human review is required.
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.
Shell · PyPI installation
Alphapip install "langchain-acgs==0.1.1"Python · LangChain & LangGraph integration
langchain_acgs/middleware.py#L51from 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.
Calls matching no blocking or review rules invoke the wrapped tool handler directly.
Returns a ToolMessage with status='error' naming the violated rule without executing the tool.
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_callPrimary 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.
- 01
Async LangGraph interrupt resume (ainvoke / astream) requires Python 3.11+ and a configured LangGraph checkpointer.
- 02
Only tool calls dispatched through create_agent with ACGSMiddleware attached are governed.
- 03
Any malformed review resume payload or evaluation error fails closed and denies the tool call.
- 04
In the current
0.1.xadapter series, rule evaluation runs throughacgs-lite'sToolCallGovernorpath. If your workflow requiresSignedReceipt,ExecutionGrant, or SQLiteEffectStorereservations, 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.