pub struct SwarmBuilder { /* private fields */ }Expand description
Builds a Swarm.
Implementations§
Source§impl SwarmBuilder
impl SwarmBuilder
Sourcepub fn agent(self, agent: Agent) -> Self
pub fn agent(self, agent: Agent) -> Self
Add an agent. It needs a name, which the others hand off to; its description tells them what it is for.
The swarm adds the handoff_to_agent tool to the
agent’s tool set, which clones of the agent share.
Each run of the agent gets max_turns_per_agent
model calls, or the agent’s own
default_max_turns if
that is higher. Rig’s own default of one turn is never used here, so a
refused handoff, or a tool whose result the agent must read, gets its
follow-up answer.
Sourcepub fn entry(self, name: impl Into<String>) -> Self
pub fn entry(self, name: impl Into<String>) -> Self
The agent the run starts with. Defaults to the first one added.
Sourcepub fn max_handoffs(self, max_handoffs: usize) -> Self
pub fn max_handoffs(self, max_handoffs: usize) -> Self
How many handoffs a run may make before it fails. Defaults to 20.
Sourcepub fn max_turns_per_agent(self, max_turns: usize) -> Self
pub fn max_turns_per_agent(self, max_turns: usize) -> Self
How many model calls one agent’s run may make, counting the first call
and every follow-up after a tool call. Applies to each agent run; an
agent whose own default_max_turns is higher keeps its own. Defaults
to 8; zero fails the build with BuildError::ZeroTurns. A handoff
ends the run at once, so the budget only has to cover the tool calls an
agent makes before it answers or hands off.
Sourcepub fn execution_timeout(self, timeout: Duration) -> Self
pub fn execution_timeout(self, timeout: Duration) -> Self
How long a whole run may take. Defaults to 15 minutes.
Sourcepub fn agent_timeout(self, timeout: Duration) -> Self
pub fn agent_timeout(self, timeout: Duration) -> Self
How long one agent’s turn may take. Defaults to 5 minutes.
Sourcepub fn detect_repetition(self, window: usize, min_unique: usize) -> Self
pub fn detect_repetition(self, window: usize, min_unique: usize) -> Self
Fail a run whose last window turns went to fewer than min_unique
distinct agents: two agents passing the work back and forth. Off by
default.
Sourcepub fn allow_questions(self) -> Self
pub fn allow_questions(self) -> Self
Sourcepub fn checkpoints(
self,
store: impl AsyncStore + WasmCompatSend + WasmCompatSync + 'static,
) -> Self
pub fn checkpoints( self, store: impl AsyncStore + WasmCompatSend + WasmCompatSync + 'static, ) -> Self
Sourcepub fn build(self) -> Result<Swarm, BuildError>
pub fn build(self) -> Result<Swarm, BuildError>
Check the agents and give each one the handoff tool.