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,22 @@
// The create form's and the inference dialog's `soft_context_percent` field,
// kept out of the component so `npm test` can run it.
/** The lowest `soft_context_percent` the swarm accepts. */
export const MIN_SOFT_CONTEXT_PERCENT = 5;
/** The highest: the whole context window. */
export const MAX_SOFT_CONTEXT_PERCENT = 100;
/**
* `soft_context_percent` as typed: `undefined` for empty (the agent's own
* default), the number for a whole number from [`MIN_SOFT_CONTEXT_PERCENT`]
* to [`MAX_SOFT_CONTEXT_PERCENT`], else `null`.
*/
export function softContextValue(text: string): number | null | undefined {
const t = text.trim();
if (t === "") return undefined;
if (!/^\d+$/.test(t)) return null;
const n = Number(t);
return n >= MIN_SOFT_CONTEXT_PERCENT && n <= MAX_SOFT_CONTEXT_PERCENT
? n
: null;
}