iT邦幫忙

2026 iThome 鐵人賽

DAY 9
0
AI Engineering

從 LLM 到 AI Agent:30 天打造 vLLM × RAG × LangChain 智慧推薦系統系列 第 9

LangChain, LangGraph, and LangSmith: Building, Orchestrating, and Observing AI Agents

  • 分享至 

  • xImage
  •  

In the previous days, we built a RAG pipeline from the ground up using embeddings, FAISS, and a locally served LLM. That pipeline works well when the workflow is simple and predictable, but real AI applications often need more control: they may need to call tools, choose between different actions, remember previous steps, or inspect why a response failed. This is where LangChain, LangGraph, and LangSmith become useful. Together, they provide a practical stack for building AI applications, orchestrating agent workflows, and observing how those systems behave in practice.

1. LangChain — Build the AI application

LangChain is the application framework. It helps connect the core components around an LLM, such as models, prompts, tools, retrievers, and agent loops. In current LangChain, create_agent provides a configurable agent harness around the model, and LangChain’s agent abstractions are built on top of LangGraph.

For our project, LangChain can connect the components we already built:

User Question
      ↓
LangChain
      ↓
Retriever / FAISS
      ↓
Prompt
      ↓
Qwen via vLLM
      ↓
Answer

So instead of manually connecting every component ourselves, LangChain gives us reusable abstractions for building the application.

A simple way to remember it is:

LangChain = connect the LLM with data, tools, and application logic.

2. LangGraph — Control the workflow

LangGraph is a lower-level orchestration framework and runtime for stateful agents. It is useful when an AI application is no longer a simple linear pipeline and needs decisions, loops, persistence, or human intervention. LangGraph can combine deterministic code with LLM-driven decisions in the same workflow.

For example, instead of always performing retrieval, an agent could decide:

          User Question
                ↓
              Agent
                ↓
         Need Retrieval?
          /          \
        Yes           No
         ↓             ↓
       FAISS           LLM
         ↓             ↓
       Context ─────→ Answer
       

LangGraph represents this using state, nodes, and edges. It also supports capabilities such as persistence, human-in-the-loop workflows, memory, and durable execution.

So:

LangGraph = control how the agent moves between different steps.

3. LangSmith — Observe and evaluate the system

Once our application becomes more complex, another question appears:

What actually happened inside the agent?

LangSmith is the observability and evaluation platform. It records traces of what an LLM application or agent did, allowing developers to inspect execution, debug failures, monitor quality, and build evaluation datasets. It can also work with frameworks beyond LangChain.

For example:
User Question

Retriever

Tool Call

LLM

Final Answer

                      │
                      └──────────────→ LangSmith
                                        Trace
                                        Debug
                                        Evaluate
                                        Monitor
                                       

If an agent produces the wrong answer, LangSmith can help us inspect the execution path rather than only looking at the final output.

So:

LangSmith = see what happened, understand why it happened, and measure how well it worked.

How They Work Together

The three tools solve different parts of the same problem:

            AI Agent Application

                 LangChain
          Build the application
      Models • Tools • RAG • Agents
                   ↓
                 LangGraph
          Orchestrate workflow
    State • Routing • Loops • Memory
                   ↓
                 LangSmith
         Observe and evaluate
      Trace • Debug • Monitor • Test

A useful shorthand is:

LangChain builds it. LangGraph orchestrates it. LangSmith observes it.

Conclusion

In this article, we introduced LangChain, LangGraph, and LangSmith as three complementary parts of modern AI application development. LangChain helps us connect LLMs with retrievers, tools, and application logic. LangGraph gives us more control when the workflow becomes stateful or requires decisions and loops. LangSmith then helps us trace, debug, and evaluate the resulting system.

For our project, this marks an important transition. Until now, we have focused on building the individual parts of RAG—embeddings, FAISS, retrieval, and LLM inference. From here, we can begin connecting those components into an AI Agent that can decide what to do instead of simply following a fixed pipeline.

Reference:

  1. https://www.truefoundry.com/blog/langchain-vs-langgraph-vs-langsmith

上一篇
Day 8: How Does Vector Search Work?-
下一篇
Day 10: Building Our First RAG Application with LangChain
系列文
從 LLM 到 AI Agent:30 天打造 vLLM × RAG × LangChain 智慧推薦系統15
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言