Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Stop calling functions: my first LangGraph graph, where state does the calling

说明与用途

将 JobCopilot 流程重写为 LangGraph 图,状态通过节点流动,函数不再相互调用,消除了嵌套调用问题并澄清了重试逻辑。

问题

Nested function calls in a JobCopilot pipeline caused unclear ownership, retry logic, and state management issues.

结果

The graph-based approach eliminated nested function calls, clarified retry logic, and ensured robust state management, allowing the pipeline to handle errors and scoring correctly.

工作流

  • Define a single Pydantic model (AgentState) to hold all run data.
  • Implement nodes that receive state, perform a task, and return a dict patch of changed fields.
  • Use LangGraph’s StateGraph to declare nodes and edges, ensuring no node calls another.
  • Configure last-writer-wins for fields and use Annotated with custom reducers for list accumulation.
  • Run the graph, letting LangGraph merge patches and pass updated state to the next node.
  • Fix a wiring bug that caused every job to return "error" after correcting the graph.
  • Validate state integrity with Pydantic to catch type errors during merges.

证据

functions stop calling each other; state flows through a graph, and nodes return patches of that state.

来源

Fields without a custom reducer are last-writer-wins — I proved it to myself before trusting it:

来源

Same lesson as part 1: shape is a contract, and contracts live in pydantic, not in comments.

来源

  • 记录日期: 2026-10-27T09:26:20.465Z