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

> 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.

Source: https://www.honeyhive.ai/learn/langchain-framework (updated 2026-11-02)

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](https://github.com/langchain-ai/langchain)). Its main entry point is `create_agent`, which the docs call "a minimal, highly configurable agent harness" ([overview](https://docs.langchain.com/oss/python/langchain/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](https://docs.langchain.com/oss/python/langchain/agents)). For more on that idea, see [what AI agents are](/learn/what-are-ai-agents). 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](https://docs.langchain.com/oss/python/langchain/overview)). Pass a `provider:model` string or a model instance ([agents](https://docs.langchain.com/oss/python/langchain/agents)). |
| Tools | The functions the model calls inside the loop ([agents](https://docs.langchain.com/oss/python/langchain/agents)). |
| Structured output | `response_format=` returns a validated schema, read from `result["structured_response"]` ([agents](https://docs.langchain.com/oss/python/langchain/agents)). |
| State and memory | State is a typed dictionary of the conversation and custom fields. Persisting by `thread_id` needs a checkpointer ([agents](https://docs.langchain.com/oss/python/langchain/agents)). |
| Middleware | Hooks before and after model calls and tool execution ([middleware](https://docs.langchain.com/oss/python/langchain/middleware/overview)). |

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](https://docs.langchain.com/oss/python/langchain/middleware/overview)). They describe retry middleware as handling failures "so your tools and business logic don't need try/catch around every call" ([agents](https://docs.langchain.com/oss/python/langchain/agents)).

## How LangChain relates to LangGraph and Deep Agents

LangChain's agents run on [LangGraph](/learn/langgraph-framework), which supplies durable execution, human-in-the-loop support and persistence ([overview](https://docs.langchain.com/oss/python/langchain/overview)). The docs position the three layers like this:

| Layer | Use it for ([overview](https://docs.langchain.com/oss/python/langchain/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](/learn/crewai-framework), [Pydantic AI](/learn/pydantic-ai-framework) and the [OpenAI Agents SDK](/learn/openai-agents-sdk-framework).

## What changed in v1

Anyone following older tutorials will hit these changes, all from the [v1 migration guide](https://docs.langchain.com/oss/python/migrate/langchain-v1):

- `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](https://docs.langchain.com/oss/python/langchain/test)):

- 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](/learn/ai-agent-evaluation).

## 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](/learn/agent-observability).

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](https://docs.honeyhive.ai/v2/integrations/langchain)):

```python
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](https://docs.honeyhive.ai/v2/integrations/langchain).

## FAQ

### Is LangChain free?

Yes. The repository is MIT licensed ([GitHub](https://github.com/langchain-ai/langchain)).

### 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](https://docs.langchain.com/oss/python/langchain/overview)). See [LangGraph](/learn/langgraph-framework).

### 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](https://docs.langchain.com/oss/python/migrate/langchain-v1)).

### Which Python version does LangChain need?

The v1 migration guide says "All LangChain packages now require Python 3.10 or higher" ([migration guide](https://docs.langchain.com/oss/python/migrate/langchain-v1)). HoneyHive's integration requires Python 3.11 or later ([integration docs](https://docs.honeyhive.ai/v2/integrations/langchain)).
