Watch
0
0
Fork
You've already forked hyperhive
0

swarm: /clear starts an agent's next turn on a fresh session

This commit is contained in:
iris 2026-11-16 01:01:31 +01:00
commit fb9d4b5040

View file

@ -18,11 +18,15 @@ use crate::routes::AppState;
/// The commands the swarm UI offers every agent: the name without the slash,
/// and what it does.
const COMMANDS: [(&str, &str); 2] = [
const COMMANDS: [(&str, &str); 3] = [
(
"compact",
"Compact this agent's context after the current turn",
),
(
"clear",
"Start the next turn on a fresh session, dropping this one's context",
),
("clear-todos", "Mark all of this agent's todos done"),
];
@ -164,7 +168,7 @@ mod tests {
#[test]
fn the_swarms_commands_come_first_and_always() {
let list = build(None);
assert_eq!(names(&list), ["compact", "clear-todos"]);
assert_eq!(names(&list), ["compact", "clear", "clear-todos"]);
assert!(list.iter().all(|e| e.kind == CommandKind::Command));
}
@ -173,8 +177,11 @@ mod tests {
let list = build(Some(Skills {
skills: vec![skill("zeta", "z"), skill("alpha", "a")],
}));
assert_eq!(names(&list), ["compact", "clear-todos", "alpha", "zeta"]);
assert_eq!(list[2].kind, CommandKind::Skill);
assert_eq!(
names(&list),
["compact", "clear", "clear-todos", "alpha", "zeta"]
);
assert_eq!(list[3].kind, CommandKind::Skill);
}
/// What the agent publishes is untrusted: a skill cannot take a command's
@ -184,15 +191,16 @@ mod tests {
let list = build(Some(Skills {
skills: vec![
skill("compact", "pretends to be the command"),
skill("clear", "so does this"),
skill("good", "one"),
skill("good", "two"),
skill("two words", "not a word"),
skill("", "empty"),
],
}));
assert_eq!(names(&list), ["compact", "clear-todos", "good"]);
assert_eq!(names(&list), ["compact", "clear", "clear-todos", "good"]);
assert_eq!(list[0].kind, CommandKind::Command);
assert_eq!(list[2].description, "one");
assert_eq!(list[3].description, "one");
}
#[test]