pub fn tools_condition<S: State + Serialize>(
state: &S,
messages_field: &str,
) -> &'static strExpand 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 statemessages_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,
},
);