LangGraph composes and routes primitive components. Design the components first (LLM chains, tools, agents, memory) and then use LangGraph to connect and orchestrate them.

- LLMChain: a prompt template paired with an LLM; returns generated text for inputs.
- Tools: Python functions (or connectors) wrapped with metadata so agents or orchestrators can call them safely.
- Agents: decision-makers that inspect inputs, choose tools/LLMChains, and orchestrate steps.
- Memory: state that preserves prior messages or facts to support multi-step interactions.

Below we break each primitive down and explain how it maps into LangGraph nodes, with short examples and recommended patterns.
LLMChain
The LLMChain is the foundation for most language-centric flows. It wraps a prompt template and an LLM, accepts inputs, and returns generated outputs. In LangGraph, an LLMChain typically becomes a node that you call whenever language generation is needed. Key properties:- Stateless by default: processes inputs and returns outputs without persistent state.
- Can be paired with Memory when you need context across invocations.
- Typical uses: summarization, rephrasing, query rewrite, content generation, prompt-based classification, and intermediate reasoning steps.
LLMChain into a node that accepts text and outputs summary. Add Memory to the node only when the model must refer to prior exchanges.

Tools
Tools expose external functionality (search, compute, REST calls, DB access) to agents or to deterministic nodes. Conceptually they are Python functions enriched with metadata (name, description, arg schema) so orchestration layers and agents can call them safely and explainably. Common tool types:SearchTool: queries a search index or engine.MathTool: evaluates expressions.APITool: calls REST APIs.- DB connectors, file readers, and other I/O utilities.
- Call tools directly from nodes when the workflow is deterministic.
- Let an agent pick the appropriate tool dynamically for open-ended tasks.
- Route execution conditionally based on tool outputs.


Agents
Agents are higher-order actors that make decisions: they inspect inputs, select tools or LLMChains, and orchestrate multi-step strategies to reach a goal. In LangChain, agents often run loops (think of a planner that uses tools iteratively). In LangGraph, agents can either be single nodes encapsulating that logic, or you can implement agent-like behavior explicitly with multiple nodes and edges (intent classification → tool selection → iterative steps). When to use an agent vs. explicit routing:- Use an agent when the task is open-ended, requires dynamic tool selection, or benefits from iterative reasoning.
- Use explicit nodes and edges when the control flow is well-known and you need stronger observability, reproducibility, and testability.
Memory
Memory provides context across node invocations—storing conversation history, user state, or facts for retrieval-augmented flows. Add Memory to an LLMChain or agent when the model must consider prior interactions. Common memory patterns:- Short-term conversational memory (recent messages window).
- Long-term memory for user profiles or persistent facts.
- Retrieval-augmented memory that uses a vector database to fetch relevant past context.
Putting it together
Every LangGraph node maps to one of these primitives or a small composition of them. Design the primitives deliberately to make graphs easier to build and maintain. Recommended design workflow:- Define prompts and LLMChains for core transformations.
- Implement tools with clear schemas for inputs/outputs.
- Decide where agents are necessary versus explicit routing via edges.
- Add memory selectively where context continuity is required.
- Compose nodes into LangGraph graphs, using edges for routing, retries, and conditional logic.
Agents can execute tools that have side effects (API calls, DB writes). Always model and test tool behavior, and apply safety checks or sandboxing where necessary.
- LangChain course (KodeKloud)
- Kubernetes Documentation
- Vector Database for GenAI (KodeKloud)
- Fundamentals of RAG (KodeKloud)