Agent Pipeline
How a question flows through AgentIQ's LangGraph agent, from routing decision to streamed, cited answer.
Architecture
User Query
Natural language question, 1–2000 characters
Router Node
GPT-4o-mini classifies the query as
retrieval, web_search, or direct — a single-word decision, no explanation.One of three paths, by route decision
FAISS Retrieval
Local vector search over ~30 AI/ML research documents, embedded with all-MiniLM-L6-v2. Top chunks by cosine similarity feed the generator as grounded context.
Tavily Web Search
Live web search for time-sensitive or current-events questions — news, recent releases, anything that changes over time.
Direct LLM
GPT-4o-mini answers conversational or general-knowledge questions directly from training data, no retrieval step.
Generator Node
Synthesises retrieved context (or answers directly, for the direct route) into a grounded response, citing sources inline by title. Direct-route answers skip this node and stream straight from the router's downstream LLM call.
Streamed Response
Server-Sent Events over POST /chat/stream — token chunks, then a sources list, then a done signal — rendered progressively in the chat UI.
Memory & Observability
Session Memory
A LangGraph
MemorySaver checkpoints every turn, keyed by session_id, giving each conversation full multi-turn history. It's process-local — memory resets if the API process restarts.Reference-only components
The backend repo also includes standalone Pinecone and LlamaIndex implementations (
retrieval/pinecone_store.py, retrieval/llamaindex_loader.py). Neither is wired into this graph — FAISS is the only vector backend the live agent queries.Technology Stack
| Component | Technology | Notes |
|---|---|---|
| Agent Orchestration | LangGraph | StateGraph with conditional routing edges |
| Router / Generator LLM | GPT-4o-mini | Classifies intent, then synthesises the cited answer |
| Embeddings | all-MiniLM-L6-v2 | sentence-transformers, used to build the FAISS index |
| Vector Store | FAISS | Local index over the research-paper corpus |
| Web Search | Tavily Search API | Live results for current-events queries |
| Memory | LangGraph MemorySaver | Process-local, keyed by session_id — multi-turn history per session |
| API | FastAPI | POST /chat (JSON) and POST /chat/stream (SSE) |