Human in the Loop
How an agent run stops for a person, what it shows them, what they can answer, how that answer is governed, and where the exchange is recorded.
Three ways a run pauses
All three are LangGraph interrupt() calls in svc-ai. All three resume with the same payload ({approved, feedback, answers}), so one resume path serves them.
| Pause | Raised by | When | source |
|---|---|---|---|
| Mid-task question | __clarify__ system node, asked by the ask_user tool | When the agent (or a skill node with ask_user: true) needs something only the person knows — once a turn, never on a revision (see below) | tool |
| Approval | a skill node's approval gate, or the __hitl__ node | Before a gated node runs, or before the final answer | — |
Every question is asked in __clarify__ (20 October 2026). Scope clarification and ask_user produce the same clarification_request payload, the same form and the same pause. They differ in when they ask:
Scope clarification is decided up front, in triage's one structured call (the
__gate__node), so it costs no extra model call. With the check on, triage usesScopedTriageProfile, which addsscope_is_ambiguous,ambiguity_reasonand up to fourclarifying_questions. Triage also reads the recent conversation, so it does not re-ask what the user already said. Triage never pauses itself. A resume replays the paused node, and its model call is not deterministic. Instead it parks the validated questions inGraphState.pending_clarification, and__clarify__(which makes no model call) asks them. A failed triage asks nothing (scope_checkunavailable): until October 2026__recon__then asked a model again, and its guessed form asked for a PDF's file name.The scope check never asks (
_SCOPE_CHECK_GUIDANCE, every agent):what to name a file or title a document;
for something because the knowledge bases do not hold it — the agent can search the web;
which items to include when the request leaves the set open ("different climbing knots") — the agent chooses a representative set and says so.
A
multiquestion marks recommended every option the agent would include by default. The climbing-knots form recommended one knot; the person accepted it, and the PDF had one.ask_useris a GENERAL tool bound to every tools-enabled agent. It does not pause itself: it raisesClarificationRequested(aGraphBubbleUp, soToolNodepasses it up) with the questions. The tool loop attaches the step's trace so far, the skill node ends the step with the questions inpending_clarification, the steps after it wait (a skill node with a pending question returns at once), and_synthesis_routersends the run to__clarify__before synthesis or the evaluator can read a half-done answer. Once answered,_clarify_routersends atoolclarification back to the skill graph's start node: the step runs again with the answers in its request and its earlier tool calls in<prior_tool_calls>, so it does not repeat them.Why. The tool used to call
interrupt()inside the agent's step, and the skill node'sexcept Exceptioncaught theGraphInterruptas a failure ("agent: GraphInterrupt"): no mid-task question ever reached a person. CHAINR Bot's 11-option question, refused instead, ended up as questions written into its answer, which the quality check passed. The skill node now re-raises anyGraphBubbleUp, so no pause is swallowed.
After __clarify__ is answered, the answers are appended to state.input as a <clarified_scope> block. Planning, retrieval, every skill node, synthesis and the evaluator all work to the chosen scope, and none of them needs to know a clarification happened. A skip is honoured, not re-asked: the block tells the agent to proceed on its best reading and state its assumptions.
Memory is the one reader that does not take the block (18 October 2026). The turn's episode and its recall use the request as sent (GraphState.request_before_clarification) plus the answers as [clarified: …] (clarify.answer_labels: option labels, free text verbatim), and extraction never sees the answers. Every clarified episode used to store the block's scaffolding as if the person had written it, and an earlier clarified episode about something else came back for every later clarified request. svc-ai migration 29 strips it from stored episodes. See Memory.
GATE → RECON ──(scope ambiguous)──▶ CLARIFY ⏸ ──▶ PLANNING / SYNTHESIS …
└──(clear)────────────────────────▶ PLANNING / SYNTHESIS …
… SKILL STEP ──(ask_user)──▶ CLARIFY ⏸ ──▶ SKILL STEP again (answers, earlier calls)
The __clarify__ node is in every graph; only the up-front scope check depends on the builder's clarify_scope. Its <clarified_scope> block says which kind of question it was ("Before any work started…" or "While working on this request you asked…"), and each clarifications entry records its source.
The form
ClarifyQuestion (svc-ai app/tools/clarify.py, mirrored in fe-core objects/Hitl.ts):
| Field | Meaning |
|---|---|
options[].recommended | The agent's suggested default. At most one on a single question. Rendered first, with a Recommended badge |
allow_other | Adds an Other free-text choice to a single/multi question (default on) |
required | Must be answered unless the whole form is skipped |
placeholder, multiline | Hints for form fields |
Several text/number/date questions together are an input form; there is no separate form type. ask_user allows 6 questions of up to 10 options (both stated in its description); a scope check allows 4.
Model output at a boundary. Every proposed question is checked: ids unique and non-empty, choice kinds with 2–10 unique options, field kinds with none, and at most one recommendation on a radio question. The same checks run for both sources (usable_questions), one question at a time:
too many choices are cut to 10, keeping the recommended ones, with Other left on;
a question that fails is left out, not the set;
questions past the cap are left out.
An ask_user call with nothing left to ask returns the reasons to the model, which can retry, and is told never to write the questions in its answer. A scope check with nothing left carries on without asking: it is an aid, never a gate. validate_questions stays the strict check for what is stored and resumed.
Questions never ship as an answer. The ask_user description and CHAINR Bot's instructions say questions for the person go in the form, never the reply. A draft that asks the person questions in its text instead of doing the task is a quality-check gap, and the revision decides and states its assumption.
When an agent may ask, and what (20 October 2026)
The next live run asked well up front ("which illusions, how many, with images?"), rendered a PDF with three of ten images missing, and was failed by the quality check — which added "since the agent can ask the user, it should have asked whether to substitute other images" (the <can_ask> cue above had invited it). The revision asked the person to pick image links for it, with a written-out "Other (specify)" option it recommended; the person picked that, and every answer came back as the word "other". Asking the person to find what they had asked for is never theirs to do. So:
Once a turn, whoever asks.
AgentGraphBuilder._may_ask: no step asks once the scope check or a step has asked this turn.Never on a revision (
eval_retry_count > 0): what the quality check found missing is the agent's to fix.Not allowed means not offered. The skill node runs its agent inside
clarify.asking_allowed(_may_ask(state)), and the tool loop (BaseAgent.run_with_tools) leavesask_userout of the tools it binds and runs whereverclarify.may_ask()is false — which is everywhere outside a skill step (the default). A refused call had left the model writing "I've asked you to provide…" to someone never asked;NOT_NOWis only a backstop. Anode.ask_usernode is given the tool and its "ask before any other work" line only when it may ask.Only what the person alone can answer. The tool's description and CHAINR Bot's instructions: what they want, which meaning, a detail of their own — never to find, choose or fix what they asked for (a file, an image, a link, a source, a failed search). A question whose choices are web links is refused (
_question_problem), and a written-out "Other" option ("Other", "Other (specify)", "Something else: …") is dropped for the form's own box, which is turned on (_without_written_other).Never what is settled, never a pick among what it found (28 October 2026). Given a fully specified offsite request (times, £60 a head, lunch), the first capabilities scenario run's agent researched venues and asked "Do you want to include catering?" and which of two rooms it had found to use. The description now says: never ask what the request or the conversation already says, and never ask the person to choose among things you found (venues, rooms, products, options) — choose one, and say why. This is the model's instruction only: unlike links, such a choice cannot be told apart in code.
The quality check never sends the agent to ask.
<can_ask>is gone from its input;NODE_EVALUATORsays a gap is what the answer lacks, for the agent to fix with its own tools, and never tells it to ask the person or have them supply anything. The revision note says the person cannot be asked during a revision.
The clarify stage's trace line says which it was: "scope clarification: N answer(s)" or "clarification: N answer(s)".
Who can turn it on
Agents —
agents.clarify_scope(migration 71), shown as Human in the loop → Ask clarifying questions before starting on the agent page. New agents default to on, including generated agents and the CHAINR Bot. Agents that existed before migration 71 default to off, so an upgrade changes no live agent's behaviour or evaluation baselines.Callers — only callers with a person to answer set
clarify_scopeon the svc-ai spec (AgentConfig.clarify_scope,SkillSpec.clarify_scope):the chat websocket forwards the agent's setting on both the agent and the skill path;
an evaluation forwards it too, because it asks what the agent does in chat. The questions become the graded answer (expected behaviour
clarify);a dashboard tile that borrows the agent (
target.attribute(...)) never does. It has nobody to answer.
Nobody to answer at all (21 October 2026): a tile also sends
ExecuteRequest.may_ask = false(AgentTarget.attended,agent_spec.AgentRequest.payload(may_ask=…)). svc-ai's builder then never offersask_user(AgentGraphBuilder._may_ask) and never runs the scope check, on the batch path and the stream (graph_based._may_ask). A tile had been offeredask_usermid-task, and its question was cached as the tile's answer; one that asks anyway now fails its refresh with "make the prompt self-contained". Chat, the batch prompt and evaluations send nothing, so they may ask as before.
Governance
A pause is two boundary crossings, and both are governed (svc-core app/services/hitl.py, shared by chat and standalone skill runs):
| Crossing | Rules | Effect |
|---|---|---|
| Answers → model | Access and Input (hitl.govern_answer) | redact_pii redacts every answer value (the record notes redacted); block ends the turn as blocked, still through the ordinary persist so the spend before the pause is ledgered, and svc-ai's checkpoint is discarded |
Answers are validated server-side (hitl.validate_response). The client form checks too, but it is never trusted to have done so. Required questions must be answered unless the whole set is skipped, a radio question gets exactly one answer, and options must come from the list unless Other was offered. Numbers must be finite and dates must be YYYY-MM-DD. No answer may be longer than 4,000 characters. In chat, a refused answer comes back as a hitl_invalid frame ({message, fields}) and the pause stays open. The form stays on screen, disabled while the answer is checked, so a refusal does not lose what was typed.
Time spent waiting for a person is excluded from the turn's invocation_latency_ms, so latency routing never sees it. The model calls on either side of a pause are metered and ledgered as one turn.
Where it is recorded
In the trace
| Frame | From | Carries |
|---|---|---|
hitl_resume | svc-core, on answer | node_id, outcome, answers / approved + feedback, answered_at, answered_by, waited_ms, redacted |
outcome is answered, skipped, approved, rejected, blocked or abandoned (the chat closed while waiting, or the person pressed Stop; reason_closed says which). An abandoned pause still gets a hitl_resume, so no stored trace shows a pause still waiting. Closing the page ends a turn only at a pause: anywhere else it runs on to its end and is stored (see docs/system/services/core.md#a-turn-outlives-the-page).
In fe-core, attachHitl (util/traceUtils.ts) folds both frames onto the execution that paused — __clarify__ for every question, the gated node for an approval — for the live pipeline and stored traces alike. The paused execution never gets a node_end, because the node replays as a new attempt after the answer. So the pause decides that attempt's state:
awaiting: an amber stage with a pulsing hand, captioned waiting for you, kept in view on the rail;once answered, the attempt is
done, and the stage keeps a Human input badge and a caption of you answered / you approved / you skipped. Its card opens on aHumanInputRecordshowing the questions, the answers by label (with recommended when the person took the suggestion), the outcome and how long it waited.
On the message
The assistant message stores every exchange of the turn on meta.hitl (hitl.exchange). Each exchange keeps the questions as shown, not just the answers, because ["eu"] means nothing to an auditor without the options it was chosen from. The chat transcript shows each exchange above the answer it shaped. Stored answers are the redacted ones, so the record never holds more than the model was given.
On a skill run
A standalone skill run pauses to awaiting_input and is answered from its page. It uses the same validation and governance (runner.validate_response wraps hitl.validate_response) and records answers on SkillRun.responses. See Skills.
Known limits
A mid-task question costs the step again. Once answered, the asking step runs from the start with the answers. Its tool calls are listed for it, not replayed, and web search results are cached for ten minutes, but its model calls are paid again.
Paused state lives in svc-ai's memory (
MemorySaver). Restarting svc-ai makes a pause unresumable. A skill run is then refused, never silently restarted. A chat turn is abandoned when its socket closes, and the chat has no way to re-attach to a pause after a page reload.Only a pause keeps its checkpoint. The checkpoint thread is the conversation id, shared by every turn of the conversation. svc-ai evicts it when a run finishes, fails, is rejected or is stopped (Stop, or the stream closed at a frame), on the stream and batch paths and on resumes; a paused run's is kept so it can resume. A stopped turn's checkpoint used to seed the next turn with what it had retrieved and cited (
tests/inference/test_stopped_turn.py). A fresh turn on a thread with a pending pause still merges into the paused checkpoint; svc-core discards an abandoned pause (discard_paused_run).A resumed answer's sources include those from before the pause. The resume is a new stream, which saw only what came after it, so an answer citing a passage retrieved before an
ask_userpause stored no sources. The resumed stream now starts its list from the checkpoint's completed nodes (graph_based._citations_before_pause).LangGraph 1.x reports a streamed interrupt as a chunk, not an exception.
_stream_graphwatches for the__interrupt__chunk and re-raises it. Before that, every chat pause (ask_userand approvals alike) was reported as an emptydoneand its checkpoint evicted.tests/inference/test_stream_interrupt.pystreams a real compiled graph so a LangGraph upgrade that changes this again fails there.Resume rebuilds the graph through its engine.
POST /agents/execute/stream/resumeacceptsagentas well asskillandgraph, and rebuilds agent and skill runs with the engine's own_build_builder(_rebuild_paused_graph). It had accepted onlyskill/graph, so a plain agent's pause could never be resumed (a 422), and a skill was rebuilt by hand without its spec's settings.
Code map
| Concern | svc-ai | svc-core | fe-core |
|---|---|---|---|
| Scope check | ScopedResourceStrategy, _scope_clarification, _create_clarify_node_fn in agents/graph.py | Agent.clarify_scope, chat spec, evaluation/targets.py | agent page → Human in the loop |
| Mid-task question | ClarificationRequested, asking_allowed, usable_questions in tools/clarify.py; the skill node's handler, _synthesis_router, _clarify_router, _may_ask in agents/graph.py; may_ask in the tool loop (agents/base.py) | — | the clarify stage |
| Stream / pause frame | hitl_pause_frame, _stream_graph in inference/engines/graph_based.py | _on_hitl_interrupt in router/app/agents/router.py | Chat.tsx |
| Resume | POST /agents/execute/stream/resume, _rebuild_paused_graph | resume loop in the chat websocket | ClarifyForm, approval panel |
| Record | — | hitl.exchange, resume_trace_frame, meta.hitl | HumanInputRecord, StageCard, StageRail |