pub struct SubAgentRunner {
pub work_dir: PathBuf,
pub source_root: PathBuf,
pub llm_client: Arc<dyn LlmClient>,
pub event_tx: Option<UnboundedSender<AgentEvent>>,
pub override_llm_client: Option<Arc<dyn LlmClient>>,
}Expand description
Runs a subagent to completion.
The subagent gets its own AgentLoop with its own context window. It runs
the given task prompt and returns the result. Subagents cannot spawn other
subagents — the spawn_subagent tool is intentionally excluded.
Fields§
§work_dir: PathBuf§source_root: PathBuf§llm_client: Arc<dyn LlmClient>§event_tx: Option<UnboundedSender<AgentEvent>>§override_llm_client: Option<Arc<dyn LlmClient>>Optional override LLM client (for model override).
Implementations§
Source§impl SubAgentRunner
impl SubAgentRunner
pub fn new( work_dir: PathBuf, source_root: PathBuf, llm_client: Arc<dyn LlmClient>, ) -> Self
pub fn with_event_sink(self, tx: UnboundedSender<AgentEvent>) -> Self
pub fn with_override_llm_client(self, client: Arc<dyn LlmClient>) -> Self
Sourcepub async fn run(
&self,
def: &SubAgentDef,
task_prompt: &str,
) -> SdkResult<SubAgentResult>
pub async fn run( &self, def: &SubAgentDef, task_prompt: &str, ) -> SdkResult<SubAgentResult>
Run a subagent with the given definition and task prompt.
Returns the subagent’s result including final content and token usage.
Sourcepub fn run_background(
&self,
def: SubAgentDef,
task_prompt: String,
) -> JoinHandle<SdkResult<SubAgentResult>>
pub fn run_background( &self, def: SubAgentDef, task_prompt: String, ) -> JoinHandle<SdkResult<SubAgentResult>>
Run a subagent in the background, returning a handle to await the result.
Auto Trait Implementations§
impl Freeze for SubAgentRunner
impl !RefUnwindSafe for SubAgentRunner
impl Send for SubAgentRunner
impl Sync for SubAgentRunner
impl Unpin for SubAgentRunner
impl UnsafeUnpin for SubAgentRunner
impl !UnwindSafe for SubAgentRunner
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