何時使用: 您需要一個可用的工具迴圈代理作為起點,而不是另一個空白筆記本。
前置條件
- Python 3.10 +和pip — pyenv或system Python
- LangGraph + LangChain核心 — pip install langgraph langchain-core
步驟
-
索取ReAct腳手架
使用兩個工具(搜尋+計算器)和MemorySaver檢查指標將ReAct客服人員腳手架架起來。✓ 已複製
→ 具有圖形、工具和檢查指標的可執行程式碼有線
-
跑步並穿過
Run it with thread_id='thread-1' and show me the state at each step.✓ 已複製
→ State snapshots per step confirm the loop is working
結果: 您可以延伸的運行代理,而不是從零開始。
注意事項
- Using InMemorySaver in production — Swap to the Postgres checkpointer before shipping; the guide covers the swap
何時使用: Your workflow has branches (classify → route → specialize → finalize) and you want explicit state.
步驟
-
Describe the branches
Draft a LangGraph for: classify intent → route to summarizer or Q&A → finalize with citations.✓ 已複製
→ Graph diagram and code; explicit conditional edges
-
Add checkpointing
Add a checkpointer so resumes work mid-flow.✓ 已複製
→ State persisted between invocations
結果: A typed pipeline that's testable and resumable.
注意事項
- Treating every node as an LLM call — Non-LLM pure Python nodes are often clearer and cheaper
何時使用: The agent is about to spend money, email someone, or mutate state — you want a human checkpoint.
步驟
-
Add an interrupt node
Insert a human approval interrupt before the 'send_email' node; show how to resume.✓ 已複製
→ interrupt_before wiring + clear resume API
-
Test approve + reject paths
Write a script that tests both approval and rejection flows.✓ 已複製
→ Two paths exercised cleanly
結果: Humans gate the risky step; approved actions run to completion.
注意事項
- Forgetting to persist state across the interrupt — Interrupts need a checkpointer; without it, the pause is useless
何時使用: A single agent is getting confused or too big; you're considering orchestration patterns.
步驟
-
Walk through the tradeoffs
Compare supervisor vs swarm for a researcher + coder + reviewer team.✓ 已複製
→ Clear pros/cons; when to pick each
-
Pick and scaffold
Scaffold the chosen pattern with the three agents.✓ 已複製
→ Runnable code with routing/handoff logic
結果: A principled choice of multi-agent pattern with running code.
注意事項
- Adopting multi-agent before a single agent has been debugged — Start single-agent; split only when you hit concrete limits
何時使用: You have a working graph and need a real deploy plan.
步驟
-
Pick the deploy target
Compare Docker + LangGraph Platform vs self-hosted; recommend for small team.✓ 已複製
→ Concrete recommendation with cost/ops tradeoffs
-
Wire tracing
Add LangSmith tracing with project scoping.✓ 已複製
→ Traces visible in LangSmith with proper project name
結果: A deploy path you can show a platform team.