Human in the loop for LangGraph.
LangGraph's interrupt pauses a graph until someone on your side answers. When nobody on your team is free to watch the queue, or the call needs an outside view, add a node that sends the judgment call to ID verified people instead and routes on their consensus: act when it's unanimous, escalate when it isn't.
pip install langgraph pluresHow it works
- 1
Add an ask_humans node
It sends one clear question, the material to judge and two to eight options. plures.verify waits for the answer; use create_task and a webhook if your graph shouldn't block.
- 2
Route on agreement
Plures returns the answer and how strongly people agreed, from 0 to 1. A unanimous answer goes straight to the action node.
- 3
Escalate the rest
A split or an expired task goes to your own team. Those are the genuinely hard cases, and they're rare.
The code
Runs as is with a free pk_test_ key, which answers instantly without reaching people.
from typing import Optional, TypedDict
from langgraph.graph import END, START, StateGraph
from plures import Plures
plures = Plures() # reads PLURES_API_KEY
class State(TypedDict):
message: str
order_total: float
answer: Optional[str]
agreement: float
outcome: str
def ask_humans(state: State) -> dict:
task = plures.verify(
"Should this customer get a full refund?",
["Yes", "No"],
context="Order total: $%.2f\nCustomer: %s" % (state["order_total"], state["message"]),
verifiers=3,
timeout=600,
)
result = task.get("result") or {}
return {"answer": result.get("answer"), "agreement": result.get("agreement", 0)}
def route(state: State) -> str:
if state["agreement"] >= 1:
return "refund" if state["answer"] == "Yes" else "decline"
return "escalate"
graph = StateGraph(State)
graph.add_node("ask_humans", ask_humans)
graph.add_node("refund", lambda s: {"outcome": "Refunded $%.2f" % s["order_total"]})
graph.add_node("decline", lambda s: {"outcome": "Declined, with a note to the customer"})
graph.add_node("escalate", lambda s: {"outcome": "Sent to the support team"})
graph.add_edge(START, "ask_humans")
graph.add_conditional_edges("ask_humans", route, ["refund", "decline", "escalate"])
for node in ("refund", "decline", "escalate"):
graph.add_edge(node, END)
app = graph.compile()Prefer LangGraph's own interrupt for decisions your team must make? Send those with route: "team": Plures puts them in your team's Decisions app and Slack, and your graph resumes on the webhook.
What your agent gets back
The answer, how strongly people agreed from 0 to 1, and each vote. Act on a unanimous answer; send anything less to your team.
{
"status": "completed",
"result": {
"answer": "Yes",
"label": "Yes",
"agreement": 1,
"answers": 3,
"votes": { "Yes": 3, "No": 0 }
}
}Questions
How is this different from LangGraph's interrupt?
interrupt pauses the graph until a person on your side resumes it, so someone has to be watching. Plures sends the question to several ID verified people who answer independently, returns their consensus and agreement, and only escalates to your team when they split.
Does it block the graph?
plures.verify waits up to the timeout you set. For long waits, create the task with a webhook_url and resume the thread when the task.completed event arrives.
How do I start?
Get a free API key at plures.si. Test keys (pk_test_) answer instantly without reaching people, so you can build the whole flow first. Then send your own team up to 50 decisions a month for free, and add credit when you want ID verified people on the rest.
Other integrations
Product names and logos are trademarks of their owners, shown only to name the tools these pages are about.