Skip to main content

create_react_agent

Function create_react_agent 

Source
pub fn create_react_agent(
    model: Arc<dyn ChatModel>,
    tools: Vec<Arc<dyn Tool>>,
) -> Result<CompiledGraph<MessageState>, SynapseError>
Expand description

Create a prebuilt ReAct agent graph.

The graph has two nodes:

  • “agent”: calls the ChatModel with messages and tool definitions
  • “tools”: executes any tool calls from the agent’s response

Routing: if the agent returns tool calls, route to “tools”; otherwise route to END.