Skip to main content

Router Reject

Chapter 03 โ€” Node-by-Node Breakdown

3.1 Entry & Routing Layer โ€” Nodes 0 to 3โ€‹

Node 0 โ€” User Inputโ€‹

The sole entry point into the LangGraph StateGraph. Every query โ€” including follow-up clarifications and HITL affirmative responses ("Yes, search the web") โ€” enters here. State is initialized and forwarded to Node 1.

  • Single, deterministic entry point โ€” no multi-path entry
  • Handles all query types: first-time queries, clarification rounds, HITL responses
  • Initializes full LangGraph state object passed through all downstream nodes

Node 1 โ€” Intent & ReAct Routerโ€‹

The brain of the routing layer. An LLM classifier analyses query intent and executes conditional edge dispatch. This is a diamond-shaped decision node โ€” it routes but does not retrieve or generate. Also detects HITL affirmative responses to override standard routing.

  • 5-way conditional routing: greeting / abusive / vague / legal-finance / ReAct-OOS
  • Detects affirmative HITL responses โ†’ overrides routing โ†’ triggers Node 6 directly
  • Classifies intent: abusive, greeting, vague, RAG-eligible, or out-of-scope
  • Determines search scope: System-only, User-only, or Hybrid namespace

Node 2 โ€” Greeting & Small Talkโ€‹

Handles casual greetings, pleasantries, and social queries without consuming any Vector DB or LLM generation resources. A lightweight response is returned and the path terminates at Final Output.

  • Zero vector database consumption
  • Zero LLM inference cost โ€” pre-crafted or rule-based response
  • Terminates directly at Final Output โ€” no downstream node activation

Node 3 โ€” Abusive / Reject Queryโ€‹

Intercepts and firmly blocks abusive, toxic, or harmful queries. Returns a structured rejection message and terminates the pipeline. No context retrieval, no LLM generation, no external API call.

  • Hard block on toxic inputs โ€” structured rejection response
  • No downstream node activation whatsoever
  • Terminates directly at Final Output โ€” same convergence path as Node 2

Agentic Financial Parser v2.0 โ€” Technical DocumentationPage 4

3.2 Retrieval Layer โ€” Nodes 4 to 6โ€‹

Node 4 โ€” Cross-Questioning (LLM Clarifier)โ€‹

Activated when the router classifies a query as vague or under-specified. An LLM generates targeted follow-up questions to elicit sufficient context before retrieval. Maximum 2 clarification rounds; after that, retrieval is forced with available context.

  • Triggered for vague/ambiguous queries โ€” prevents low-precision retrieval
  • LLM-powered targeted questioning โ€” not generic "please clarify"
  • Maximum 2 clarification rounds to prevent infinite loops
  • After clarification, routes to retrieved-context zone (Node 5 path)

Node 5 โ€” Pinecone Retrieval (MRL 256d)โ€‹

The primary semantic retrieval engine. Executes high-precision cosine similarity search against Pinecone Serverless using Jina v3 Matryoshka Representation Learning embeddings at 256 dimensions. Calculates a confidence score for retrieved chunks and routes accordingly.

  • Jina v3 MRL: 1024d โ†’ 256d โ€” 75% storage reduction, ~95% accuracy retained
  • Pinecone Serverless with dual-namespace support: System docs + User uploads
  • Confidence gating: score <45% triggers HITL pause instead of generation
  • High-confidence retrieval routes directly to Generation & Guardrails zone

Node 6 โ€” Web Search / ReAct Fallback (Tavily API)โ€‹

Activated via two distinct paths: (1) Direct OOS routing from Node 1 for General Knowledge / Sports queries; (2) HITL-authorized fallback when Node 5 confidence is below 45% and the user has explicitly approved web search. Live data is fetched via the Tavily Search API โ€” this is the component that gives AFP genuine real-time web reasoning beyond its own indexed documents.

  • Dual activation: OOS direct path OR HITL-authorized low-confidence fallback
  • Requires explicit user authorization for financial query web fallback โ€” not automatic
  • Tavily API fetches real-time web data โ€” not cached results
  • Retrieved web context flows into Generation & Guardrails zone โ€” same as Node 5

Agentic Financial Parser v2.0 โ€” Technical DocumentationPage 5

3.3 Generation & Guardrails โ€” Nodes 7 to 9โ€‹

Node 7 โ€” LLM Generationโ€‹

Synthesizes the final answer using verified retrieved context โ€” either from Pinecone (Node 5) or Tavily web search (Node 6). Enforces strict professional formatting, citation requirements, and scope constraints. Does not generate beyond what the retrieved context supports.

  • Context-bound generation โ€” refuses to answer beyond retrieved evidence
  • Enforces professional formatting: structure, citations, scope markers
  • Receives context from both Pinecone and Tavily paths through unified context node
  • Output feeds directly and unconditionally into Hallucination Guard (Node 8)

Node 8 โ€” Hallucination Guardโ€‹

A secondary LLM-as-judge verification pass. Compares the generated answer against the retrieved source context to assess grounding. Acts as a decision diamond: grounded responses proceed to Final Output; ungrounded responses are routed to Node 9 for reformulation and retry.

  • LLM-as-judge architecture โ€” not rule-based pattern matching
  • Binary grounding decision: grounded โ†’ Final Output, not grounded โ†’ Node 9
  • Flags unverified claims without halting the pipeline (non-blocking)
  • Evaluation-only node โ€” no retrieval, no generation

Node 9 โ€” ReAct Fallback Promptโ€‹

Receives responses that failed grounding verification in Node 8. Applies explicit grounding constraints and reformulates the generation prompt with stricter context-adherence instructions, then retries. The retried output routes directly to Final Output.

  • Triggered only when Node 8 returns "not grounded"
  • Reformulates with explicit grounding constraints โ€” not a simple retry
  • Retry output terminates at Final Output โ€” no second Hallucination Guard pass
  • Final barrier preventing hallucinated answers from reaching the user

Final Output โ€” Grounded ยท Cited ยท Safe

Convergence node for all terminal paths โ€” Nodes 2, 3, 4, 7, and 9. Every response reaching this node has been verified against source context (grounded), traced to a document or web result (cited), and passed through PII masking and hallucination verification (safe).

Agentic Financial Parser v2.0 โ€” Technical DocumentationPage 6