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

@ -0,0 +1,26 @@
// The max-subagents field: empty is no cap, 0 is no subagents, and anything
// that is not a whole number up to the limit is refused. Run by `npm test`.
import assert from "node:assert/strict";
import { test } from "node:test";
import {
MAX_SUBAGENTS,
maxSubagentsValue,
} from "../src/agent/detail/max-subagents.ts";
test("empty is no cap, and 0 is a cap of none rather than empty", () => {
assert.equal(maxSubagentsValue(""), undefined);
assert.equal(maxSubagentsValue(" "), undefined);
assert.equal(maxSubagentsValue("0"), 0);
});
test("a whole number up to the limit is taken as typed", () => {
assert.equal(maxSubagentsValue("1"), 1);
assert.equal(maxSubagentsValue(" 3 "), 3);
assert.equal(maxSubagentsValue(String(MAX_SUBAGENTS)), MAX_SUBAGENTS);
});
test("above the limit, negative, fractional or not a number is refused", () => {
for (const text of [String(MAX_SUBAGENTS + 1), "-1", "1.5", "abc", "1e1"]) {
assert.equal(maxSubagentsValue(text), null, text);
}
});