LangGraph Integration
Route LangGraph nodes through pyhall governance. Before a node executes a capability, ask Hall Server whether that capability is allowed for the current tenant and environment. If denied, the node raises before any work runs.
Install
pip install pyhall-wcp langchain-core langgraphThen start Hall Server:
pyhall hall startIntegration Pattern
import os, requests
HALL_URL = "http://localhost:8765"HALL_TOKEN = os.environ.get("HALL_SESSION_TOKEN", "")
def hall_route(capability_id: str, tenant_id: str = "your-org", **kwargs) -> dict: """Route a capability request through Hall Server governance.""" resp = requests.post(f"{HALL_URL}/api/route", headers={"Authorization": f"Bearer {HALL_TOKEN}"}, json={ "capability_id": capability_id, "env": "dev", "data_label": "PUBLIC", "tenant_id": tenant_id, **kwargs, }) resp.raise_for_status() return resp.json()
# In your LangGraph node:def governed_node(state): decision = hall_route("cap.doc.summarize", tenant_id="org.acme") if not decision.get("allowed"): raise PermissionError(f"Hall denied: {decision.get('deny_reason', 'policy violation')}") # proceed with node logic ...The allowed Field
Every response from /api/route includes:
allowed—trueif the capability is permitted under current policy,falseif blockeddeny_reason— human-readable reason whenallowedisfalse(e.g.,"risk_tier_exceeded","capability_not_enrolled")decision_id— UUID for audit trail correlationworker_id— the enrolled worker assigned to this capability
Always check allowed before proceeding. Never assume true on network error — fail closed.