Skip to main content

create_react_agent

Function create_react_agent 

Source
pub fn create_react_agent(
    model: Arc<dyn ChatModel>,
    tools: ToolRegistry,
) -> Result<Graph>
Expand description

Build a prebuilt ReAct agent graph over model and tools.

The returned graph has exactly two nodes (AGENT_NODE, TOOLS_NODE), a conditional edge agent → tools | End, and a static edge tools → agent. It is stateless with respect to any single run: clone it freely and drive it with the crate::executor::Executor.

The graph never errors at build time for an empty registry — a tool-less agent simply answers directly on the first agent pass.

This variant never emits GraphEvent::Token: the agent node calls ChatModel::chat. Use create_react_agent_streaming to stream token deltas into the run’s event channel.