Skip to main content

build_react_graph

Function build_react_graph 

Source
pub fn build_react_graph(
    llm_node: LLMNode,
    tool_node: ToolNode,
    compactor_node: CompactorNode,
) -> Graph<AgentState, AgentStateMerge>
Expand description

构建 ReAct 内部图。

START → budget_check

budget_check --budget_ok--> [llm]
         --need_compact--> [compactor] → [llm]

[llm] → [post_llm_check]
   --budget_exceeded--> [end]
   --has_tool_calls--> [tool] → [budget_check] (循环)
   --no_tool_calls--> [end]

使用 Graph<AgentState> — 节点直接读写强类型 AgentState,零序列化。