pub struct MagenticBuilder { /* private fields */ }Expand description
Builder for a Magentic workflow. Rust analogue of MagenticBuilder.
let manager = StandardMagenticManager::new(manager_agent);
let workflow = MagenticBuilder::new()
.participant("coder", coder)
.participant("researcher", researcher)
.standard_manager(manager)
.max_round_count(10)
.build()?;Implementations§
Source§impl MagenticBuilder
impl MagenticBuilder
Sourcepub fn new() -> MagenticBuilder
pub fn new() -> MagenticBuilder
Create an empty builder.
Sourcepub fn participant(
self,
name: impl Into<String>,
agent: Arc<dyn SupportsAgentRun>,
) -> MagenticBuilder
pub fn participant( self, name: impl Into<String>, agent: Arc<dyn SupportsAgentRun>, ) -> MagenticBuilder
Register a participant (its description defaults to its name).
Sourcepub fn participant_described(
self,
name: impl Into<String>,
description: impl Into<String>,
agent: Arc<dyn SupportsAgentRun>,
) -> MagenticBuilder
pub fn participant_described( self, name: impl Into<String>, description: impl Into<String>, agent: Arc<dyn SupportsAgentRun>, ) -> MagenticBuilder
Register a participant with an explicit description (shown to the manager).
Sourcepub fn participants(
self,
participants: impl IntoIterator<Item = (String, Arc<dyn SupportsAgentRun>)>,
) -> MagenticBuilder
pub fn participants( self, participants: impl IntoIterator<Item = (String, Arc<dyn SupportsAgentRun>)>, ) -> MagenticBuilder
Register several participants as (name, agent) pairs.
Sourcepub fn manager(self, manager: Arc<dyn MagenticManager>) -> MagenticBuilder
pub fn manager(self, manager: Arc<dyn MagenticManager>) -> MagenticBuilder
Use a custom MagenticManager.
Sourcepub fn standard_manager(
self,
manager: StandardMagenticManager,
) -> MagenticBuilder
pub fn standard_manager( self, manager: StandardMagenticManager, ) -> MagenticBuilder
Use a StandardMagenticManager (convenience wrapper around
MagenticBuilder::manager).
Sourcepub fn max_round_count(self, n: usize) -> MagenticBuilder
pub fn max_round_count(self, n: usize) -> MagenticBuilder
Override the maximum number of rounds.
Sourcepub fn max_stall_count(self, n: usize) -> MagenticBuilder
pub fn max_stall_count(self, n: usize) -> MagenticBuilder
Override the stall threshold.
Sourcepub fn max_reset_count(self, n: usize) -> MagenticBuilder
pub fn max_reset_count(self, n: usize) -> MagenticBuilder
Override the maximum number of replans.
Sourcepub fn name(self, name: impl Into<String>) -> MagenticBuilder
pub fn name(self, name: impl Into<String>) -> MagenticBuilder
Set the workflow name.
Sourcepub fn with_plan_review(self) -> MagenticBuilder
pub fn with_plan_review(self) -> MagenticBuilder
Require a human to review and approve (or send back for revision) the
initial plan before the coordination round loop starts. See the
module-level docs for the full request/response loop semantics. Rust
analogue of Python’s MagenticBuilder.with_plan_review(enable=True).
Sourcepub fn max_plan_review_rounds(self, n: u32) -> MagenticBuilder
pub fn max_plan_review_rounds(self, n: u32) -> MagenticBuilder
Override the maximum number of plan-review revise rounds before the
orchestrator force-proceeds with whatever plan is current (default 10,
matching Python). Only meaningful with Self::with_plan_review.
Sourcepub fn with_stall_intervention(self) -> MagenticBuilder
pub fn with_stall_intervention(self) -> MagenticBuilder
Pause for a human decision when the round loop detects a stall, instead
of silently auto-replanning. When stall_count exceeds
max_stall_count the orchestrator emits a
MagenticStallInterventionRequest via
WorkflowContext::request_info and suspends until a
MagenticStallInterventionDecision is supplied. See the module-level
docs for the full loop semantics. Rust analogue of Python’s
MagenticBuilder.with_human_input_on_stall(enable=True).
Sourcepub fn output_from(
self,
names: impl IntoIterator<Item = impl Into<String>>,
) -> MagenticBuilder
pub fn output_from( self, names: impl IntoIterator<Item = impl Into<String>>, ) -> MagenticBuilder
Designate participants (by the name passed to
Self::participant/Self::participant_described) as a workflow
output source, forwarded to WorkflowBuilder::output_from.
Divergence from Sequential/Concurrent: like
GroupChatBuilder,
Magentic compiles to a single orchestrator Executor that drives
the whole plan/round loop internally (see the module-level design
note) rather than one executor per participant, so there is no
per-participant executor id to route to individually. Naming any
participant here keeps the orchestrator’s single final yield — the
synthesized final answer — as the terminal
WorkflowEvent::Output
(already the default). Call Self::intermediate_output_from
instead to demote it to a non-terminal
WorkflowEvent::Intermediate
event when composing Magentic into a larger workflow.
Rejected at build() if a name does not match any registered
participant, or if this and Self::intermediate_output_from are
both non-empty (both resolve to the same underlying executor id).
Sourcepub fn intermediate_output_from(
self,
names: impl IntoIterator<Item = impl Into<String>>,
) -> MagenticBuilder
pub fn intermediate_output_from( self, names: impl IntoIterator<Item = impl Into<String>>, ) -> MagenticBuilder
Designate participants (by name) as an intermediate-output source,
demoting the orchestrator’s single final yield to a non-terminal
WorkflowEvent::Intermediate
event instead of the workflow’s terminal output. See
Self::output_from for the single-executor caveat.