Skip to main content

HITL Fallback

Chapter 06 — ReAct Pattern & Human-in-the-Loop (Real-Time Web Reasoning)

6.1 ReAct Execution Flow

AFP implements a genuine Agentic ReAct (Reasoning + Acting) pattern — the system does not blindly retrieve-then-generate. It reasons about its own confidence, decides whether its knowledge is sufficient, and observes human authorization before accessing external resources such as live web search. This preserves human control while giving the system true autonomy for routine high-confidence queries.

Thought

The Retriever (Node 5) fetches chunks from Pinecone and computes a confidence score. The score falls below the 45% threshold, indicating the indexed documents do not contain a reliable, grounded answer to this specific query.

Action

Instead of hallucinating a low-confidence answer, the Agent pauses pipeline execution and surfaces a HITL prompt to the user: "I couldn't find an exact match in my verified documents. Would you like me to search the internet?"

Observation

The user replies: "Yes" — an explicit, affirmative authorization for the system to proceed with external web search. The user's intent is captured and stored in the LangGraph state.

Thought 2

On the next query cycle, the Intent & ReAct Router (Node 1) detects the affirmative response against the pending HITL state flag in the state object. Standard legal/finance routing is overridden.

Action 2

Node 6 (Tavily API) executes a live internet search. The retrieved web context flows into the Generation & Guardrails zone. Node 7 synthesizes a cited, grounded response using the web evidence. Node 8 performs hallucination verification before final output.

Activation PathTrigger ConditionNode Route
Low-Confidence HITL FallbackNode 5 confidence <45% AND user explicitly authorizes web searchNode 5 → HITL Pause → User Input (Node 0) → Node 1 detects affirmative → Node 6
Out-of-Scope Direct (OOS)Query classified as General Knowledge, Sports, or non-financial/legal topicNode 1 (ReAct/OOS edge) → Node 6 directly — no HITL pause required

Agentic Financial Parser v2.0 — Technical DocumentationPage 11