[KongchangAI]
· 2 min read· 1,464 words

Getting Started with LangChain: Agent Development and RAG in Practice

Getting Started with LangChain: Agent Development and RAG in Practice

LangChain is an open-source framework that fills LLMs' three major gaps and builds agent apps via chained orchestration.

The article clarifies a common misconception: LangChain is not just a model API wrapper but an open-source framework for building LLM-driven applications, offering a prebuilt agent framework and tool integration, analogous to Spring in Java and built on LangGraph. It covers three LLM limitations — knowledge cutoff, inability to interact with external systems, and inherent statelessness — and how LangChain compensates via Function Call, tools, and chained orchestration. Learning should start with official docs covering LangChain, LangGraph, Deep Agents, and LangSmith.

What LangChain Is: More Than an API Wrapper

Many developers starting out with LLM application development assume LangChain is just an API wrapper for calling models. That understanding is incomplete. According to this Bilibili tutorial, LangChain is essentially an open-source framework for building applications powered by large language models, and it is nearly unavoidable in the Python ecosystem and mainstream Agent development.

Its real value lies in providing a prebuilt agent framework and rich tool integration capabilities. The tutorial draws a vivid analogy: if you've written Java, you can think of LangChain's role in Agent development as similar to Spring's role in Java — you don't need to build complex integration architectures from scratch to quickly construct advanced LLM-based applications. Under the hood it currently runs on LangGraph while also incorporating Deep Agents-related capabilities.

LangChain solves more than just model invocation

Three Shortcomings of LLMs and How LangChain Addresses Them

To understand a framework, you first need to understand what problems it solves. The tutorial summarizes three categories of limitations inherent to LLMs, all of which are very typical in practice.

Knowledge Cutoff: It Doesn't Know What Happened After Training

A model's knowledge stops at its training cutoff; it has no way of knowing what happened afterward. The tutorial gives a straightforward example: a model trained on August 10th can't answer a question about the weather on August 11th. Some might say, "But Doubao knows when I ask it" — that's because Doubao itself is already a wrapped application, not direct interaction with the underlying model. LangChain uses the Function Call mechanism to let developers invoke tools themselves to fetch data the model can't access.

Function Call is a structured output capability provided by LLMs: developers use JSON Schema to describe the names, parameters, and purposes of available functions, and the model determines during a conversation whether to call one, which one, and with what arguments, returning a structured call request; the application side actually executes the function and feeds the result back to the model. It's not the model actually executing code — the decision of "what to call" is delegated to the model while "actual execution" remains with the developer, which both breaks through knowledge cutoff and keeps permissions and side effects under control at the application layer. LangChain encapsulates this mechanism as a unified Tool abstraction, so the same tool definition can be reused across different model providers, and it automatically handles the multi-turn call-result loop.

External Interaction and Internal Data: The Model Can't Reach Your Systems

LLMs cannot directly interact with external systems. Calling third-party APIs to check the weather, writing utility classes for precise arithmetic, or even using JDBC to connect to your company's internal database — the model itself can't do any of these. This is especially true for complex calculations, where the model being inaccurate is the norm. LangChain's tool integration capabilities exist precisely to bridge this gap between the model and external resources.

The model cannot directly interact with external systems

Statelessness: Multi-turn Dialogue Is Not a Native Model Capability

When interacting with Doubao or DeepSeekAd, it seems to remember what you discussed earlier and combines previous and current questions in its answers. But this isn't the model's own capability. LLMs are inherently one-question-one-answer and have no state-retention ability; the second question doesn't automatically relate to the first. Multi-turn dialogue memory relies on orchestration by an outer framework, and LangChain is one such framework.

From a protocol perspective, mainstream LLM chat interfaces are stateless: each request must resend the complete message history (the system, user, and assistant role sequence) for the model to "see" what was discussed before. Memory is essentially a message list maintained on the application side and assembled into context on each call. This introduces two engineering problems: first, context length has a limit, so long histories need truncation, summarization, or retrieval-based memory; second, token consumption grows linearly with turns, so cost and latency must be factored into the design. LangChain abstracts this layer with Memory components and message history management, separating "where to store, how to trim, how to inject" from business code, and making it easy to persist at the session or user level.

