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
impl AgentFactory
Sourcepub fn new(default_provider: Arc<dyn LlmProvider>) -> Self
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.
Sourcepub fn with_provider(
self,
name: AgentName,
provider: Arc<dyn LlmProvider>,
) -> Self
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.
Sourcepub fn with_custom_prompt(self, name: AgentName, prompt: String) -> Self
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.
Sourcepub fn from_directory(self, dir: &Path) -> Result<Self, MagiError>
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.
Sourcepub 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.
pub fn create_agents(&self, mode: Mode) -> Vec<Agent>
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.