review verdict → your on_review callback suspends the run (interrupt()) → your transport renders a review event to the user → the user approves → the run resumes with the cached verdict → the callback returns allow and the tool proceeds.
The judge decides what needs a human; you own how the human answers. The middleware deliberately ships no transport — the same verdict round-trips through SSE, WebSocket, or an approval queue. This guide shows the full LangGraph + SSE wiring.
When to use it
Wire HITL when areview verdict should stop the agent in a user-facing harness — the recruiter sees why, and decides. Skip it for background/batch judging: the default on_review (soft-allow + tenet_review metadata marker) keeps the run moving while your audit trail records the flag. Don’t confuse the two — without an interrupt()-based callback, nothing pauses.
Requirements
- A checkpointer.
interrupt()persists graph state and raises; resume replays from the checkpoint. In-memory checkpointers lose paused turns on restart — don’t ship one to multi-worker production. - A stable
thread_id. The resume request must carry the samethread_idas the paused turn, or LangGraph starts a fresh thread and the pause is orphaned.
The callbacks
interrupt() is the only side effect. Rendering, alternatives generation, and anything async belongs in the streaming layer that catches the interrupt.
What you can read at interrupt time
The callback’sJudgeContext carries the phase, tool, and — in streaming mode — fields the middleware folds onto ctx.metadata from the judge’s SSE body:
What the user sees
A review pause from start to finish. A recruiting agent receives “Can you find candidates who graduated after 2020?” (a graduation-year age proxy):
A review interrupt rendered in a recruiting agent: the judge's display_message, app-generated lawful rewrites, and the approve path.
- “paused” — the
on_reviewcallback calledinterrupt(); the graph is checkpointed, awaiting resume. - The flagged-for-review copy —
display_messagefromRiskLabelDisplay, rendered verbatim (here the guaranteed-non-empty generic fallback). - The rewrite suggestions — app-side lawful alternatives carried in the event’s
extras; the SDK ships the pause, the app owns the rewrites. - “continue anyway” — the
proceedchoice. On resume the callback returnsJudgeAction.allow(), and withturn_approval=Truethe approved risk labels don’t re-prompt this turn. - “I’ll flag it on the result” — Tenet’s verdict trace holds the verdict, not the reviewer’s decision. Record the approval in your own logs next to
decision_id.
Rendering the review over SSE
format_review_event(verdict, ...) builds a ReviewEvent — a transport-ready record with user-facing copy, operator detail, and default UI choices. The middleware never calls it; your app does, wherever it converts the interrupt payload into wire frames:
type/action—tenet_review(approve or cancel) vs.tenet_block(dismiss-only). Your frontend branches on this: reviews get a “Continue anyway” path, blocks don’t.display_message— guaranteed non-empty, compliance-safe copy built from the risk labels. Show it verbatim.risk_labels— raw engine codes (EEO-AGE-PROXY-01) for telemetry and filtering; not for end users.choices— default review choices areproceed/reject; blocks getdismissonly. Override per-app.extras— free-form dict for app-side additions (e.g., LLM-generated lawful rewrites as suggestion chips — kept app-side so the SDK ships no LLM dependency).
Translating risk labels for humans
RiskLabelDisplay is the single source of the code → topic vocabulary, so your UI never re-derives (and drifts from) the compliance language:
format_review_event(display=...) accepts the same instance.
Resume semantics
The middleware caches the judge response before dispatching your callback —interrupt() raises a GraphInterrupt straight through the tool boundary, and on the resume pass the cached verdict is reused instead of re-judging. You pay one judge call per human decision, not two.
With turn_approval=True, an approved review does double duty: the middleware records what was approved — the verdict’s rule_ids, or its risk_labels when no finding carries a rule id — and any later call in the same turn whose identifiers are a subset auto-allows (tenet_turn_approved: True in the action metadata). One “Continue anyway” covers the follow-up tool calls it implies, instead of re-prompting the user per call. A later verdict carrying neither rule_ids nor risk_labels always re-prompts, so an approval can’t cover a finding the reviewer never saw.
On the resume request itself: route it to the same agent with the same thread_id, passing the resume value LangGraph expects (Command(resume=...)).
LangGraph treats falsy resume payloads (
{}, None, []) as “no resume queued” — interrupt() fires again instead of returning. If your UI’s approve action carries no data, coerce the resume value to something truthy (e.g. True) before resuming.Gotchas
- No checkpointer, no HITL. Without one,
interrupt()has nowhere to persist the paused state. This is the first thing to check when resume “starts over.” - Approve ≠ policy change. A resume approves this decision (and, with
turn_approval, its subset repeats this turn). The same request in a new turn judges fresh. - Don’t put async work in the callback. Alternatives generation, DB writes, notifications — all of it belongs after the interrupt surfaces in your streaming layer, where you’re in an async context and a failure can fail open (cosmetics) without weakening the gate.