Watch
0
0
Fork
You've already forked hyperhive
0

swarm ui: a soft context limit field in an agent's inference settings

A whole percent from 5 to 100 of the model's context window, sent as
soft_context_percent next to max_subagents. The inference row shows it, the
edit dialog and the create form take it, and an archetype can carry it.
This commit is contained in:
iris 2026-11-15 15:16:59 +01:00 • committed by mara
commit e9af6cf2c7
2 changed files with 109 additions and 7 deletions

View file

@ -15,7 +15,13 @@ const empty = {
permissions: defaults,
cpu: "",
memory: "",
inference: { model: "", effort: "", subagents: "", maxSubagents: "" },
inference: {
model: "",
effort: "",
subagents: "",
maxSubagents: "",
softContext: "",
},
};
test("no archetype is the default permissions and empty settings", () => {
@ -34,6 +40,7 @@ test("an archetype's settings fill the form", () => {
effort: "high",
subagent_models: ["haiku", "sonnet"],
max_subagents: 0,
soft_context_percent: 20,
},
};
assert.deepEqual(prefill(reviewer, defaults), {
@ -45,6 +52,7 @@ test("an archetype's settings fill the form", () => {
effort: "high",
subagents: "haiku, sonnet",
maxSubagents: "0",
softContext: "20",
},
});
});

View file

@ -0,0 +1,33 @@
// The soft context limit field: what counts as empty, valid and refused. Run
// by `npm test`, which imports the `.ts` module as it is.
import assert from "node:assert/strict";
import { test } from "node:test";
import {
MAX_SOFT_CONTEXT_PERCENT,
MIN_SOFT_CONTEXT_PERCENT,
softContextValue,
} from "../src/agent/detail/soft-context.ts";
test("an empty box leaves the agent on its own limit", () => {
assert.equal(softContextValue(""), undefined);
assert.equal(softContextValue(" "), undefined);
});
test("a whole percent from 5 to 100 is taken", () => {
assert.equal(softContextValue("20"), 20);
assert.equal(softContextValue(" 75 "), 75);
assert.equal(
softContextValue(String(MIN_SOFT_CONTEXT_PERCENT)),
MIN_SOFT_CONTEXT_PERCENT,
);
assert.equal(
softContextValue(String(MAX_SOFT_CONTEXT_PERCENT)),
MAX_SOFT_CONTEXT_PERCENT,
);
});
test("anything else is refused", () => {
for (const text of ["0", "4", "101", "-20", "20.5", "abc", "1e1", "20%"]) {
assert.equal(softContextValue(text), null, text);
}
});