pub struct MicroAgentBuilder<Ctx> {
pub storage: Box<dyn AgentStorage>,
pub parallel_tool_calls: bool,
/* private fields */
}Expand description
Builder for MicroAgent.
§Example
use microagents_core::agent::MicroAgentBuilder;
use microagents_core::types::ToolExecutionContext;
let agent = MicroAgentBuilder::new(ToolExecutionContext::new(()))
.provider("openai".into()).unwrap()
.model("gpt-5.5".into())
.build()
.expect("API key must be set");Fields§
§storage: Box<dyn AgentStorage>§parallel_tool_calls: boolImplementations§
Source§impl<Ctx: Send + Sync + 'static> MicroAgentBuilder<Ctx>
impl<Ctx: Send + Sync + 'static> MicroAgentBuilder<Ctx>
Sourcepub fn new(tool_context: ToolExecutionContext<Ctx>) -> Self
pub fn new(tool_context: ToolExecutionContext<Ctx>) -> Self
Create a new builder with the given tool execution context.
The skills tool is registered automatically.
Sourcepub fn add_skill(
self,
skill_name: String,
) -> Result<Self, MicroAgentBuilderError>
pub fn add_skill( self, skill_name: String, ) -> Result<Self, MicroAgentBuilderError>
Register a single skill by name.
Searches .agents/skills/{name} then ~/.agents/skills/{name}.
Sourcepub fn find_skills(self) -> Result<Self, MicroAgentBuilderError>
pub fn find_skills(self) -> Result<Self, MicroAgentBuilderError>
Auto-discover and register all skills found in the local and global skills directories.
Sourcepub fn provider(self, provider: String) -> Result<Self, MicroAgentBuilderError>
pub fn provider(self, provider: String) -> Result<Self, MicroAgentBuilderError>
Set the LLM provider (e.g. "openai", "groq", "ollama").
Sourcepub fn model(self, model: String) -> Self
pub fn model(self, model: String) -> Self
Set the model identifier. If empty, the provider’s default is used.
Sourcepub fn parallel_tool_calls(self, parallel_tool_calls: bool) -> Self
pub fn parallel_tool_calls(self, parallel_tool_calls: bool) -> Self
Enable or disable parallel tool execution.
Sourcepub async fn storage(
self,
storage: AgentStorageChoice,
) -> Result<Self, MicroAgentBuilderError>
pub async fn storage( self, storage: AgentStorageChoice, ) -> Result<Self, MicroAgentBuilderError>
Configure the session storage backend.
Sourcepub fn add_tool(
self,
tool: Arc<dyn ToolFunction<Ctx>>,
) -> Result<Self, MicroAgentBuilderError>
pub fn add_tool( self, tool: Arc<dyn ToolFunction<Ctx>>, ) -> Result<Self, MicroAgentBuilderError>
Register a custom tool.
Sourcepub fn custom_instructions(self, instructions: String) -> Self
pub fn custom_instructions(self, instructions: String) -> Self
Append free-form instructions to the system prompt.
Sourcepub fn build(self) -> Result<MicroAgent<Ctx>, MicroAgentBuilderError>
pub fn build(self) -> Result<MicroAgent<Ctx>, MicroAgentBuilderError>
Finalise the builder and return a MicroAgent.
Fails early if a required API key is missing for the chosen provider.
Trait Implementations§
Auto Trait Implementations§
impl<Ctx> !RefUnwindSafe for MicroAgentBuilder<Ctx>
impl<Ctx> !UnwindSafe for MicroAgentBuilder<Ctx>
impl<Ctx> Freeze for MicroAgentBuilder<Ctx>
impl<Ctx> Send for MicroAgentBuilder<Ctx>
impl<Ctx> Sync for MicroAgentBuilder<Ctx>
impl<Ctx> Unpin for MicroAgentBuilder<Ctx>
impl<Ctx> UnsafeUnpin for MicroAgentBuilder<Ctx>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more