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

Getting Started with LangChain: From Model Invocation to Building Agent Memory Systems

Getting Started with LangChain: From Model Invocation to Building Agent Memory Systems

LangChain is an application development framework that fills LLMs' gaps in knowledge timeliness, external interaction, and memory.

The article covers LangChain's positioning, capabilities, and learning path. It first clarifies that LangChain is not just a model API wrapper but an open-source framework providing pre-built agents and rich tool integrations, analogous to Spring in the Java ecosystem, built on LangGraph. It then addresses three innate LLM shortcomings: knowledge locked to training time, inability to directly interact with external systems and internal data, and statelessness preventing independent multi-turn conversations. LangChain fills these gaps through Function Call, tool integration, and short-term and long-term memory systems. The article also explains the meaning of Language and Chain in the name—connecting and orchestrating models with other computing resources in a chained manner. Finally, it recommends official documentation as the primary learning entry point, with Chinese and English docs sharing identical code but English updates being more timely.

In the process of developing agents and deploying large language model applications, LangChain is a framework that's nearly impossible to avoid. But what exactly is it, what role does it play in agent products, and which innate shortcomings of large models does it solve? Many beginners aren't clear on this. This article, based on a step-by-step tutorial from a Bilibili creator, explains LangChain's positioning, core capabilities, and learning path all at once.

LangChain's positioning goes far beyond simple API wrapping

What LangChain Really Is: More Than Just a Model Invocation Wrapper

LangChain is an open-source framework for developing applications powered by large language models. In the Python ecosystem and even in mainstream agent development ecosystems, it's practically a must-have.

But many people misunderstand it, thinking it's just a tool for calling model APIs. The creator emphasizes in the video: LangChain is not merely an API wrapper for model invocation, but an architecture that provides pre-built agents and rich tool integrations.

If you've used Java, you can think of its role in agent development as analogous to Spring's position in Java—it provides a complete infrastructure so you don't have to build complex integration architectures from scratch to quickly construct advanced applications based on large language models.

Architecturally, LangChain is built on LangGraph underneath, and also includes DeepAgents-related content. It lets developers quickly build an advanced LLM-powered application without repeatedly setting up complex integration architectures.

LangChain is a framework for developing LLM-powered applications

Three Innate Shortcomings of Large Models and How LangChain Fills Them

Before learning any technology, first understand what problem it solves. The creator summarizes three key ways LangChain compensates for the limitations of large models from a macro perspective.

Limited Knowledge: The Model Doesn't Know What Happened After Training

A large language model's knowledge is locked to the point in time of its training data. For example, if the model finished training on August 10th, and you ask it about the weather on August 11th or what happened on August 12th, it simply doesn't know.

Some might say that when I ask Doubao, it knows—but actually you're using an application someone else has already wrapped, not interacting directly with the Doubao model. LangChain uses the Function Call mechanism to let developers call tools themselves to obtain information after the model's training time, thereby breaking through the timeliness limitation of knowledge.

Function Call is a structured output capability provided by large models: developers pre-declare several available functions (name, purpose, parameter schema), and the model determines during conversation whether to call one, which function to call, and outputs JSON parameters conforming to the schema. The application layer actually executes the function and passes the result back to the model. It's important to emphasize that the model itself doesn't execute any code—it only decides "what to call and what parameters to pass." Actual execution, permission checks, and error handling are all done by the host program. This also explains why frameworks like LangChain are needed: they encapsulate tedious logic like tool description generation, call parsing, result injection, exception retry, and multi-turn tool loops into standard components, so developers only need to register tools via a unified interface.

Missing External Interaction: The Model Can't Touch Your Systems and Data

The model itself cannot directly interact with external systems. If you want to call a third-party API to check the weather, or write a utility class to perform precise arithmetic, the large model can't do it directly.

A more typical scenario is when a company's internal data is stored in a database—the large model can't connect to JDBC itself to interact with you. These problems can all be solved through LangChain's tool integration capabilities—teaching the model to call external tools, indirectly gaining the ability to interact with external systems and data.

By the way, models aren't very accurate with complex arithmetic anyway, and Function Call combined with a self-built calculator solves this precision problem.

