codetether_agent/agent/swarm/
handler_impl.rs1use super::task_execution::unsupported_message_response;
13use crate::agent::Agent;
14use crate::swarm::{Handler, SwarmMessage};
15use anyhow::Result;
16use async_trait::async_trait;
17
18#[async_trait]
19impl Handler<SwarmMessage> for Agent {
20 type Response = SwarmMessage;
21
22 async fn handle(&mut self, message: SwarmMessage) -> Result<Self::Response> {
23 match message {
24 SwarmMessage::ExecuteTask {
25 task_id,
26 instruction,
27 } => self.handle_task_execution(task_id, instruction).await,
28 SwarmMessage::ToolRequest { tool_id, arguments } => {
29 self.handle_tool_request(tool_id, arguments).await
30 }
31 SwarmMessage::Progress { .. }
32 | SwarmMessage::TaskCompleted { .. }
33 | SwarmMessage::TaskFailed { .. }
34 | SwarmMessage::ToolResponse { .. } => Ok(unsupported_message_response()),
35 }
36 }
37}