langGraph (Agentic workflow in langGraph)

Navneet KumarNavneet Kumar
4 min read

Using the library to build stateful, multi-actor applications with large language models (LLMs).

So ye ho hamari deffison and ab ham baat karte ye hota kay hai or RAG se bhi hamara kaam ho raha hia tha to kay need padhi hamko vase kay

🧠 What is LangGraph?

LangGraph ek powerful library hai jo aapko stateful, multi-actor applications banane mein help karti hai β€” especially jab aap Large Language Models (LLMs) ke saath kaam kar rahe hote ho.

Yeh ek aise system ko design karne mein use hoti hai jahan multiple steps aur conditions involved ho, aur sab kuch ek graph structure ke through represent kiya jata hai. Har step ko ek Node aur har flow ko ek Edge ke through define kiya jata hai.

πŸ€” Why did LangGraph come into the picture?

Pehle jab hum LangChain + RAG (Retrieval Augmented Generation) use karte the, to kaam kuch aise hota tha:

plaintextCopyEditLoad Documents β†’ Split Text β†’ Vector Store β†’ Search β†’ Query LLM β†’ Return Answer

Yeh approach linear hoti thi β€” matlab sab kuch ek seedhe pipeline mein chalta tha. Jaise hi complexity badhti thi:

  • Memory usage badh jata tha

  • Redundant steps run hote the

  • Flexibility kam ho jati thi

  • Har baar pura chain traverse karna padta tha

Is problem ka solution hai β€” LangGraph.

⚑ LangGraph vs LangChain (Linear vs Graph)

FeatureLangChain (Linear)LangGraph (Graph-based)
FlowLinear pipelineDynamic Graph flow
EfficiencyHigh memory/time for big flowsMore optimized & scalable
FlexibilityLowHigh (can branch, loop, merge logic)
Use-caseSimple workflowsComplex, stateful, branching workflows

πŸ” LangGraph Flow (Example Diagram)

javaCopyEditπŸ§‘ User Input 
   ↓
🟦 Entry Node (Start)
   ↓
πŸ€– Agent Node (LLM Decision)
   ↓
β”œβ”€β”€ πŸ”§ Tool Node (e.g., Calculator)
β”œβ”€β”€ πŸ“š Retrieval Node (Vector DB, Memory)
β”œβ”€β”€ 🧠 Function Node (Python logic, Tools)
└── ❓ Conditional Node (Branching decisions)
   ↓
πŸ’¬ Response Node (Final Output)

🧠 Why Do We Need LangGraph?

LangGraph ki zarurat tab padti hai jab hume complex, dynamic, aur multi-step AI workflows ko banana aur control karna hota hai β€” especially jab hum LLMs (Large Language Models) ke saath kaam kar rahe ho.


πŸ” Problem with Traditional Approaches (e.g., LangChain + RAG)

Traditional linear approaches ka structure kuch is tarah hota hai:

mathematicaCopyEditLoad Document β†’ Split β†’ Vector Search β†’ Query LLM β†’ Return Answer

❌ Issues:

  • Har query ke liye same steps follow hote hain (chahe zarurat ho ya na ho).

  • Memory aur computation kaafi zyada lagta hai.

  • Har function fixed order mein run hota hai β†’ flexibility nahi hoti.

  • Har situation ke liye same LLM use hota hai β†’ cost badh jata hai.


βœ… Solution: LangGraph

LangGraph ek graph-based architecture provide karta hai, jismein har step ek node hota hai, aur unke beech edges define karte hain ki agla step kya hoga β€” completely dynamic and condition-based flow.


πŸ“Œ Use-Case Example (Multi-Model Agent)

Maan lo hum ek aisa AI Agent bana rahe hain jo har input ke type ke basis par alag action leta hai:

  • Agar coding question pucha jaye β†’ use GPT-4.1 (paid, accurate)

  • Agar general knowledge ka question ho β†’ use GPT-mini (free)

  • Agar real-time info chahiye β†’ call Web Search tool

  • Agar past memory recall karni ho β†’ use Vector DB retrieval

LangGraph ka use yahan pe:

  • Har condition ke liye ek separate node

  • Har node ke decision ke liye dynamic branching

  • Har step ke beech context pass hone ke liye stateful architecture

  • LangGraph ki zaroorat isliye hoti hai kyunki yeh ek advanced approach hai jo graph structure ka use karke complex workflows ko manage karta hai. Jab hum LangChain ya RAG jaise linear workflows ka use karte hain, toh woh zyada memory, space, aur time consume karte hain. LangGraph is problem ko solve karta hai kyunki yeh ek graph-based approach hai jismein multiple actors aur stateful applications ko efficiently handle kiya ja sakta hai. Isse hum har point par dekh sakte hain ki kaunsa tool ya function use ho raha hai, aur yeh zyada flexible aur scalable solution provide karta hai.

Main compount in LangGraph

ComponentPurpose

Node

Ek logical step (e.g., tool, LLM, function call)

Edge

Decision ya connection between two nodes

State

Memory/context jo poore flow mein pass hota hai

Multi-actor

Alag-alag tasks ko parallel ya conditional tarike se handle kar sakna

πŸš€ Agentic Workflow in LangGraph (Text-based Graph View)

pgsqlCopyEdit+---------------------+
|     πŸ§‘ User Input    |
+---------------------+
           |
           β–Ό
+---------------------+
|   πŸ€– Agent Node      |   <== (LLM decides based on query + state)
+---------------------+
     |       |       |
     |       |       |
     |       |       |
     β–Ό       β–Ό       β–Ό
+------------+  +----------------+  +------------------+
|  Code Tool |  | WebSearch Tool |  |   GPT-mini Model |
|  (Executor)|  |   (Real-time)  |  |  (Casual reply)  |
+------------+  +----------------+  +------------------+
     |                |                  |
     |                |                  |
     β–Ό                β–Ό                  β–Ό
+-----------------------------------------------+
|           πŸ’¬ Response Node (Final Output)      |
+-----------------------------------------------+

so aage class mai padhuga to likhuga aa kar

0
Subscribe to my newsletter

Read articles from Navneet Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Navneet Kumar
Navneet Kumar