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.
33 lines
1 KiB
JavaScript
33 lines
1 KiB
JavaScript
// 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);
|
|
}
|
|
});
|