How LangChain agents work: Deep Agents, MCP, Bedrock and agentic memory

How LangChain agents work and how to build one, LangChain Deep Agents, LangChain vs MCP, using Bedrock models, retrieval as a tool, and agentic memory.

On the mic
On the mic

Key takeaways

  • A LangChain agent runs a model in a loop: the model picks a tool, LangChain runs it, the result goes back, until the model answers.
  • Modern LangChain builds agents on LangGraph; give it a model, tools and a system prompt.
  • Deep Agents add planning, sub-agents and a file system for long, multi-step tasks.
  • LangChain is a framework for building apps; MCP is a protocol for connecting tools; LangChain can use MCP servers through adapters.
  • Instead of old retrieval chains, expose your retriever as a tool the agent can call.

A LangChain agent is a language model running in a loop with tools: the model decides which tool to call, LangChain executes it, the result goes back to the model, and the loop continues until the model gives a final answer. Modern LangChain builds agents on LangGraph, which manages state and control flow. This page explains how agents work and how to build one, what Deep Agents are, LangChain versus MCP and how they combine, using AWS Bedrock models, upgrading old retrieval chains to tools, and what agentic approaches and agentic memory mean.

How do LangChain agents work?

A LangChain agent gives a model a system prompt and a set of tools with names, descriptions and input schemas. On each step, the model either requests a tool call or answers; LangChain runs requested tools, appends the results to the conversation, and calls the model again.

Also asked as: how langchain agents work · how to build langchain agents

This is the ReAct pattern: reason, act, observe, repeat. LangGraph underneath tracks the state, the message history and any custom fields, and lets you add limits, human approval steps, persistence so conversations resume later, and streaming of intermediate steps. The quality of an agent depends mostly on tool descriptions, instructions and the model's tool-calling ability, not on the framework. Keep tools few and well described.

How do I build a LangChain agent?

Define tools as Python functions with docstrings, choose a chat model that supports tool calling, and create an agent with LangChain's agent constructor, then invoke it with a user message.

from langchain.agents import create_agent
from langchain_core.tools import tool

@tool
def room_for(course: str) -> str:
    """Return the classroom for a course code such as BCA301."""
    return {"BCA301": "Room 4"}.get(course.upper(), "Unknown course")

agent = create_agent(model="anthropic:claude-sonnet-5-5", tools=[room_for],
                     system_prompt="Answer timetable questions using tools. Say so if unsure.")
out = agent.invoke({"messages": [{"role": "user", "content": "Where is BCA301?"}]})
print(out["messages"][-1].content)

APIs evolve between versions, so check the current LangChain docs for the exact constructor and model identifiers.

What are LangChain Deep Agents?

Deep Agents is LangChain's approach for agents that handle long, complex tasks. It adds a planning tool for keeping a to-do list, sub-agents for delegating focused work, a virtual file system for notes and intermediate results, and a detailed system prompt.

The idea comes from how capable coding and research agents work: they plan, break work into parts, write things down instead of keeping everything in context, and delegate. Deep Agents packages these patterns on top of LangGraph so you can build, for example, a research agent that searches, saves findings to files and writes a report. They cost more tokens than simple agents, so use them when tasks genuinely need many steps.

What is the difference between LangChain and MCP?

LangChain is a framework for building LLM applications and agents in code. MCP, the Model Context Protocol, is an open protocol for exposing tools, data and prompts to any AI application. They solve different problems and work together.

With LangChain you write your application: prompts, chains, agents, retrieval and state. With MCP you package tools as servers that any MCP-compatible client can use, such as Claude, IDE agents or your own LangChain agent. If you build a tool once as an MCP server, it works across many apps; if you build it only as a LangChain tool, it works in LangChain. Many teams use LangChain for app logic and MCP for shareable tools.

Does LangChain support MCP?

Yes. The LangChain MCP adapters package lets LangChain and LangGraph agents load tools from MCP servers and use them like native tools.

Also asked as: langchain vs mcp

The typical flow: start a client for one or more MCP servers, such as a database or GitHub server, load their tools through the adapter, and pass them to your agent. The agent then sees tool names and descriptions from the servers and can call them. Because MCP tools may perform real actions, apply the same care as with any tool: least privilege, trusted servers, and human approval for destructive operations. Check the adapter's README for current usage.

Can I use LangChain agents with AWS Bedrock models?

Yes. LangChain's AWS integration provides chat model classes for Amazon Bedrock, so you can use Bedrock-hosted models, including Anthropic's Claude models and others, in LangChain agents, as long as the model supports tool calling.

