pub struct AgentRegistry { /* private fields */ }Expand description
Tracks active sub-agents and enforces spawn limits.
§Lifecycle
register() → status=Idle
→ set_status(Running) on followup_task
→ set_status(Done) on completion
→ close() removes from registryDone agents still count toward the quota until explicitly close()d.
There is no automatic garbage collection in v1.
Implementations§
Source§impl AgentRegistry
impl AgentRegistry
Sourcepub fn new(config: MultiAgentConfig) -> Self
pub fn new(config: MultiAgentConfig) -> Self
Create a new registry with the given configuration.
Sourcepub fn can_spawn(&self, depth: i32) -> Result<(), SpawnError>
pub fn can_spawn(&self, depth: i32) -> Result<(), SpawnError>
Check whether a new agent can be spawned at the given depth.
Returns Ok(()) if spawning is allowed, or a SpawnError describing
which limit was exceeded.
Sourcepub fn register(
&mut self,
path: &AgentPath,
depth: i32,
tool_count: usize,
) -> Result<(), SpawnError>
pub fn register( &mut self, path: &AgentPath, depth: i32, tool_count: usize, ) -> Result<(), SpawnError>
Register a new agent.
Returns Ok(()) on success, or a SpawnError if limits are exceeded
or the path already exists.
Sourcepub fn close(&mut self, path: &AgentPath) -> Option<AgentEntry>
pub fn close(&mut self, path: &AgentPath) -> Option<AgentEntry>
Close (remove) an agent from the registry.
Returns the removed entry, or None if the agent was not registered.
This releases the agent’s quota slot.
Sourcepub fn set_status(&mut self, path: &AgentPath, status: AgentStatus) -> bool
pub fn set_status(&mut self, path: &AgentPath, status: AgentStatus) -> bool
Update the lifecycle status of an agent.
Returns true if the agent was found and updated.
Sourcepub fn get(&self, path: &AgentPath) -> Option<&AgentEntry>
pub fn get(&self, path: &AgentPath) -> Option<&AgentEntry>
Get an agent entry by path.
Sourcepub fn list(&self) -> Vec<&AgentEntry>
pub fn list(&self) -> Vec<&AgentEntry>
List all registered agents (all statuses).
Sourcepub fn count_by_status(&self, status: &AgentStatus) -> usize
pub fn count_by_status(&self, status: &AgentStatus) -> usize
Return the number of agents with a specific status.
Sourcepub fn config(&self) -> &MultiAgentConfig
pub fn config(&self) -> &MultiAgentConfig
Get a reference to the configuration.