AIWiki
Malaysia

LangChain

LangChain is an open-source framework for building applications powered by large language models, providing composable abstractions for chaining LLM calls with tools, memory, and data retrieval in Python and JavaScript.

6 min readLast updated May 2026Infrastructure

LangChain is an open-source framework designed to simplify the construction of applications that use large language models (LLMs) as their core reasoning engine. Created by Harrison Chase and first released in October 2022, LangChain became one of the fastest-growing open-source projects in the AI space, accumulating tens of thousands of GitHub stars within months of release. It provides Python and JavaScript/TypeScript libraries that abstract the complexity of integrating LLMs with external tools, databases, APIs, and memory systems into composable building blocks called chains, agents, tools, and memory modules.[^1]

The framework gained rapid adoption among developers building chatbots, document question-answering systems, code assistants, and autonomous AI agents, as it allowed prototyping of complex LLM workflows with relatively little boilerplate code.

Core Abstractions

Chains

The foundational abstraction in LangChain is the chain — a sequence of calls to LLMs, tools, or other components that produces an output. Simple chains might route a user query through a prompt template to an LLM and return the result. More complex sequential chains pass the output of one step as input to the next, enabling multi-step reasoning pipelines. The LangChain Expression Language (LCEL), introduced in 2023, provides a declarative pipe syntax (|) for composing chains.

Agents

An agent is an LLM given access to a set of tools and instructed to decide which tool to use at each step in order to accomplish a goal. The agent reasons about the current state, selects an action (calling a tool such as a web search, a calculator, or a database query), observes the result, and iterates until it can produce a final answer. This ReAct (Reasoning and Acting) pattern — where the model interleaves reasoning traces and actions — is the most common agent architecture in LangChain.[^2]

As of LangChain version 0.1.0, legacy agent types were deprecated in favour of LangGraph, a separate library that models agent workflows as directed graphs with explicit state management, supporting more complex patterns including parallel execution, cycles, and human-in-the-loop checkpointing.

Memory

LangChain's memory modules allow conversational applications to retain context across multiple turns. Options range from simple conversation buffer memory — storing the full history verbatim — to more sophisticated approaches such as entity memory (extracting and updating facts about entities mentioned in conversation), knowledge graph memory, and summary memory (using an LLM to compress long conversation histories). For production applications with large user bases, external vector stores or databases typically handle long-term memory persistence.

Retrieval-Augmented Generation (RAG)

LangChain provides an end-to-end pipeline for retrieval-augmented generation: loading documents from diverse sources (PDFs, web pages, databases, code repositories), splitting them into chunks, embedding them with an embedding model, storing them in a vector database (such as Pinecone, Weaviate, Chroma, or Qdrant), and retrieving relevant chunks at query time to augment the LLM's context window. This architecture allows an LLM to answer questions about private or recent knowledge not included in its training data.[^1]

Tool Integration

LangChain maintains an extensive library of pre-built tool integrations covering web search (SerpAPI, Tavily), code execution (Python REPL), databases (SQL, MongoDB, Redis), cloud services (AWS, Google Cloud, Azure), and third-party APIs (Stripe, Twilio, Jira). Custom tools can be defined as Python functions decorated with a @tool decorator and automatically converted into the schema expected by LLM tool-calling APIs.

The LangChain Ecosystem

The core LangChain library has expanded into a broader ecosystem of related products.

LangGraph provides a graph-based orchestration layer for stateful, multi-actor agent workflows. It is the recommended approach for building agentic systems as of 2024, replacing the older AgentExecutor abstraction.

LangSmith is a commercial observability and evaluation platform for LLM applications. It enables tracing of LLM calls, evaluating model outputs against defined criteria, and comparing prompt variations — capabilities that address the difficulty of debugging and testing LLM-based systems.

LangServe provides a REST API layer for deploying LangChain chains and agents as production-ready endpoints.

Position in the Ecosystem

LangChain competes and coexists with other LLM orchestration frameworks including LlamaIndex (focused on document indexing and retrieval), Microsoft Semantic Kernel, Haystack, and CrewAI. The emergence of native tool-calling APIs from LLM providers (OpenAI, Anthropic, Google) has also reduced some of the abstraction value that early LangChain provided, as developers can now call tools directly through official SDKs without additional framework layers. Despite this, LangChain's extensive integrations, active community, and observability tooling have maintained its position as one of the most widely used LLM frameworks.[^3]

See Also

References

References

  1. Chase, H. (2022). LangChain. GitHub repository. https://github.com/langchain-ai/langchain
  2. Yao, S., Zhao, J., Yu, D., Du, N., Shafran, I., Narasimhan, K., & Cao, Y. (2023). ReAct: Synergizing Reasoning and Acting in Language Models. ICLR 2023.
  3. IBM. (2024). What Is LangChain? IBM Think. https://www.ibm.com/think/topics/langchain