pub struct SubAgentDef {
pub name: String,
pub description: String,
pub prompt: String,
pub allowed_tools: Vec<String>,
pub disallowed_tools: Vec<String>,
pub model: Option<String>,
pub max_turns: usize,
pub max_context_tokens: usize,
pub background: bool,
}Expand description
Definition of a subagent — its identity, capabilities, and constraints.
Analogous to a markdown frontmatter file in Claude Code’s subagent system.
Fields§
§name: StringUnique identifier (lowercase, hyphens). E.g. “code-reviewer”.
description: StringWhen the parent agent should delegate to this subagent.
prompt: StringThe system prompt (markdown body). Replaces the default system prompt entirely.
allowed_tools: Vec<String>Allowed tool names. If empty, inherits all default tools. Use this as an allowlist: only these tools will be available.
disallowed_tools: Vec<String>Tool names to explicitly deny. Applied after allowed_tools.
model: Option<String>Model override. If None, inherits from the parent.
max_turns: usizeMaximum agentic turns before the subagent stops.
max_context_tokens: usizeMaximum context window tokens.
background: boolWhether to always run this subagent in the background.
Implementations§
Source§impl SubAgentDef
impl SubAgentDef
Sourcepub fn new(
name: impl Into<String>,
description: impl Into<String>,
prompt: impl Into<String>,
) -> Self
pub fn new( name: impl Into<String>, description: impl Into<String>, prompt: impl Into<String>, ) -> Self
Create a new subagent definition with required fields.
Sourcepub fn with_allowed_tools(self, tools: Vec<String>) -> Self
pub fn with_allowed_tools(self, tools: Vec<String>) -> Self
Restrict the subagent to only these tools.
Sourcepub fn with_disallowed_tools(self, tools: Vec<String>) -> Self
pub fn with_disallowed_tools(self, tools: Vec<String>) -> Self
Deny specific tools (removed from inherited or allowed set).
Sourcepub fn with_model(self, model: impl Into<String>) -> Self
pub fn with_model(self, model: impl Into<String>) -> Self
Override the model for this subagent.
Sourcepub fn with_max_turns(self, max_turns: usize) -> Self
pub fn with_max_turns(self, max_turns: usize) -> Self
Set maximum agentic turns.
Sourcepub fn with_max_context_tokens(self, tokens: usize) -> Self
pub fn with_max_context_tokens(self, tokens: usize) -> Self
Set maximum context window tokens.
Sourcepub fn with_background(self, background: bool) -> Self
pub fn with_background(self, background: bool) -> Self
Set whether to always run in background.
Trait Implementations§
Source§impl Clone for SubAgentDef
impl Clone for SubAgentDef
Source§fn clone(&self) -> SubAgentDef
fn clone(&self) -> SubAgentDef
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more