IntegrationsMulti-Agent Graphs

LangGraph Multi-Agent Security

Protect stateful LangGraph workflows with SecureGraphNode. Enforce node-level permissions, correlate task traces, and implement human-in-the-loop state branching.

Overview & Multi-Agent State

In complex LangGraph graphs, individual nodes frequently represent different specialized agents (e.g. researcher, summarizer, executor). SecureGraphNode guarantees that each node only executes within its authorized security boundary.

Terminal
pip install "sictack>=1.0.0"
pip install "langgraph>=0.0.10"

SecureGraphNode Implementation

Wrap standard LangGraph node functions. The node intercepts execution and injects cryptographic trace IDs and status markers:

langgraph_node_demo.py
from sictack import SecureAgent, Config, Policy
from sictack.integrations.langgraph import SecureGraphNode

# 1. Define multi-agent policy
policy = Policy(
    name="langgraph-multi-agent-policy",
    allowed_permissions=["analyze_sentiment", "extract_entities"],
    denied_permissions=["publish_tweet"],
    require_approval_permissions=["post_external_review"],
)

# 2. Initialize SecureAgent
agent = SecureAgent(
    agent_id="graph-analyst",
    permissions=["analyze_sentiment", "extract_entities", "publish_tweet", "post_external_review"],
    config=Config(default_policy=policy),
)

# 3. Define standard LangGraph state handler
def sentiment_node(state: dict) -> dict:
    text = state.get("text", "")
    return {"sentiment": "POSITIVE", "length": len(text)}

# 4. Wrap with SecureGraphNode
secure_sentiment = SecureGraphNode(
    name="analyze_sentiment",
    func=sentiment_node,
    agent=agent,
    permission="analyze_sentiment",
)

# Execute node with graph state
state = {"text": "Zero-trust architecture for AI workflows"}
output_state = secure_sentiment(state)
print("Output:", output_state)
# -> Output: {'sentiment': 'POSITIVE', 'length': 41, 'trace_id': '...', '_sictack_status': 'APPROVED'}

Using @secure_langgraph_node Decorator

Use the convenience decorator for clean, declarative node registration:

decorator_demo.py
from sictack.integrations.langgraph import secure_langgraph_node

@secure_langgraph_node(
    name="extract_entities",
    agent=agent,
    permission="extract_entities",
)
def entity_node(state: dict) -> dict:
    return {"entities": ["SICTACK", "FastAPI"]}

result = entity_node({"text": "sample text"})
print(result["_sictack_status"])
# -> APPROVED

Multi-Agent Delegation State Propagation

In supervisor-worker LangGraph architectures, the supervisor issues a delegation token that flows through graph state. SecureGraphNode inspects _delegation_token in the incoming state to enforce mathematical capability intersection:

langgraph_delegation_flow.py
from sictack.unified import Sictack
from sictack.integrations.langgraph import SecureGraphNode

security = Sictack(signing_key="production-secret")

# 1. Supervisor issues cryptographic delegation token
supervisor_token = security.delegate(
    parent_agent_id="supervisor-agent",
    child_agent_id="worker-analyst",
    allowed_capabilities=["analyze_sentiment"],
    allocated_budget=10,
)

# 2. Worker node wraps handler with Sictack security enforcement
def analyze_node(state: dict) -> dict:
    return {"insights": "Positive sentiment detected across 50 records"}

secure_worker_node = SecureGraphNode(
    name="worker_analysis",
    func=analyze_node,
    security=security,
    permission="analyze_sentiment",
)

# 3. Node extracts delegation token from graph state dictionary automatically
graph_state = {
    "text": "Market research batch 12",
    "_delegation_token": supervisor_token,
    "_agent_id": "worker-analyst",
}
output_state = secure_worker_node(graph_state)
print("Status:", output_state["_sictack_status"])  # dual-key: output_state["_intentlock_status"] also emitted
# -> APPROVED

Human-in-the-Loop State Branching

Unlike simple script execution where approvals crash or block synchronously, LangGraph workflows require state preservation. When a node triggers require_approval, SecureGraphNode returns a branched state dictionary rather than raising an unhandled exception:

branching_flow.py
def review_node(state: dict) -> dict:
    return {"reviewed": True, "feedback": "Ready for publication"}

secure_review = SecureGraphNode(
    name="post_external_review",
    func=review_node,
    agent=agent,
    permission="post_external_review",  # Requires human authorization
)

# Calling the node branches state gracefully without throwing an exception
pending_state = secure_review({"text": "Release draft v2"})

print("Status:", pending_state["_sictack_status"])
# -> Status: REQUIRE_APPROVAL

print("Pending Node:", pending_state["_pending_node"])
# -> Pending Node: post_external_review

print("Approval ID:", pending_state["_approval_id"])
# -> Approval ID: eba5b6a9-92d5-44ee-8fa9-...
LangGraph Conditional Routing

You can connect conditional edges in your LangGraph StateGraph using state["_sictack_status"] (or legacy state["_intentlock_status"]) to route pending actions directly to a human notification or review queue.

Fail-Closed Configuration

By default, fail_closed=True raises a PermissionDeniedError when a prohibited tool is requested. If you prefer to handle denials as a state branch, configure fail_closed=False to return _sictack_status = "DENIED" in the output state.