Tool Integration refers to wrapping external capabilities as tools that large models can call. Common forms include: calling third-party REST APIs, executing local functions or scripts, querying databases, and retrieving from vector stores. In LangChain, tools are typically defined via a unified Tool interface containing a name, description, and parameter structure. The description text goes directly into the prompt, so the clearer it's written, the lower the chance of the model choosing the wrong tool. In engineering practice, you also need to consider security boundaries for tool calls (such as read-only queries, parameter whitelists), timeouts and retries, and truncation and summarization of call results to avoid overly long return values crowding the context window. This is precisely the key to why "model + tools" can actually be deployed in real business scenarios compared to pure conversation mode.

Stateless: Multi-turn Conversation Memory Comes from the Application Layer

When you use Doubao or DeepSeekAd, it seems to remember what you talked about before. But this isn't the model's own capability—large models don't have state retention ability and are essentially one question, one answer. When you ask the second question, the model itself doesn't know what the first question was.

The model alone cannot achieve multi-turn conversation, but with the LangChain framework you can build short-term session memory and long-term persistent memory systems—this is the key to unlocking large model memory system development.

Large models are stateless; memory must be solved at the framework layer

Short-term memory and long-term memory are two solutions at different levels. Short-term memory usually refers to context management within a session: retaining, trimming, or summarizing historical messages according to a strategy and re-inserting them into the prompt to fit within the model's context window limit. Common approaches include sliding windows, truncation by token count, and summarization compression of earlier conversations. Long-term memory persists important information to external storage (such as a database or vector store) and recalls it through retrieval when needed, thereby preserving user preferences, factual information, or historical conclusions across sessions. LangChain provides various Memory and Retriever components to carry these two types of requirements. Note that more memory isn't always better—irrelevant history dilutes model attention and increases costs. Designing recall and eviction strategies is often more critical than the components themselves.

The Mystery in the Name: Language Plus Chain

The name LangChain is essentially a combination of two words: Lang stands for Language, i.e., large language models; Chain stands for chained interaction composition.

In plain terms: connecting large language models with other computer resources in a chained manner, enabling them to interact and thereby building more powerful AI applications or agents.

Once you understand this naming logic, you understand LangChain's core design philosophy—connection and orchestration.

LangGraph is the orchestration framework in the LangChain ecosystem for building stateful, multi-step agents. It models applications as graphs of "nodes + edges": nodes are specific processing steps (calling models, executing tools, conditional checks, etc.), and edges define flow relationships, supporting loops, branching, interruption, and human intervention. Compared to the earlier abstraction centered on linear Chains, graph structures are better suited for expressing Agent flows that require repeated reasoning, tool calls, and backtracking based on results. LangChain's foundation shifting toward LangGraph means its focus is moving from "stringing calls together" to "managing state and flow"—which is also the mainstream direction of current Agent engineering.

Learning Path: Official Documentation Is the First Entry Point

LangChain is constantly iterating and updating, so the most reliable resource for learning is the official documentation. The creator recommends bookmarking two addresses in the video: the English official documentation and the synchronously updated Chinese documentation.

If your English is good, it's recommended to read the official documentation directly to get the latest updates first. If your English is average, the Chinese documentation is fine too—the code parts are completely identical, and the Chinese content can be understood as AI-translated results. Most of it is accurate, but the latest version updates will certainly come out in English official first.

From the structure of the official documentation, it mainly involves components like LangChain, LangGraph, DeepAgents, and LangSmith. The relationships and differences between them are clearly explained in the overview section. Among them, LangChain is the first one to encounter. The official documentation positions it as a model plus wrapper framework—LangChain is one such framework and provides highly configurable Agent wrapper capabilities that you can use to interact with all kinds of models.

Official documentation is the first entry point for learning LangChain

Final Thoughts

LangChain's value isn't in calling models for you, but in filling the three major gaps: knowledge timeliness, external interaction, and stateful memory. From Function Call to tool integration, and then to building short-term and long-term memory systems, this path is a required course for agent developers. Only by thoroughly understanding the official documentation and combining it with complete hands-on code practice can you truly master large model memory system development.

#LangChain#Agent development#Function Call#tool integration#memory system#LangGraph
Share:

Related articles