Skip to main content

Agent

Struct Agent 

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

An autonomous MAGI agent with its own identity, system prompt, and LLM provider.

Each agent combines an AgentName identity, a mode-agnostic system prompt (v0.3.0+), and an LlmProvider backend. The agent delegates LLM communication to its provider via execute.

Implementations§

Source§

impl Agent

Source

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

Creates an agent with a mode-agnostic system prompt for the given name.

The prompt is selected from compiled-in markdown files via include_str!. As of v0.3.0 the mode parameter has been removed; the agent uses a single consolidated prompt per identity. Mode routing is handled by the orchestrator.

§Parameters
  • name: Which MAGI agent (Melchior, Balthasar, Caspar).
  • provider: The LLM backend for this agent.
Source

pub fn with_custom_prompt( name: AgentName, provider: Arc<dyn LlmProvider>, prompt: String, ) -> Self

Creates an agent with a custom system prompt, bypassing the compiled-in defaults.

§Parameters
  • name: Which MAGI agent.
  • provider: The LLM backend.
  • prompt: Custom system prompt string.
Source

pub fn from_file( name: AgentName, provider: Arc<dyn LlmProvider>, path: &Path, ) -> Result<Self, MagiError>

Creates an agent by loading the system prompt from a filesystem path.

Returns MagiError::Io if the file cannot be read.

§Parameters
  • name: Which MAGI agent.
  • provider: The LLM backend.
  • path: Path to the prompt file.
§Errors

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

Source

pub async fn execute( &self, user_prompt: &str, config: &CompletionConfig, ) -> Result<String, ProviderError>

Executes the agent by sending the user prompt to the LLM provider.

Delegates to LlmProvider::complete with this agent’s system prompt. Returns the raw LLM response string — parsing is the orchestrator’s responsibility.

§Parameters
  • user_prompt: The user’s input content.
  • config: Completion parameters (max_tokens, temperature).
§Errors

Returns ProviderError on LLM communication failure.

Source

pub fn name(&self) -> AgentName

Returns the agent’s name.

Source

pub fn system_prompt(&self) -> &str

Returns the agent’s system prompt.

Source

pub fn provider_name(&self) -> &str

Returns the provider’s name (e.g., “claude”, “openai”).

Source

pub fn provider_model(&self) -> &str

Returns the provider’s model identifier.

Source

pub fn display_name(&self) -> &str

Returns the agent’s display name (e.g., “Melchior”).

Source

pub fn title(&self) -> &str

Returns the agent’s analytical role title (e.g., “Scientist”).

Auto Trait Implementations§

§

impl Freeze for Agent

§

impl !RefUnwindSafe for Agent

§

impl Send for Agent

§

impl Sync for Agent

§

impl Unpin for Agent

§

impl UnsafeUnpin for Agent

§

impl !UnwindSafe for Agent

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.