Skip to main content

AgentFactory

Struct AgentFactory 

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

Factory for creating sets of three MAGI agents with provider and prompt overrides.

Supports a default provider shared by all agents, per-agent provider overrides, and custom prompt overrides. Always creates agents in order: [Melchior, Balthasar, Caspar].

Implementations§

Source§

impl AgentFactory

Source

pub fn new(default_provider: Arc<dyn LlmProvider>) -> Self

Creates a factory with a default provider shared by all three agents.

§Parameters
  • default_provider: The LLM provider used for agents without a specific override.
Source

pub fn with_provider( self, name: AgentName, provider: Arc<dyn LlmProvider>, ) -> Self

Registers a provider override for a specific agent.

§Parameters
  • name: Which agent to override.
  • provider: The provider to use for this agent.
Source

pub fn with_custom_prompt(self, name: AgentName, prompt: String) -> Self

Registers a custom prompt override for a specific agent across all modes.

§Parameters
  • name: Which agent to override.
  • prompt: The custom system prompt applied to every analysis mode.
Source

pub fn from_directory(self, dir: &Path) -> Result<Self, MagiError>

Loads custom prompts from a directory of markdown files.

Expected filenames: {agent}_{mode}.md (e.g., melchior_code_review.md). Only loads files that exist; missing files use the default compiled-in prompts. Returns MagiError::Io if the directory itself does not exist.

§Errors

Returns MagiError::Io if the directory does not exist or cannot be read.

Source

pub fn create_agents(&self, mode: Mode) -> Vec<Agent>

👎Deprecated since 0.3.0:

create_agents does NOT apply overrides set via MagiBuilder::with_custom_prompt_for_mode / with_custom_prompt_all_modes. If you need overrides, call create_agents_with_prompts(mode, &overrides) directly, or (preferred) use MagiBuilder::build() which wires overrides automatically. See docs/migration-v0.3.md §3 for the correct upgrade path.

Creates exactly three agents for the given mode.

Returns agents in fixed order: [Melchior, Balthasar, Caspar]. Each agent uses its specific provider override or the default provider, and its custom prompt override or the compiled-in default prompt.

§Parameters
  • mode: The analysis mode for all three agents.
§Deprecation

Use AgentFactory::create_agents_with_prompts or crate::orchestrator::MagiBuilder::build instead. Those paths respect the v0.3 overrides map set via with_custom_prompt_for_mode / with_custom_prompt_all_modes. This method falls back to embedded defaults only (ignores orchestrator-level overrides) and will be removed in v0.4.0.

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, 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, 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.