Skip to main content

AutoAgent

Struct AutoAgent 

Source
pub struct AutoAgent {
    pub id: Uuid,
    pub agents: Vec<BoxedAgent>,
    pub execute: bool,
    pub browse: bool,
    pub max_tries: u64,
    pub crud: bool,
    pub auth: bool,
    pub external: bool,
}
Expand description

Orchestrates a pool of agents, running them concurrently on separate Tokio tasks and collecting results.

§Examples

use lmm_agent::prelude::*;

#[derive(Debug, Default, Auto)]
pub struct MyAgent {
    pub persona: Cow<'static, str>,
    pub behavior: Cow<'static, str>,
    pub status: Status,
    pub agent: LmmAgent,
    pub memory: Vec<Message>,
}
#[async_trait]
impl Executor for MyAgent {
    async fn execute<'a>(&'a mut self, _: &'a mut Task, _: bool, _: bool, _: u64) -> Result<()> { Ok(()) }
}
#[tokio::main]
async fn main() {
    let agent = MyAgent {
        persona: "Researcher".into(),
        behavior: "Research Rust.".into(),
        agent: LmmAgent::new("Researcher".into(), "Research Rust.".into()),
        ..Default::default()
    };

    AutoAgent::default()
        .with(agents![agent])
        .build()
        .unwrap()
        .run()
        .await
        .unwrap();
}

Fields§

§id: Uuid

Unique ID for this orchestrator instance.

§agents: Vec<BoxedAgent>

Pool of agents to run.

§execute: bool

Whether agents should execute generated artefacts.

§browse: bool

Whether agents may open browser tabs.

§max_tries: u64

Maximum task-execution attempts per agent.

§crud: bool

CRUD permission scope passed to each agent task.

§auth: bool

Auth permission scope.

§external: bool

External-access permission scope.

Implementations§

Source§

impl AutoAgent

Source

pub fn new() -> Self

Creates a new AutoAgent with default settings.

Source

pub fn id(self, id: Uuid) -> Self

Sets the orchestrator’s unique identifier.

Source

pub fn with<A>(self, agents: A) -> Self
where A: Into<Vec<BoxedAgent>>,

Provides the agent pool.

Use the agents! macro to construct the pool.

Source

pub fn execute(self, execute: bool) -> Self

Sets whether agents should execute generated artefacts (default: true).

Source

pub fn browse(self, browse: bool) -> Self

Sets whether agents may open browser tabs (default: false).

Source

pub fn max_tries(self, max_tries: u64) -> Self

Sets the maximum retry count per agent (default: 1).

Source

pub fn crud(self, enabled: bool) -> Self

Enables/disables CRUD scope for all agents (default: true).

Source

pub fn auth(self, enabled: bool) -> Self

Enables/disables auth scope for all agents (default: false).

Source

pub fn external(self, enabled: bool) -> Self

Enables/disables external-access scope for all agents (default: true).

Source

pub fn build(self) -> Result<Self>

Finalises the builder, returning Err when no agents are registered.

Source

pub async fn run(&self) -> Result<String>

Runs all agents concurrently and waits for every one to finish.

Returns Ok("All agents executed successfully.") when every agent completes without error, or an aggregated error listing all failures.

Trait Implementations§

Source§

impl Default for AutoAgent

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more