What is LangChain? How it works and how to evaluate it

Build agents
HoneyHive Engineering

LangChain is an open-source framework for building agents and LLM apps. Its create_agent runs a model-and-tools loop on LangGraph, with middleware to control it.

LangChain is an open-source framework for building agents and LLM-powered applications. Its README describes it as “a framework for building agents and LLM-powered applications” (GitHub). Its main entry point is create_agent, which the docs call “a minimal, highly configurable agent harness” (overview).

What LangChain gives you

The docs define an agent as “a model calling tools in a loop until a given task is complete” (agents). For more on that idea, see what AI agents are. LangChain supplies the pieces around that loop:

Piece What the docs say
Models A standard interface that “supports OpenAI, Anthropic, Google, and more,” so you can switch models with minimal code changes (overview). Pass a provider:model string or a model instance (agents).
Tools The functions the model calls inside the loop (agents).
Structured output response_format= returns a validated schema, read from result["structured_response"] (agents).
State and memory State is a typed dictionary of the conversation and custom fields. Persisting by thread_id needs a checkpointer (agents).
Middleware Hooks before and after model calls and tool execution (middleware).

Middleware is how you shape the loop. The docs name summarization, human-in-the-loop approval, PII detection, tool retries, model fallbacks, model call limits and LLM tool selection as examples (middleware). They describe retry middleware as handling failures “so your tools and business logic don’t need try/catch around every call” (agents).

How LangChain relates to LangGraph and Deep Agents

LangChain’s agents run on LangGraph, which supplies durable execution, human-in-the-loop support and persistence (overview). The docs position the three layers like this:

Layer Use it for (overview)
LangChain A standard agent with create_agent, extended through middleware
LangGraph “Advanced needs combining deterministic and agentic workflows”
Deep Agents A batteries-included harness with context compression, a virtual filesystem and subagents, “built on LangChain agents, which you can also use directly”

If a tool-calling loop with middleware covers your case, start with LangChain. If you need to control the flow yourself, drop to LangGraph. Other options exist, such as CrewAI, Pydantic AI and the OpenAI Agents SDK.

What changed in v1

Anyone following older tutorials will hit these changes, all from the v1 migration guide:

  • langchain.agents.create_agent is now the recommended function and replaces create_react_agent from langgraph.prebuilt. The prompt parameter became system_prompt.
  • Legacy chains, retrievers, the indexing API and the hub module moved to langchain-classic. Install it and update imports if you use them.
  • The langchain namespace was “significantly reduced in v1 to focus on essential building blocks for agents”: agents, messages, tools, chat_models and embeddings.
  • All LangChain packages require Python 3.10 or higher.
  • Messages gain provider-agnostic content blocks through message.content_blocks, while message.content is unchanged.

How to test a LangChain agent

The testing guide splits tests in two (testing):

  • Unit tests “exercise small, deterministic pieces of your agent in isolation using in-memory fakes.” You mock chat models and use in-memory persistence, so no API calls are needed.
  • Integration tests use real network calls and real LLM APIs to confirm components work together.

The same guide says to “evaluate agent trajectories with deterministic matching or LLM-as-judge evaluators.” A trajectory is the sequence of messages and tool calls a run made. For a broader method, see how to evaluate AI agents.

Tracing a LangChain app in HoneyHive

Because an agent is a loop of model and tool calls, a final answer can look fine while the run behind it looped or called the wrong tool. A trace shows each step. See what agent observability is.

HoneyHive traces LangChain with the OpenInference LangChainInstrumentor, so existing code runs unchanged. It captures agent runs, LLM calls with token usage, tool calls with arguments and results, and chain operations such as LCEL pipes. The integration page lists langchain 1.2.15 as tested as of April 2026, with 1.0.0 as the minimum, and requires Python 3.11 or later (integration docs):

from honeyhive import HoneyHiveTracer
from openinference.instrumentation.langchain import LangChainInstrumentor

tracer = HoneyHiveTracer.init()  # Reads HH_INGESTION_API_KEY from your environment
LangChainInstrumentor().instrument(tracer_provider=tracer.provider)

Setup details, a single-agent example and a multi-agent routing example are on the HoneyHive LangChain integration page.

FAQ

Is LangChain free?

Yes. The repository is MIT licensed (GitHub).

What is the difference between LangChain and LangGraph?

LangChain's agents are "built on top of LangGraph," which the docs call "our low-level orchestration framework, for advanced needs combining deterministic and agentic workflows" (overview). See LangGraph.

What happened to the old LangChain chains?

In v1 legacy chains, retrievers, the indexing API and the hub module moved to the langchain-classic package, and the langchain namespace was cut down to agent building blocks (v1 migration guide).

Which Python version does LangChain need?

The v1 migration guide says "All LangChain packages now require Python 3.10 or higher" (migration guide). HoneyHive's integration requires Python 3.11 or later (integration docs).

Share