Skip to main content

aether_core/events/
sub_agent_progress.rs

1use super::AgentEvent;
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5/// A sub-agent's event, tagged with the task and agent it came from.
6///
7/// `mcp-subagents` serializes this into MCP progress notification messages.
8/// The parent agent parses it once at the tool-execution boundary into
9/// `ToolEvent::SubAgentProgress`, so every consumer downstream sees a typed
10/// event instead of JSON in a string.
11#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, JsonSchema)]
12pub struct SubAgentProgressPayload {
13    pub task_id: String,
14    pub agent_name: String,
15    pub event: AgentEvent,
16}
17
18#[cfg(test)]
19mod tests {
20    use super::SubAgentProgressPayload;
21    use crate::events::{AgentEvent, TurnOutcome};
22
23    #[test]
24    fn test_sub_agent_progress_payload_roundtrip() {
25        let payload = SubAgentProgressPayload {
26            task_id: "task_123".to_string(),
27            agent_name: "explorer".to_string(),
28            event: AgentEvent::turn_ended(TurnOutcome::Completed),
29        };
30
31        let json = serde_json::to_string(&payload).expect("serializable");
32        let parsed: SubAgentProgressPayload = serde_json::from_str(&json).expect("deserializable");
33
34        assert_eq!(payload, parsed);
35    }
36}