FailLoud Playground / Guides

How do I verify a LangGraph agent's output before the next step trusts it?

Short answer

Put a verification node between the worker nodes. FailLoud — a deterministic verification harness for LLM agent outputs — checks the previous step's output document (claimed actions vs evidence, counts vs the itemized record, state freshness, placeholder payloads) and the graph routes on the verdict: pass and the next node runs; fail and the graph goes to repair or stops, instead of building on a claim nothing proved. No LLM in the verdict path, so the gate itself cannot be talked into a pass.

Why LangGraph agents need the gate between nodes

A LangGraph run is a chain of trust handovers: each node reads the state the previous node wrote and treats its claims as facts. When a node reports "emails sent: 12" while its own itemized record lists 9 — or claims a publish action with no URL anywhere in the output — every downstream node inherits the lie, and the final answer reports it with confidence. LangChain and LangGraph give you the graph; they do not check whether a node's output is true. That check is a separate, deterministic step, and it belongs in the graph, not in a dashboard after the run.

The guard-node pattern

from failloud import check_output

class BlockedStep(RuntimeError):
    pass

def verify_step(state):
    """Guard node: verify the last worker output before anything trusts it."""
    result = check_output(state["last_output"])
    if not result.passed:
        raise BlockedStep(result.verdict)   # or route to a repair node
    return {"verified": True}

Wire it as a node after every worker whose output the next step will act on, or once before the final-answer node. The runnable version — a two-step simulated graph where the guard catches a count mismatch and an unbacked claim — is in the repository at examples/langgraph_gate. For raw LangChain runnables and callbacks, FailLoud also ships a LangChain adapter (failloud.adapters.langchain) that normalizes agent results into the same checked document shape.

What the gate catches in a graph

CheckIn a LangGraph run, that is…
FL002 unbacked_claimA node claiming it sent/posted/published with no id, URL, or receipt in its output.
FL004 count_mismatchThe "sent 12" summary the next node quotes, contradicted by the node's own item list.
FL003 stale_stateA planner node working from a state snapshot older than the run allows.
FL001 placeholder_shippedA writer node returning template text the formatter node then ships as final.