reagent-rs 0.2.2

A Rust library for building AI agents with MCP & custom tools
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::{call_tools, invoke, invoke_without_tools, Agent, FlowFuture, Message};

pub fn default_flow<'a>(agent: &'a mut Agent, prompt: String) -> FlowFuture<'a> {
    Box::pin(async move {
        agent.history.push(Message::user(prompt));
        let mut response = invoke(agent).await?;
        if let Some(tc) = response.message.tool_calls {
            for tool_msg in call_tools(agent, &tc).await {
                agent.history.push(tool_msg);
            }
            response = invoke_without_tools(agent).await?;
        } 

        agent.notify(crate::NotificationContent::Done(true, response.message.content.clone())).await;
        Ok(response.message)
    })    
}