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

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);
}
});