Skip to contents

Returns "tools" if the state has pending tool calls, "end" otherwise.

Usage

route_tool_calls(state)

Arguments

state

Current graph state.

Value

Character string: either a tool node name or END.

Note

These functions are for manual tool dispatch in custom node handlers. When using Agent objects with ellmer, tool calling is handled internally by ellmer's Chat class. See react_graph for the recommended pattern.

See also

Other node-helpers: as_node(), route_to(), tool_node()

Examples

route_tool_calls(list(pending_tool_calls = list()))
#> [1] "end"
route_tool_calls(list(pending_tool_calls = list(list(name = "add"))))
#> [1] "tools"