langgraph

โดย langchain-ai

Build stateful, durable agent workflows with LangGraph. Use when you need custom graph-based control flow, human-in-the-loop, persistence, or multi-agent…

npx skills add https://github.com/langchain-ai/docs --skill langgraph

LangGraph

LangGraph is a low-level orchestration framework and runtime for building, managing, and deploying long-running, stateful agents. It provides durable execution, streaming, human-in-the-loop interactions, and time-travel debugging.

When to use

Use LangGraph when you need to:

  • Design custom agent workflows with explicit graph-based control flow
  • Add durable execution so agents survive failures and restarts
  • Implement human-in-the-loop with interrupts and approval steps
  • Build multi-agent systems with state shared across agents
  • Stream intermediate results from long-running agent tasks
  • Time-travel debug by replaying agent execution from any checkpoint

When NOT to use

  • For a simple tool-calling agent, use LangChain agents instead—less boilerplate for common patterns
  • For a batteries-included agent with planning and subagents, use Deep Agents instead
  • LangGraph is the orchestration layer—use it when you need fine-grained control over agent behavior

Install

# Python
pip install -U langgraph

# JavaScript/TypeScript
npm install @langchain/langgraph @langchain/core

Quick reference

Graph API (recommended for most use cases)

from langgraph.graph import StateGraph, MessagesState, START, END

def my_node(state: MessagesState):
    return {"messages": [{"role": "ai", "content": "hello world"}]}

graph = StateGraph(MessagesState)
graph.add_node(my_node)
graph.add_edge(START, "my_node")
graph.add_edge("my_node", END)
graph = graph.compile()

result = graph.invoke(
    {"messages": [{"role": "user", "content": "Hello!"}]}
)

Functional API (for simple pipelines)

from langgraph.func import entrypoint, task

@task
def step_one(input: str) -> str:
    return f"processed: {input}"

@entrypoint()
def pipeline(input: str) -> str:
    return step_one(input).result()

Add human-in-the-loop

from langgraph.types import interrupt

def human_approval(state: MessagesState):
    answer = interrupt({"question": "Approve this action?"})
    return {"messages": [{"role": "user", "content": answer}]}

Key concepts

ConceptDescription
StateGraphDefine nodes and edges that form your agent's control flow
MessagesStateBuilt-in state schema for chat-based agents
compile()Compile a graph builder into an executable graph
interrupt()Pause execution and wait for human input
CheckpointerPersist state for durable execution and time-travel
Graph API vs Functional APIGraph API for complex workflows; Functional API for linear pipelines

Key documentation

API reference

For SDK class and method details, use the LangChain API Reference site:

  • Browse: https://reference.langchain.com/python/langgraph
  • MCP server: https://reference.langchain.com/mcp

Related skills

  • langchain—Core building blocks for models, tools, and simple agents
  • deep-agents—High-level agent harness built on LangGraph
  • langsmith—Trace, evaluate, and deploy your LangGraph agents

Skills เพิ่มเติมจาก langchain-ai

