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
impl AgentTeam
Sourcepub fn new(llm_config: LlmConfig, agent_config: AgentConfig) -> Self
pub fn new(llm_config: LlmConfig, agent_config: AgentConfig) -> Self
Create a new AgentTeam with the given LLM and agent configuration.
Sourcepub fn source_root(self, path: impl Into<PathBuf>) -> Self
pub fn source_root(self, path: impl Into<PathBuf>) -> Self
Set the source root directory (read-only source code).
Sourcepub fn prompt_builder(self, builder: Arc<dyn PromptBuilder>) -> Self
pub fn prompt_builder(self, builder: Arc<dyn PromptBuilder>) -> Self
Set a custom prompt builder.
Sourcepub fn event_channel(self, tx: UnboundedSender<AgentEvent>) -> Self
pub fn event_channel(self, tx: UnboundedSender<AgentEvent>) -> Self
Set an event channel for monitoring agent activity.
Sourcepub fn llm_client(self, client: Arc<dyn LlmClient>) -> Self
pub fn llm_client(self, client: Arc<dyn LlmClient>) -> Self
Provide a pre-created LLM client (skips creating one from config).
Sourcepub fn add_hook(self, hook: impl Hook + 'static) -> Self
pub fn add_hook(self, hook: impl Hook + 'static) -> Self
Add a hook for quality gates (TeammateIdle, TaskCreated, TaskCompleted).
Sourcepub fn add_teammate(
self,
name: impl Into<String>,
prompt: impl Into<String>,
) -> Self
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");Sourcepub fn add_teammate_with_plan_approval(
self,
name: impl Into<String>,
prompt: impl Into<String>,
) -> Self
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.
Sourcepub fn add_task(self, task: Task) -> Self
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);Sourcepub async fn run(self, _goal: &str) -> SdkResult<TeamResult>
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.
Sourcepub async fn run_single(self, user_message: &str) -> SdkResult<AgentLoopResult>
pub async fn run_single(self, user_message: &str) -> SdkResult<AgentLoopResult>
Run as a single agent (no team). For simple, focused tasks.