
LangGraph
エージェントの処理をノードと共有状態のグラフとして自分で設計する制御層。モデルが決めるのは各ノードの中身だけ
LangGraphとは
LangGraphでは、エージェントの処理の流れを「状態・ノード・エッジ」のグラフとして自分で定義します。ノードはLLM呼び出しやツール実行といった処理単位、エッジは次にどのノードへ進むかのつなぎで、全ノードが共有の状態を読み書きします。状態に応じてエッジを分岐させてループを作れるほか、ノードごとに状態が保存されるため、人の承認待ちで止めて後から再開したり、障害後に保存地点から続けたりできます。その分コードは増え、単純なツール呼び出しだけのエージェントには他のフレームワークより重くなります。
LangGraphで何ができますか?
- 処理の流れをグラフとして定義する — 手順を1つずつノードとして置き、次にどのノードへ進むかをエッジで自分で決めます。モデルが判断するのは各ノードの中身であって、経路ではありません。
- 共有の状態を全ノードで読み書きする — 調べた内容、試行回数、承認の有無といった情報を1つの状態にまとめて持ち回り、どのノードもそれを読んで書き足します。
- 状態に応じて分岐し、ループを作る — 条件付きエッジで経路を切り替えたり、前のノードへ戻したりできます。検索して草案を作り、確認して足りなければもう一度検索する、という流れをそのまま書けます。
- チェックポイントから再開する — ノードを通過するたびに状態が保存されるため、途中で落ちた実行も最初からではなく直前の保存地点から再開できます。
- 人の承認を挟んで止める — 指定したノードで実行を中断し、これから行われる内容を人が確認・修正してから再開できます。
- 細かく設計しないならDeep Agentsから — 計画立案・サブエージェント・ファイル操作を備えたDeep AgentsがLangGraphの上に用意されており、グラフを自分で設計しなくてよい場合はこちらから始められます。
LangGraphを選ぶ前に
- 再開できるのは直前の保存地点までで、エージェントが最後にした操作からではありません。マネージド版では時間のかかる処理が二重・三重に実行される報告があり、実行を取り消すと直近の状態が失われることもあります。報告#7417#5672
- 承認の仕組みは部品として提供され、確認画面は自分で組み立てます。1か所で続けて複数の質問をすると、新しい質問ではなく前の質問が表示される事象も報告されています。報告#8026#3275
- エージェントの動作を確認する手段として案内されるLangSmithは別の有料製品です。1人かつ月5,000トレースまでは無料、超えると1席あたり月39ドル、自社サーバーでの運用はEnterpriseプランに限られます。
スター推移
8月15日〜8月28日 · +899
よくある質問
LangGraphは商用利用できますか?
LangGraphはMITライセンスで公開されています。OSI承認のオープンソースライセンスで、商用利用が認められています。
LangGraphはどの形で使えますか?
LangGraphはセルフホスト・マネージドクラウドの形で利用できます。
ドキュメント
langchain-ai/langgraph のREADMEより転載(MIT)。 原文を読む ↗
Trusted by companies shaping the future of agents – including Klarna, Replit, Elastic, and more – LangGraph is a low-level orchestration framework for building, managing, and deploying long-running, stateful agents.
pip install -U langgraph
[!TIP] If you’re looking to quickly build agents, check out Deep Agents — a higher-level package built on LangGraph for agents that can plan, use subagents, and leverage file systems for complex tasks.
For an equivalent JS/TS library, check out LangGraph.js and the JS docs.
Why use LangGraph?
LangGraph provides low-level supporting infrastructure for any long-running, stateful workflow or agent:
- Durable execution — Build agents that persist through failures and can run for extended periods, automatically resuming from exactly where they left off.
- Human-in-the-loop — Seamlessly incorporate human oversight by inspecting and modifying agent state at any point during execution.
- Comprehensive memory — Create truly stateful agents with both short-term working memory for ongoing reasoning and long-term persistent memory across sessions.
- Debugging with LangSmith — Gain deep visibility into complex agent behavior with visualization tools that trace execution paths, capture state transitions, and provide detailed runtime metrics.
- Production-ready deployment — Deploy sophisticated agent systems confidently with scalable infrastructure designed to handle the unique challenges of stateful, long-running workflows.
[!TIP] For developing, debugging, and deploying AI agents and LLM applications, see LangSmith.
LangGraph ecosystem
While LangGraph can be used standalone, it also integrates seamlessly with any LangChain product, giving developers a full suite of tools for building agents.
To improve your LLM application development, pair LangGraph with:
- Deep Agents – Build agents that can plan, use subagents, and leverage file systems for complex tasks.
- LangChain – Provides integrations and composable components to streamline LLM application development.
- LangSmith – Helpful for agent evals and observability. Debug poor-performing LLM app runs, evaluate agent trajectories, gain visibility in production, and improve performance over time.
- LangSmith Deployment – Deploy and scale agents effortlessly with a purpose-built deployment platform for long-running, stateful workflows. Discover, reuse, configure, and share agents across teams – and iterate quickly with visual prototyping in LangSmith Studio.
Documentation
- docs.langchain.com – Comprehensive documentation, including conceptual overviews and guides
- reference.langchain.com/python/langgraph – API reference docs for LangGraph packages
- LangGraph Quickstart – Get started building with LangGraph
- Chat LangChain – Chat with the LangChain documentation and get answers to your questions
Discussions: Visit the LangChain Forum to connect with the community and share all of your technical questions, ideas, and feedback.
Additional resources
- Guides – Quick, actionable code snippets for topics such as streaming, adding memory & persistence, and design patterns (e.g. branching, subgraphs, etc.).
- LangChain Academy – Learn the basics of LangGraph in our free, structured course.
- Case studies – Hear how industry leaders use LangGraph to ship AI applications at scale.
- Contributing Guide – Learn how to contribute to LangChain projects and find good first issues.
- Code of Conduct – Our community guidelines and standards for participation.