pub struct SubagentIndex {
pub name: String,
pub description: String,
pub allowed_tools: Vec<String>,
pub source: ContentSource,
pub source_type: SourceType,
pub model: Option<String>,
pub model_type: Option<ModelType>,
pub skills: Vec<String>,
}Expand description
Subagent index entry - minimal metadata always available in context.
This enables the progressive disclosure pattern where:
- Metadata (~30 tokens per subagent) is always in the Task tool description
- Full prompt (~200 tokens per subagent) is loaded only when spawned
§Token Efficiency
With 10 subagents:
- Index only: 10 × 30 = ~300 tokens
- Full load: 10 × 200 = ~2,000 tokens
- Savings: ~85%
Fields§
§name: StringSubagent name (unique identifier)
description: StringSubagent description - used by Claude for semantic matching
allowed_tools: Vec<String>Allowed tools for this subagent (if restricted)
source: ContentSourceSource location for loading full prompt
source_type: SourceTypeSource type (builtin, user, project, managed)
model: Option<String>Optional model alias or ID
model_type: Option<ModelType>Model type for resolution
skills: Vec<String>Skills available to this subagent
Implementations§
Source§impl SubagentIndex
impl SubagentIndex
Sourcepub fn new(name: impl Into<String>, description: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, description: impl Into<String>) -> Self
Create a new subagent index entry.
Sourcepub fn with_allowed_tools(
self,
tools: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn with_allowed_tools( self, tools: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Set allowed tools.
Sourcepub fn with_tools(
self,
tools: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn with_tools( self, tools: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Alias for with_allowed_tools() for convenience.
Sourcepub fn with_source(self, source: ContentSource) -> Self
pub fn with_source(self, source: ContentSource) -> Self
Set the content source (prompt).
Sourcepub fn with_source_type(self, source_type: SourceType) -> Self
pub fn with_source_type(self, source_type: SourceType) -> Self
Set the source type.
Sourcepub fn with_model(self, model: impl Into<String>) -> Self
pub fn with_model(self, model: impl Into<String>) -> Self
Set the model alias or ID.
Sourcepub fn with_model_type(self, model_type: ModelType) -> Self
pub fn with_model_type(self, model_type: ModelType) -> Self
Set the model type.
Sourcepub fn with_skills(
self,
skills: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn with_skills( self, skills: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Set available skills.
Sourcepub fn resolve_model<'a>(&'a self, config: &'a ModelConfig) -> &'a str
pub fn resolve_model<'a>(&'a self, config: &'a ModelConfig) -> &'a str
Resolve the model to use for this subagent.
Supports both direct model IDs and aliases:
"opus"→ resolves to reasoning model (e.g., claude-opus-4-5)"sonnet"→ resolves to primary model (e.g., claude-sonnet-4-5)"haiku"→ resolves to small model (e.g., claude-haiku-4-5)- Direct model ID → passed through unchanged
Falls back to model_type if model is not set.
Sourcepub async fn load_prompt(&self) -> Result<String>
pub async fn load_prompt(&self) -> Result<String>
Load the full prompt content.
Trait Implementations§
Source§impl Clone for SubagentIndex
impl Clone for SubagentIndex
Source§fn clone(&self) -> SubagentIndex
fn clone(&self) -> SubagentIndex
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SubagentIndex
impl Debug for SubagentIndex
Source§impl<'de> Deserialize<'de> for SubagentIndex
impl<'de> Deserialize<'de> for SubagentIndex
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Index for SubagentIndex
impl Index for SubagentIndex
Source§fn source(&self) -> &ContentSource
fn source(&self) -> &ContentSource
Source§fn source_type(&self) -> SourceType
fn source_type(&self) -> SourceType
Source§fn to_summary_line(&self) -> String
fn to_summary_line(&self) -> String
Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl Serialize for SubagentIndex
impl Serialize for SubagentIndex
Source§impl ToolRestricted for SubagentIndex
impl ToolRestricted for SubagentIndex
fn allowed_tools(&self) -> &[String]
fn has_tool_restrictions(&self) -> bool
fn is_tool_allowed(&self, tool_name: &str) -> bool
Auto Trait Implementations§
impl Freeze for SubagentIndex
impl RefUnwindSafe for SubagentIndex
impl Send for SubagentIndex
impl Sync for SubagentIndex
impl Unpin for SubagentIndex
impl UnwindSafe for SubagentIndex
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<D> DeserializeWith<JsonFormat> for Dwhere
D: DeserializeOwned,
impl<D> DeserializeWith<JsonFormat> for Dwhere
D: DeserializeOwned,
Source§fn deserialize_with(body: ResponseBody) -> Result<D, Error>
fn deserialize_with(body: ResponseBody) -> Result<D, Error>
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more