pub struct Subagents { /* private fields */ }Expand description
Owns the child sessions, shared capacity, and tool state for one agent runtime.
Implementations§
Source§impl Subagents
impl Subagents
Sourcepub fn new(
max_concurrency: usize,
) -> (Self, UnboundedReceiver<ScopedAgentUpdate>)
pub fn new( max_concurrency: usize, ) -> (Self, UnboundedReceiver<ScopedAgentUpdate>)
Creates an isolated runtime and its typed update stream.
The receiver carries model events as well as lifecycle changes. Keep it alive and drain it continuously for the lifetime of the runtime. Dropping it ends event forwarding and makes later lifecycle changes unobservable. A zero concurrency limit creates the runtime but rejects child turns until the limit is raised.
Sourcepub fn downgrade(&self) -> WeakSubagents
pub fn downgrade(&self) -> WeakSubagents
Returns a non-owning handle for tool factories and other runtime-owned callbacks.
Sourcepub fn set_agent_factory<F>(
&self,
thinking: Thinking,
fast_mode: bool,
factory: F,
) -> Result<(), NanocodexError>where
F: Fn(Model, Thinking, bool) -> Result<(Nanocodex, AgentEvents), NanocodexError> + Send + Sync + 'static,
pub fn set_agent_factory<F>(
&self,
thinking: Thinking,
fast_mode: bool,
factory: F,
) -> Result<(), NanocodexError>where
F: Fn(Model, Thinking, bool) -> Result<(Nanocodex, AgentEvents), NanocodexError> + Send + Sync + 'static,
Configures how clean child sessions are constructed.
The factory must return a new session and its event stream on every call. The runtime
supplies the requested model and the current inherited settings. A runtime accepts exactly
one factory; a second call returns NanocodexError::InvalidRequest.
§Errors
Returns NanocodexError::InvalidRequest if a factory is already configured.
Returns a root-session authority checker for application-owned tools.
Sourcepub fn set_max_concurrency(&self, limit: usize)
pub fn set_max_concurrency(&self, limit: usize)
Changes the maximum number of concurrently active child turns.
Lowering the limit does not cancel active turns. New reservations fail until the active count falls below the new limit.
Sourcepub fn set_thinking(&self, thinking: Thinking)
pub fn set_thinking(&self, thinking: Thinking)
Changes the reasoning effort inherited by newly created child sessions.
Sourcepub fn set_fast_mode(&self, enabled: bool)
pub fn set_fast_mode(&self, enabled: bool)
Changes the fast-mode setting inherited by newly created child sessions.
Sourcepub async fn cancel_all(&self, root_session_id: &str)
pub async fn cancel_all(&self, root_session_id: &str)
Attempts to interrupt every active child without closing reusable sessions.
Shutdown is best effort and bounded. Individual child failures are reflected in updates.
Sourcepub async fn close_all(&self, root_session_id: &str)
pub async fn close_all(&self, root_session_id: &str)
Attempts to close and join every child owned by a root session.
Shutdown is best effort and bounded. Individual child failures are reflected in updates.
Sourcepub fn runtime_id(&self) -> SubagentRuntimeId
pub fn runtime_id(&self) -> SubagentRuntimeId
Returns the identity used to reject updates from a replaced runtime.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Subagents
impl !UnwindSafe for Subagents
impl Freeze for Subagents
impl Send for Subagents
impl Sync for Subagents
impl Unpin for Subagents
impl UnsafeUnpin for Subagents
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.