Skip to main content

codetether_agent/agent/swarm/
actor_impl.rs

1//! Swarm actor lifecycle for agents.
2//!
3//! This module provides the lightweight lifecycle hooks required by the swarm
4//! runtime when it manages an `Agent` actor.
5//!
6//! # Examples
7//!
8//! ```ignore
9//! let status = agent.actor_status();
10//! ```
11
12use crate::agent::Agent;
13use crate::swarm::{Actor, ActorStatus};
14use anyhow::Result;
15use async_trait::async_trait;
16
17#[async_trait]
18impl Actor for Agent {
19    fn actor_id(&self) -> &str {
20        &self.info.name
21    }
22    fn actor_status(&self) -> ActorStatus {
23        ActorStatus::Ready
24    }
25
26    async fn initialize(&mut self) -> Result<()> {
27        tracing::info!(agent = %self.info.name, "Agent initialized for swarm participation");
28        Ok(())
29    }
30
31    async fn shutdown(&mut self) -> Result<()> {
32        tracing::info!(agent = %self.info.name, "Agent shutting down");
33        Ok(())
34    }
35}