Agents (in LangChain)
A LangChain agent is an LLM that decides its own actions — it picks tools, calls them, reads the results, and loops until the task is done. This is where LangChain's pieces come together: model + tools + memory + retrievers, wrapped in a loop. It's also where the API has changed: the modern way is create_agent, which runs on LangGraph.
💡 In one line: A LangChain agent is an LLM that chooses and calls tools in a loop — built with
create_agent, running on LangGraph.
What is a LangChain Agent?
Unlike a chain (a fixed sequence you define), an agent decides at runtime which tools to call and in what order, looping until it can answer. Chain = you decide the steps; agent = the model decides.
The Modern API: create_agent
create_agent(model, tools) is the current standard. Under the hood it builds a LangGraph graph — so you get state, persistence, and streaming for free. The legacy AgentExecutor and the old initialize_agent helpers are superseded; if you're starting fresh in 2026, use create_agent (or drop to LangGraph directly for full control).
The Agent Graph
Under the hood, the agent is a small graph: a model node that decides, a tool node that executes, and a conditional edge that loops back or finishes.
The Agent Loop (ReAct)
ReAct is the paradigm behind most LangChain agents — the model reasons, then acts.
Code Example
That single call wires together model, tools, and memory — the pieces from the previous subtopics.
Bringing the Pieces Together
- Tools — what the agent can do.
- Memory — the checkpointer (thread) and store (long-term).
- Retrievers — wrap as a tool for agentic RAG.
- Model — the brain that decides.
create_agent vs. LangGraph
create_agent— a prebuilt agent loop. Fastest path; covers most cases.- LangGraph directly — define your own nodes, edges, and state. Use it when you need custom control flow, branching, human-in-the-loop, or multi-agent structures.
Rule of thumb: start with create_agent; drop to LangGraph when you need explicit control.
Production Concerns
- Observability — LangSmith traces each step as a span; it's the fastest way to see why an agent did something.
- Guardrails — cap steps, add human-in-the-loop approval for risky actions.
- Persistence — a durable checkpointer so runs survive restarts.
Best Practices
- Keep the toolset small with clear descriptions.
- Cap iterations to prevent runaway loops.
- Use a durable checkpointer and trace with LangSmith.
- Start simple — a chain may be enough; use an agent only when the path is unknown upfront.
A Note on Currency
In 2026, create_agent is the standard API and runs on LangGraph internally; AgentExecutor is legacy. Given the pace of change, check docs.langchain.com before building.
Summary
- A LangChain agent lets the model decide which tools to call, in a loop.
create_agent(model, tools)is the modern API — built on LangGraph.- The agent is a graph: model node → tool node → loop or END (the ReAct pattern).
- It unites tools, memory (checkpointer/store), and retrievers.
- Use
create_agentfor speed; drop to LangGraph for custom control, and trace with LangSmith. EOF echo created