Skip to main content

a3s_code_core/orchestrator/
control.rs

1//! 控制信号定义
2
3use serde::{Deserialize, Serialize};
4
5/// 控制信号 - 主智能体发送给子智能体的指令
6#[derive(Debug, Clone, Serialize, Deserialize)]
7#[serde(tag = "type", rename_all = "snake_case")]
8pub enum ControlSignal {
9    /// 暂停执行
10    Pause,
11
12    /// 恢复执行
13    Resume,
14
15    /// 取消执行
16    Cancel,
17
18    /// 调整参数
19    AdjustParams {
20        #[serde(skip_serializing_if = "Option::is_none")]
21        max_steps: Option<usize>,
22        #[serde(skip_serializing_if = "Option::is_none")]
23        timeout_ms: Option<u64>,
24    },
25
26    /// 注入新提示词
27    InjectPrompt { prompt: String },
28}
29
30impl std::fmt::Display for ControlSignal {
31    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32        match self {
33            ControlSignal::Pause => write!(f, "pause"),
34            ControlSignal::Resume => write!(f, "resume"),
35            ControlSignal::Cancel => write!(f, "cancel"),
36            ControlSignal::AdjustParams { .. } => write!(f, "adjust_params"),
37            ControlSignal::InjectPrompt { .. } => write!(f, "inject_prompt"),
38        }
39    }
40}