langgraph-docs
langchain-ai
เข้าถึงเอกสาร LangGraph เพื่อสร้างเอเจนต์ที่มีสถานะและเวิร์กโฟลว์แบบหลายเอเจนต์ ดึงข้อมูลเอกสาร Python อย่างเป็นทางการของ LangGraph ซึ่งครอบคลุมเครื่องจักรสถานะ การออกแบบเอเจนต์แบบกราฟ และรูปแบบมนุษย์ในวงจร จัดลำดับความสำคัญของเอกสารที่เกี่ยวข้องตามประเภทคำถาม: คู่มือการใช้งานสำหรับคำถามวิธีทำ หน้าคอนเซปต์สำหรับทฤษฎี บทช่วยสอนสำหรับตัวอย่างแบบครบวงจร และเอกสารอ้างอิง API สำหรับรายละเอียดทางเทคนิค เลือก URL เอกสารที่เกี่ยวข้องมากที่สุด 2–4 รายการโดยอัตโนมัติและดึงเนื้อหามาเพื่อตอบ...
official
langgraph-human-in-the-loop
langchain-ai
หยุดการทำงานของกราฟเพื่อให้มนุษย์ตรวจสอบ อนุมัติ หรือตรวจสอบความถูกต้อง จากนั้นดำเนินการต่อด้วยข้อมูลที่มนุษย์ป้อนเข้าไป ต้องมีสามองค์ประกอบ: ตัวตรวจสอบจุด (InMemorySaver หรือ PostgresSaver), ID เธรดใน config, และเพย์โหลดขัดจังหวะที่แปลงเป็น JSON ได้ interrupt(value) จะหยุดและแสดงข้อมูล; Command(resume=value) จะดำเนินการต่อและส่งคืนค่านั้นไปยังโหนดที่ถูกหยุด โค้ดทั้งหมดก่อน interrupt() จะถูกเรียกใช้ใหม่เมื่อดำเนินการต่อ ดังนั้นผลข้างเคียงต้องเป็น idempotent (ใช้ upsert ไม่ใช่ insert) รองรับเวิร์กโฟลว์การอนุมัติ...
official
web-research
langchain-ai
ใช้ทักษะนี้สำหรับคำขอที่เกี่ยวข้องกับการค้นคว้าทางเว็บ โดยมีแนวทางที่มีโครงสร้างเพื่อดำเนินการค้นคว้าทางเว็บอย่างครอบคลุม
official
langchain-oss-primer
langchain-ai
เริ่มต้นที่นี่เสมอสำหรับโปรเจกต์สร้างเอเจนต์ LangChain, Deep Agents หรือ LangGraph ใดๆ จุดเริ่มต้นที่จำเป็นก่อนเลือกสกิลอื่นหรือเขียนอะไรก็ตาม…
official
skill-creator
langchain-ai
คู่มือสำหรับสร้างสกิลที่มีประสิทธิภาพเพื่อขยายความสามารถของเอเจนต์ด้วยความรู้เฉพาะทาง เวิร์กโฟลว์ หรือการรวมเครื่องมือ ใช้สกิลนี้เมื่อผู้ใช้…
official
social-media
langchain-ai
ร่างโพสต์โซเชียลมีเดียเฉพาะแพลตฟอร์มพร้อมเนื้อหาที่มีงานวิจัยรองรับและภาพประกอบที่สร้างขึ้น รองรับโพสต์ LinkedIn (1,300 ตัวอักษรด้วยน้ำเสียงมืออาชีพ) และเธรด Twitter/X (280 ตัวอักษรต่อทวีตในรูปแบบ 1/🧵) ต้องมอบหมายการวิจัยให้กับซับเอเจนต์ก่อนเขียน จากนั้นอ่านผลลัพธ์เพื่อให้แน่ใจว่าถูกต้องและเกี่ยวข้อง สร้างภาพโซเชียลที่สะดุดตาโดยอัตโนมัติโดยใช้เครื่องมือ generate_social_image ด้วยองค์ประกอบที่โดดเด่นและคอนทราสต์สูงซึ่งปรับให้เหมาะสมสำหรับขนาดเล็ก...
official
deep-agents-memory
langchain-ai
ปลั๊กอินหน่วยความจำและแบ็กเอนด์ไฟล์สำหรับ Deep Agents พร้อมตัวเลือกการกำหนดเส้นทางแบบชั่วคราว ถาวร และแบบผสม แบ็กเอนด์สี่ประเภท: StateBackend (ขอบเขตเธรด, ชั่วคราว), StoreBackend (คงอยู่ข้ามเซสชัน), FilesystemBackend (เข้าถึงดิสก์จริงสำหรับการพัฒนาในเครื่อง) และ CompositeBackend (กำหนดเส้นทางพาธที่แตกต่างไปยังแบ็กเอนด์ที่แตกต่างกัน) FilesystemMiddleware มีเครื่องมือปฏิบัติการไฟล์หกอย่าง: ls, read_file, write_file, edit_file, glob, grep CompositeBackend ใช้การจับคู่คำนำหน้าที่ยาวที่สุดเพื่อกำหนดเส้นทาง...
official
deep-agents-orchestration
langchain-ai
จัดระเบียบเอเจนต์ย่อย วางแผนงานหลายขั้นตอน และต้องได้รับการอนุมัติจากมนุษย์สำหรับการดำเนินการที่ละเอียดอ่อน มอบหมายงานให้กับเอเจนต์ย่อยเฉพาะทางผ่านเครื่องมืองาน เอเจนต์ย่อยแบบกำหนดเองรองรับชุดเครื่องมือและพรอมต์ระบบที่แยกออกจากกัน ในขณะที่เอเจนต์ย่อย "วัตถุประสงค์ทั่วไป" เริ่มต้นจะสืบทอดการกำหนดค่าเอเจนต์หลัก วางแผนและติดตามเวิร์กโฟลว์ที่ซับซ้อนด้วย write_todos โดยจัดระเบียบงานในสถานะรอดำเนินการ กำลังดำเนินการ และเสร็จสมบูรณ์ ต้องใช้ thread_id เพื่อความต่อเนื่องในการเรียกใช้หลายครั้ง ดำเนินการ...
official