Skip to main content

TeamRunner

Struct TeamRunner 

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

Binds an AgentTeam to concrete AgentExecutor sessions, enabling Lead → Worker → Reviewer automated workflows.

Implementations§

Source§

impl TeamRunner

Source

pub fn new(team: AgentTeam) -> Self

Create a new runner wrapping the given team.

Source

pub fn with_agent( team: AgentTeam, agent: Arc<Agent>, workspace: &str, registry: Arc<AgentRegistry>, ) -> Self

Create a runner with a default agent context for simplified member addition.

Unlike TeamRunner::new, this constructor lets you call add_lead, add_worker, and add_reviewer without repeating the agent, workspace, and registry on every call.

Source

pub fn bind_session( &mut self, member_id: &str, executor: Arc<dyn AgentExecutor>, ) -> Result<()>

Bind an executor to a team member.

Returns an error if member_id is not registered in the team.

Source

pub fn bind_agent( &mut self, member_id: &str, agent: &Agent, workspace: &str, agent_name: &str, registry: &AgentRegistry, ) -> Result<()>

Bind a team member to a session created from a named agent definition.

Looks up agent_name in registry, applies the definition’s prompt, permissions, model, and max_steps to a new [AgentSession] via [Agent::session_for_agent], then binds it to member_id.

This is the primary integration point between the AgentTeam coordination layer and the markdown/YAML-defined subagent capability layer.

§Errors

Returns an error if member_id is not in the team, agent_name is not in registry, or session creation fails.

Source

pub fn add_lead( &mut self, agent_name: &str, opts: Option<TeamMemberOptions>, ) -> Result<()>

Add a Lead member and bind it to the named agent definition.

Requires a default agent context set via TeamRunner::with_agent. The member ID is fixed to "lead".

Use opts to override the model, prompt slots, or workspace (e.g. a git worktree).

§Errors

Returns an error if no default context is set or agent_name is not found in the registry.

Source

pub fn add_worker( &mut self, agent_name: &str, opts: Option<TeamMemberOptions>, ) -> Result<()>

Add a Worker member and bind it to the named agent definition.

Requires a default agent context set via TeamRunner::with_agent. Member IDs are auto-generated as "worker-1", "worker-2", etc. Multiple workers can be added; they run concurrently during execution.

Use opts to override the model, prompt slots, or workspace — set workspace to an isolated git worktree path to prevent filesystem conflicts between concurrent workers.

§Errors

Returns an error if no default context is set or agent_name is not found in the registry.

Source

pub fn add_reviewer( &mut self, agent_name: &str, opts: Option<TeamMemberOptions>, ) -> Result<()>

Add a Reviewer member and bind it to the named agent definition.

Requires a default agent context set via TeamRunner::with_agent. The member ID is fixed to "reviewer".

Use opts to override the model, prompt slots, or workspace.

§Errors

Returns an error if no default context is set or agent_name is not found in the registry.

Source

pub fn team_mut(&mut self) -> &mut AgentTeam

Get a mutable reference to the underlying team.

Source

pub fn task_board(&self) -> Arc<TeamTaskBoard>

Access the shared task board.

Source

pub async fn run_until_done(&self, goal: &str) -> Result<TeamRunResult>

Run the full Lead → Worker → Reviewer workflow until all tasks are done or max_rounds retry cycles are exceeded.

Steps:

  1. Lead decomposes goal into tasks via JSON response.
  2. Workers run concurrently until all tasks are in review or done.
  3. Reviewer processes all InReview tasks (after workers finish).
  4. If rejected tasks remain, workers retry them (back to step 2).

Running the reviewer after workers (rather than concurrently) prevents a race where the reviewer’s polling timeout fires before long-running agent calls have produced any InReview tasks.

Trait Implementations§

Source§

impl Debug for TeamRunner

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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