← All writing

Agentic AI with LangChain, LangGraph & LlamaIndex: A Field Guide

By Venkata Subbaraju Dommaraju · Agentic AI · 11 min read

"LangChain, LangGraph, LlamaIndex" get name-dropped together as if they were one thing. They aren't — they solve different problems, and using the right one for the right job is most of what separates a demo from a production agentic service. Here's how I think about each, how they compose, and the agent-graph patterns I reach for, grounded in a multi-agent microservice I built and deployed.

LangChain — the glue layer

LangChain is the integration and abstraction layer: a common interface over LLMs, embeddings, vector stores, document loaders, retrievers and tools, plus the composition primitives (LCEL — the pipe `|` syntax) to chain them. Its strength is breadth — swap an OpenAI model for Bedrock, or FAISS for Elasticsearch, without rewriting your logic. Use it for the building blocks: model calls, prompt templates, output parsers, retrievers, and tool definitions.

  • Model & embedding wrappers — one interface across providers (OpenAI-compatible, Bedrock, local).
  • Retrievers & document loaders — the plumbing for RAG.
  • Tools & structured outputs — function-calling with Pydantic schemas for type-safe results.
  • LCEL chains — declarative `prompt | model | parser` pipelines.

LangGraph — control flow for agents

A linear chain breaks down the moment an agent needs to loop, branch, retry, or coordinate several specialists. LangGraph models the workflow as a stateful graph: nodes are functions that read and write a shared, typed state object; edges (including conditional edges) decide what runs next. That gives you cycles, branching, checkpointing and human-in-the-loop pauses — the things real agentic systems need. If LangChain is the vocabulary, LangGraph is the grammar.

  • Typed shared state (a Pydantic model or TypedDict) flows through every node.
  • Conditional edges express "if the critic isn't satisfied, revise" — a real loop, with a cap.
  • Checkpointing persists state, so a graph can pause for approval and resume.
  • Multi-agent: each node can be its own specialist agent with its own tools and prompt.

LlamaIndex — the data/RAG framework

LlamaIndex is purpose-built for the retrieval side: ingesting documents, building indexes (vector, keyword, knowledge-graph), and query engines with advanced retrieval (hybrid search, re-ranking, recursive/auto-retrieval). When the hard part of the problem is "answer accurately over a large, messy corpus," LlamaIndex's indexing and query abstractions often get you there faster than hand-rolling retrievers. It is the one to reach for when retrieval quality — not orchestration — is the bottleneck. (I know LlamaIndex from study and prototypes; in production I have used LangChain and LangGraph.)

How they fit together

They aren't competitors; they're layers. In a typical build: LlamaIndex (or a LangChain retriever) owns ingestion and retrieval, LangChain provides the model/tool/parser abstractions, and LangGraph orchestrates the agents and the control flow around them. A clean mental model:

  • LlamaIndex / retrievers → get the right context (the "what do I know?").
  • LangChain → call models and tools with that context (the "how do I act?").
  • LangGraph → decide what happens next and loop until done (the "what's the plan?").

The agent-graph pattern I reach for: planner → worker → critic

Most enterprise agentic tasks fit a small set of graph shapes. My default is a planner → worker → critic loop, which is exactly what powers the microservice below:

  • Planner — decomposes the request into steps and decides which tools/retrievers are needed.
  • Retriever — pulls grounded context from the vector store (Elasticsearch / FAISS / pgvector).
  • Worker / Analyst — does the reasoning and drafts the answer using the retrieved context.
  • Critic — checks the draft against the question and the evidence; if it's weak, the conditional edge routes back to the worker for one more pass (capped, so it always terminates).
  • Synthesizer — emits the final, type-safe (Pydantic) response with citations.

Other shapes worth knowing: a supervisor/router fanning out to parallel specialist agents (map-reduce over big data), and a reflexion loop where the agent critiques and improves its own output. LangGraph expresses all of these as nodes + conditional edges over shared state.

Making it production-grade

Frameworks get you to a working graph; engineering discipline gets you to a service you can run. The non-negotiables I build in from day one:

  • Pydantic everywhere — request, response, and the graph's state are typed and validated; no untyped dicts flying around.
  • FastAPI — the graph is exposed as a clean REST endpoint with health checks and streaming.
  • Observability — trace every node and tool call (LangSmith is the usual choice), and monitor latency, errors and token cost in production; I do that in CloudWatch.
  • Evaluation — Recall@K and MRR for retrieval and an LLM-as-judge for answers, run as pytest suites that gate every model, prompt and retriever change, so "better" is measured, not vibes.
  • Graceful degradation — an offline fallback so the service (and the demo) never hard-fails when a model is unavailable.

What this looks like in production

The production version of this pattern is the agentic AI application I designed and built at work, behind an assistant that handles search, eligibility decisions and Q&A across 12 sites:

  • Multi-agent orchestration with LangGraph and LangChain, and tool-calling agents on Anthropic Claude through AWS Bedrock.
  • Reusable typed, schema-validated tools (Pydantic, MCP) that connect the agents to REST APIs, SQL databases and enterprise systems.
  • An LLM integration layer over Bedrock and Azure OpenAI with retries, streaming and cost controls.
  • REST APIs in FastAPI with OAuth2/JWT role-based access, streaming agent tokens over SSE and WebSocket — time to first response went from several seconds to under one second.

The personal project I built to show it

That code is private, so I built a public one as a personal open-source project: an Agentic Microservice — a LangGraph planner → retriever → analyst → critic graph behind a FastAPI + Pydantic API, with pluggable retrieval (in-memory by default, Elasticsearch-ready), observability hooks for LangSmith, tests and a Dockerfile. It runs with zero config (offline fallback) and accepts any OpenAI-compatible LLM. It's open source and deployable — see the Projects section for the live demo and code.

Takeaway

Don't pick one framework and force everything through it. Use LlamaIndex/retrievers for retrieval, LangChain for model and tool abstractions, and LangGraph for the agentic control flow — then wrap the whole thing in Pydantic, FastAPI and real observability. That layered approach is exactly what enterprise teams are hiring agentic AI engineers to build in 2026.

Related projects

Contact

Open to full-time Senior AI / Data Engineer roles. Based in Downingtown, PA.

LinkedIn · GitHub · Résumé (PDF) · Book a call