agentmux_srv_core/backend/supervisor/
message.rs1use crate::backend::reactive::sanitize::{quote_in_system_note, supervisor_turn_message};
9
10use super::judge::TEXT_MAX_CHARS;
11use super::SupervisorMode;
12
13const STEADY: &str = "Continue the task you were already doing. Ask the user only if something truly needs them.";
14
15const DRIVE: &str = "Keep going without waiting for confirmation. Research open questions thoroughly, choose the \
16best option on your own judgement, and say what you assumed. Stop and ask only for something irreversible or \
17outward-facing, for something only the user can provide, or if you are blocked.";
18
19const CLOSING: &str = "If the work is done, say so and show the evidence.";
20
21pub fn continuation(mode: SupervisorMode, n: u32, of: u32, reason: &str, next: &str) -> String {
23 let mut body = String::from(if mode == SupervisorMode::Drive { DRIVE } else { STEADY });
24 body.push(' ');
25 body.push_str(CLOSING);
26 let reason = quote(reason);
27 if !reason.is_empty() {
28 body.push_str("\nWhy: ");
29 body.push_str(&reason);
30 }
31 let next = quote(next);
32 if mode == SupervisorMode::Drive && !next.is_empty() {
33 body.push_str("\nSuggested next step: ");
34 body.push_str(&next);
35 }
36 supervisor_turn_message(mode.as_str(), n, of, &body)
37}
38
39fn quote(text: &str) -> String {
41 let quoted = quote_in_system_note(text);
42 if quoted.chars().count() <= TEXT_MAX_CHARS {
43 return quoted;
44 }
45 let mut out: String = quoted.chars().take(TEXT_MAX_CHARS - 1).collect();
46 out.push('…');
47 out
48}