Skip to main content

AgentTeam

Struct AgentTeam 

Source
pub struct AgentTeam { /* private fields */ }
Expand description

High-level entry point for the agent SDK.

AgentTeam coordinates multiple agent instances working together. One session acts as the team lead, coordinating work, assigning tasks, and synthesizing results. Teammates work independently, each in its own context window, and can communicate directly with each other.

There is no separate planning step — the lead IS the intelligence that decides how to organize work, just like Claude Code’s agent teams.

§Usage patterns

You describe the team — add teammates with roles, add tasks, and run:

let result = AgentTeam::new(LlmConfig::default(), AgentConfig::default())
    .add_teammate("security", "Review for security vulnerabilities")
    .add_teammate("performance", "Review for performance issues")
    .run("Review the auth module")
    .await?;

Single agent — for simple tasks, skip the team entirely:

let result = AgentTeam::new(LlmConfig::default(), AgentConfig::default())
    .run_single("Explain this codebase")
    .await?;

Implementations§

Source§

impl AgentTeam

Source

pub fn new(llm_config: LlmConfig, agent_config: AgentConfig) -> Self

Create a new AgentTeam with the given LLM and agent configuration.

Source

pub fn source_root(self, path: impl Into<PathBuf>) -> Self

Set the source root directory (read-only source code).

Source

pub fn work_dir(self, path: impl Into<PathBuf>) -> Self

Set the working/output directory.

Source

pub fn prompt_builder(self, builder: Arc<dyn PromptBuilder>) -> Self

Set a custom prompt builder.

Source

pub fn event_channel(self, tx: UnboundedSender<AgentEvent>) -> Self

Set an event channel for monitoring agent activity.

Source

pub fn llm_client(self, client: Arc<dyn LlmClient>) -> Self

Provide a pre-created LLM client (skips creating one from config).

Source

pub fn add_hook(self, hook: impl Hook + 'static) -> Self

Add a hook for quality gates (TeammateIdle, TaskCreated, TaskCompleted).

Source

pub fn add_teammate( self, name: impl Into<String>, prompt: impl Into<String>, ) -> Self

Add a named teammate with a specific role.

AgentTeam::new(LlmConfig::default(), AgentConfig::default())
    .add_teammate("security-reviewer", "Review for security vulnerabilities")
    .add_teammate("perf-reviewer", "Review for performance issues");
Source

pub fn add_teammate_with_plan_approval( self, name: impl Into<String>, prompt: impl Into<String>, ) -> Self

Add a teammate that must get plan approval from the lead before implementing. The teammate generates a plan, sends it to the lead for review, and only proceeds after the lead approves.

Source

pub fn add_task(self, task: Task) -> Self

Add a task for the team to work on.

let task1 = Task::new("gen", "Create config", "...", "config.rs");
let task2 = Task::new("gen", "Create server", "...", "server.rs")
    .with_dependencies(vec![task1.id]);

AgentTeam::new(LlmConfig::default(), AgentConfig::default())
    .add_task(task1)
    .add_task(task2);
Source

pub async fn run(self, _goal: &str) -> SdkResult<TeamResult>

Run the team. The lead spawns teammates, they claim tasks from the shared task list, and work until all tasks are done.

Source

pub async fn run_single(self, user_message: &str) -> SdkResult<AgentLoopResult>

Run as a single agent (no team). For simple, focused tasks.

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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