Skip to main content

tools_condition

Function tools_condition 

Source
pub fn tools_condition<S: State + Serialize>(
    state: &S,
    messages_field: &str,
) -> &'static str
Expand description

Tools condition router function

Standard routing function for ReAct agents. Routes to “tools” node if last message has tool_calls, otherwise to END.

§Arguments

  • state - Graph state
  • messages_field - Name of messages field in state

§Returns

Target node name (“tools” or END)

§Examples

graph.add_conditional_edges(
    "agent",
    |state: &MyState| tools_condition(state, "messages"),
    path_map! {
        "tools" => "tools",
        END => END,
    },
);