pub struct SubAgentConfig {
pub name: String,
pub description: String,
pub instructions: String,
pub model: Option<Arc<dyn LanguageModel>>,
pub tools: Option<Vec<ToolBox>>,
pub builtin_tools: Option<HashSet<String>>,
pub enable_prompt_caching: bool,
}
Expand description
Configuration for creating and registering a subagent using a simple, Python-like shape.
Configuration for a sub-agent - a full AI agent with its own LLM, tools, and memory.
A sub-agent is just like the main agent: it has its own system instructions,
tools, LLM, and can maintain its own conversation history. The main agent
delegates tasks to sub-agents via the task
tool.
§Required Fields:
name
: Unique identifier for this sub-agentdescription
: What this sub-agent specializes in (shown to main agent)instructions
: System prompt for this sub-agent
§Optional Fields:
model
: LLM to use (defaults to parent agent’s model if not specified)tools
: Tools available to this sub-agent (defaults to empty)builtin_tools
: Built-in tools to enable (filesystem, todos, etc.)enable_prompt_caching
: Whether to cache prompts for efficiency
Fields§
§name: String
§description: String
§instructions: String
§model: Option<Arc<dyn LanguageModel>>
§tools: Option<Vec<ToolBox>>
§builtin_tools: Option<HashSet<String>>
§enable_prompt_caching: bool
Implementations§
Source§impl SubAgentConfig
impl SubAgentConfig
Sourcepub fn new(
name: impl Into<String>,
description: impl Into<String>,
instructions: impl Into<String>,
) -> Self
pub fn new( name: impl Into<String>, description: impl Into<String>, instructions: impl Into<String>, ) -> Self
Create a new sub-agent configuration with required fields only
Sourcepub fn with_model(self, model: Arc<dyn LanguageModel>) -> Self
pub fn with_model(self, model: Arc<dyn LanguageModel>) -> Self
Set the LLM model for this sub-agent
Sourcepub fn with_tools(self, tools: Vec<ToolBox>) -> Self
pub fn with_tools(self, tools: Vec<ToolBox>) -> Self
Set the tools for this sub-agent
Sourcepub fn with_builtin_tools(self, tools: HashSet<String>) -> Self
pub fn with_builtin_tools(self, tools: HashSet<String>) -> Self
Enable specific built-in tools (filesystem, todos, etc.)
Sourcepub fn with_prompt_caching(self, enabled: bool) -> Self
pub fn with_prompt_caching(self, enabled: bool) -> Self
Enable prompt caching for this sub-agent
Trait Implementations§
Source§impl IntoIterator for SubAgentConfig
impl IntoIterator for SubAgentConfig
Auto Trait Implementations§
impl Freeze for SubAgentConfig
impl !RefUnwindSafe for SubAgentConfig
impl Send for SubAgentConfig
impl Sync for SubAgentConfig
impl Unpin for SubAgentConfig
impl !UnwindSafe for SubAgentConfig
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