The Name: Language + Chain

The name LangChain breaks down into two meanings: Lang stands for Language, i.e., large language models; Chain stands for chained interaction composition. In the tutorial's own words, it means connecting large language models with other resources in the computer in a chained manner, enabling interaction between them to build more powerful AI applications or agents. The naming itself captures the framework's design philosophy — models are nodes, chains are orchestration.

Multi-turn dialogue relies on the framework's state management

LangGraph is the underlying orchestration runtime introduced by the LangChain team, describing agent workflows with a graph structure: nodes are functions or model calls, edges are control flow, and it supports conditional branching, loops, parallelism, and persistable state. Compared to early LangChain's linear Chains, the graph structure naturally expresses loops like "think — call tool — think again" and makes it easy to add human-review interrupt points and resume-from-checkpoint. LangChain's high-level agent capabilities are now built on LangGraph, which explains the statement that "under the hood it runs on LangGraph": the upper layer provides out-of-the-box wrappers, while the lower layer provides controllable, observable orchestration, and you can drop down to the graph layer when you need fine-grained control.

Learning Path: Official Docs Are the First Entry Point

The tutorial repeatedly emphasizes checking the official documentation often, because the framework is constantly iterating and updating. The official site's core content covers LangChain, LangGraph, Deep Agents, and LangSmith, with documentation specifically explaining the relationships and differences among them. Developers less comfortable with English can refer to the synchronously updated Chinese documentation — the code is largely identical and the translation quality is mostly usable, but the latest updates still follow the official English version.

For the learning order, start with the Overview, quick start, and installation chapters to build an overall understanding: LangChain = LLM + wrapper framework + toolset. The Create Agent feature mentioned in the official docs is an extremely simple and highly configurable entry point, well suited as your first hands-on experiment.

Official documentation is the main entry point for learning LangChain

LangSmith is the companion observability and evaluation platform, used to trace the full chain of each call (prompts, model outputs, tool calls, latency, and token consumption), and supports dataset management, offline evaluation, and online monitoring. The debugging challenge of agent applications is long chains and non-deterministic behavior; locating which step went wrong is hard with logs alone, and the trace view lays out every node of a run for inspection. The article mentions LangSmith alongside LangChain and LangGraph precisely because there's a layer of observability between "it runs" and "it can be maintained stably" — in real projects it's advisable to integrate it early in development rather than retrofitting after problems arise.

What It Means for Agent Developers

Based on this tutorial's framing, LangChain is placed first among the "framework application capabilities that Agent development or LLM application engineers must have." This judgment holds up in practice: knowledge cutoff, external interaction, and state retention are walls nearly every production project runs into. Rather than reinventing the wheel for each project, it's better to first master a mature orchestration framework and save energy for business logic and tool design itself.

One caveat: the tutorial currently only covers LangChain's positioning, the problems it solves, and documentation entry points; the specifics of agent building and RAG project practice are not yet covered. When actually getting hands-on, it's recommended to proceed in the order of "official quick start → Function Call tool invocation → Agent orchestration → RAG retrieval augmentation," and to get a minimal runnable example working at each step before moving on.

One-line Summary

LangChain is an open-source framework that fills LLMs' three major gaps and builds agent applications through chained orchestration.

Paragraph Summary

The article clears up a common misconception: LangChain is not just a model API wrapper but an open-source framework for building LLM-driven applications, offering a prebuilt agent framework and tool integration capabilities, occupying a position in the Agent ecosystem analogous to Spring in Java, with LangGraph under the hood. It summarizes three LLM shortcomings — knowledge cutoff, inability to interact with external systems, and inherent statelessness — and explains how LangChain addresses them through Function Call, tool integration, and chained orchestration. The name combines Language and Chain, reflecting the design philosophy of "chaining models with internal and external computer resources." For learning, official docs are the first entry point, covering LangChain, LangGraph, Deep Agents, and LangSmith; start with the Overview and quick start, and get hands-on with Create Agent.

#LangChain#Agent development#RAG#LangGraph#LLM application development
Share:

Related articles