Also asked as: can i use the langchain agents with the models provided in aws bedrock

Set up AWS credentials with permission to invoke the models, enable model access in the Bedrock console for your region, install the LangChain AWS package, and create the chat model with the Bedrock model ID. Then pass it to your agent constructor as usual. Bedrock suits organisations already on AWS for billing, data residency and security controls. Test tool calling with your chosen model, since capabilities differ between models.

How do I combine retrieval chains, agents and tools in LangChain?

Wrap your retriever as a tool and give it to the agent, instead of using older built-in retrieval chain classes. The agent then decides when to search your documents, alongside other tools such as calculators or APIs.

Also asked as: how to combine conversationalretrievalqachain, agents, and tools in langchain

For example, create a tool search_handbook(query) that queries your vector store and returns the top passages with IDs and page numbers. The agent calls it when a question needs documents and cites the passages in its answer. Conversation memory comes from the agent's message state and persistence, not a special chain. This design is clearer and more flexible than legacy chains, and it lets you add a confidence rule, such as declining when no passage scores well, which RAG.NextUpgrad applies before answering.

What is the agentic approach?

The agentic approach means designing AI systems that pursue goals through multiple steps, using tools and checking results, instead of producing a single response to a single prompt.

Also asked as: what is agentic approach

It suits tasks with uncertain paths, such as research, debugging, or resolving a support issue across systems. It is not always better: for predictable tasks, a fixed workflow is cheaper, faster and more reliable. A practical middle ground is a mostly deterministic workflow with a few agentic steps where judgement is needed. Whatever the design, add limits, logs and evaluation, because agentic systems fail in more varied ways than single calls.

What are agentic agents?

"Agentic agents" is a redundant phrase usually meaning AI agents with real autonomy: systems that plan, take actions with tools and adapt based on results, as opposed to simple chatbots that only reply.

The term is used loosely in marketing. When evaluating a product described as agentic, ask concrete questions: which tools can it use, what can it change, when does it ask for approval, how are its actions logged, and how is it evaluated. Those answers matter more than the label. For learning, build a small agent yourself with two tools and a step limit; it teaches more than any definition.

What is A-MEM, agentic memory for LLM agents?

A-MEM is a research approach to memory for LLM agents in which the agent organises its own memories: it writes structured notes about experiences, links related notes, and updates older memories as new information arrives, inspired by note-taking systems.

Also asked as: a-mem: agentic memory for llm agents explained

The motivation is that simple memory, such as storing chat history or embedding past messages, retrieves poorly over long periods. Agentic memory lets the model decide what to store, how to tag and connect it, and when to revise it. For builders, the practical lessons are to store memories as structured, retrievable notes with metadata, to link related items, and to let memories be corrected. Evaluate memory systems on whether they improve later task performance, not just on how much they store.

Sources

  1. LangChain, documentationpython.langchain.com
  2. LangGraph, documentationlangchain-ai.github.io
  3. LangChain, MCP adapters repositorygithub.com
  4. Model Context Protocol, documentationmodelcontextprotocol.io
  5. Yao et al., ReAct: Synergizing Reasoning and Acting in Language Models (2022)arxiv.org
Pranjul Rathour
Pranjul Rathour
GenAI Engineer · India

GenAI engineer and AI product builder with 2+ years shipping production-grade AI systems: RAG pipelines, fine-tuned LLMs, hybrid retrieval and multi-modal apps across vision, speech and OCR, architected end to end from ingestion to deployment. Leads engineering for SCULT INDIA's 14-member team, founded the 500+ member TechVerse Enclave community and has mentored 200+ students. Three hackathon first prizes: Changethon 2025 (IIT Roorkee), Product Genesis at Vividhotsava 2025 (CSJMU) and BYTEBATTLE (MeetKats).

Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges. For campus sessions the inviting institution covers the visit end to end: travel (a First AC train ticket for journeys up to five hours, a flight for anything longer), accommodation, meals, and pickup and drop; the honorarium and workshop fees are negotiable on WhatsApp or on the call, and requests are welcome from institutions that can cover the visit this way. Email pranjulrathour41@gmail.com.

Keep reading

More on RAG & retrieval

All RAG & retrieval guides →
Campus talks · hackathon judging · mentoring

Want this as a live session at your college?

Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges. For campus sessions the inviting institution covers the visit end to end: travel (a First AC train ticket for journeys up to five hours, a flight for anything longer), accommodation, meals, and pickup and drop; the honorarium and workshop fees are negotiable on WhatsApp or on the call, and requests are welcome from institutions that can cover the visit this way.

Pranjul Rathour, GenAI engineer in India