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:
parent
b19b730a3a
commit
e9af6cf2c7
1 changed files with 109 additions and 7 deletions
22
frontend/packages/swarm-ui/src/agent/detail/soft-context.ts
Normal file
22
frontend/packages/swarm-ui/src/agent/detail/soft-context.ts
Normal 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;
|
||||
}
|
||||
Loading…
Reference in a new issue