Skip to content

LangGraph

LangGraph

Zero-code: auto.connect()

pip install xybern
export XYBERN_API_KEY=xb_live_…
import xybern
xybern.auto.connect()                  # discovers and registers your LangGraph agents, observe mode
xybern.auto.connect(mode="enforce")    # authorises every tool call before it runs

The SDK instruments LangGraph directly (xybern doctor shows exactly what is enforceable). Nothing else in your code changes.

Explicit guard

For finer control, authorise inside the tool itself with the explicit client. authorize() returns a Decision: execute only on allowed, wait() holds an escalated action until a human decides in the dashboard, and raise_for_decision() raises PolicyBlocked / PolicyEscalated / SessionTerminated.

from langgraph.graph import StateGraph
from xybern import Xybern, PolicyBlocked

xy = Xybern(agent_id="ops-agent")

def query_db_node(state):
    d = xy.authorize("query_database",
                     content=state["sql"],
                     context={"table": state.get("table"), "classification": "INTERNAL"})
    if d.escalated:
        d = d.wait(timeout=900)          # holds until a human approves in the dashboard
    d.raise_for_decision()               # raises PolicyBlocked / ApprovalRejected
    return {"rows": run_sql(state["sql"])}

graph = StateGraph(dict)
graph.add_node("query_db", query_db_node)

The REST payload underneath is documented in the Quick Start: action_type plus optional action_content, metadata, agent_id; decisions come back lowercase as allow, block, escalate or terminate.