Watch
0
0
Fork
You've already forked hyperhive
0

allow a max_subagents of 0: no subagents for the agent

This commit is contained in:
damocles 2026-10-15 18:48:22 +02:00 • committed by mara
commit a1f99c77f8
7 changed files with 85 additions and 31 deletions

View file

@ -2590,6 +2590,10 @@ pub fn interrupt(state: &State, name: &str) -> anyhow::Result<String> {
fn refused(state: &State, name: &str, refusal: &Refusal, hint: &str) -> anyhow::Error {
match refusal {
Refusal::Taken => name_taken(state, name, hint),
Refusal::AtCap { cap: 0, .. } => anyhow::anyhow!(
"subagents are disabled for this agent: the cap is 0 (set in swarm-ui → this \
agent → inference)"
),
Refusal::AtCap { running, cap } => anyhow::anyhow!(
"{running} {} running, cap is {cap} (set in swarm-ui → this agent → \
inference) — wait for one to finish, or `interrupt` one",
@ -4688,6 +4692,17 @@ mod tests {
);
}
#[test]
fn a_cap_of_zero_refuses_every_start() {
let state = State::new(PathBuf::from("/dev/null"), signal_url());
assert_eq!(
state.reserve_under("a", Some(0)),
Err(Refusal::AtCap { running: 0, cap: 0 })
);
let msg = refused(&state, "a", &Refusal::AtCap { running: 0, cap: 0 }, "").to_string();
assert!(msg.contains("disabled"), "{msg}");
}
/// A run between turns and one winding down both still count.
#[test]
fn every_tracked_slot_counts_toward_the_cap() {