diff --git a/docs/4-implementation/swarm/inference.md b/docs/4-implementation/swarm/inference.md index c658cf819..c984ac78d 100644 --- a/docs/4-implementation/swarm/inference.md +++ b/docs/4-implementation/swarm/inference.md @@ -37,9 +37,12 @@ swarmctl agent inference clear iris percent of the context window above which a turn that finds the prompt cache cold starts a fresh session instead of resuming, in place of the harness's own 50%. It's a whole number from 5 to 100, and not above the soft limit when - both are set, since the agent compacts at the soft limit and the context would + you set both, since the agent compacts at the soft limit and the context would never reach a higher threshold; the controller refuses a pair that crosses. - `set` has no flag for it either, and the dialog edits both on one slider. + With no soft limit set, the harness's own 75% applies, and the dialog keeps + the threshold at or below it. `HIVE_AUTO_RESET_WATERMARK_TOKENS` in the agent's + environment outranks the threshold. `set` has no flag for it either, and the + dialog edits both on one slider. - `get` shows each field, naming the unset ones (or says the swarm sets nothing for the agent), and then the model and effort the agent reports running on, each with where it comes from. @@ -140,7 +143,7 @@ in-memory model or effort without writing `hyperhive-model` or The same loop hands `soft_context_percent` to the Bus (`set_soft_context_percent`), which the compaction policy reads when it decides at turn end, and `fresh_session_percent` (`set_fresh_session_percent`), which -the pre-turn auto-reset reads; a key with no limit, or no key, clears it on the +the pre-turn autoreset reads; a key with no limit, or no key, clears it on the next read. The subagent daemon (`hive-subagent-mcp`'s `swarm_models`) reads diff --git a/docs/4-implementation/web-ui/swarm-ui.md b/docs/4-implementation/web-ui/swarm-ui.md index 146221eaf..0d86cf043 100644 --- a/docs/4-implementation/web-ui/swarm-ui.md +++ b/docs/4-implementation/web-ui/swarm-ui.md @@ -748,7 +748,7 @@ when it sets none, the subagent cap, which reads "no cap" when unset, and the fresh-session threshold and the soft context limit, which each read "its own" when unset. **edit** opens a dialog with the fields, filled with what the swarm stores; saving does a `PUT /api/agents/{agent}/inference` of the whole value. A field you leave empty stays out of it, so the agent keeps -its own value for that field; an empty max subagents is no cap, and the two context limits share one slider with two handles on the model's context window, from 5 to 100 percent: a turn that finds the prompt cache cold starts a fresh session once the context passes the left (green) handle, and the agent compacts at the end of a turn once it passes the right (purple) one, and a turn can run past it. The handles can't cross. A handle the swarm hasn't set sits at the harness's own value (50 and 75) and is dimmed; **use its own** on its line puts it back there, which leaves that field out of the `PUT`. **clear the swarm's setting** sends the `DELETE`. +its own value for that field; an empty max subagents is no cap, and the two context limits share one slider with two handles on the model's context window, from 5 to 100 percent: a turn that finds the prompt cache cold starts a fresh session once the context passes the left (green) handle, and the agent compacts at the end of a turn once it passes the right (purple) one, and a turn can run past it. The handles can't cross. A handle the swarm hasn't set sits at the harness's own value (50 and 75), dimmed; **use its own** on its line puts it back there, which leaves that field out of the `PUT`. **clear the swarm's setting** sends the `DELETE`. The card reads `GET /api/agents/{agent}/inference`; before the agent's first report reaches the controller, it shows the swarm's stored values only. [inference](../swarm/inference.md) describes the settings themselves. diff --git a/frontend/packages/swarm-ui/src/agent/detail/soft-context.ts b/frontend/packages/swarm-ui/src/agent/detail/soft-context.ts index ebf912fae..08897924e 100644 --- a/frontend/packages/swarm-ui/src/agent/detail/soft-context.ts +++ b/frontend/packages/swarm-ui/src/agent/detail/soft-context.ts @@ -74,10 +74,15 @@ export function clampFresh(to: number, limits: Limits): number { ); } -/** Where the soft handle may go: not below the fresh-session handle. */ +/** + * Where the soft handle may go: not below the fresh-session handle when the + * swarm sets one. An unset fresh-session handle only follows the soft one down + * (`limitsOf`), so it does not hold it up. + */ export function clampSoft(to: number, limits: Limits): number { + const floor = limits.freshSet ? limits.fresh : MIN_SOFT_CONTEXT_PERCENT; return Math.min( - Math.max(Math.round(to), limits.fresh, MIN_SOFT_CONTEXT_PERCENT), + Math.max(Math.round(to), floor, MIN_SOFT_CONTEXT_PERCENT), MAX_SOFT_CONTEXT_PERCENT, ); } diff --git a/frontend/packages/swarm-ui/test/context-limits.test.mjs b/frontend/packages/swarm-ui/test/context-limits.test.mjs index 65e618c5c..186de803d 100644 --- a/frontend/packages/swarm-ui/test/context-limits.test.mjs +++ b/frontend/packages/swarm-ui/test/context-limits.test.mjs @@ -52,7 +52,14 @@ test("the fresh-session handle stops at the soft one and at 5", () => { assert.equal(clampFresh(44.6, l), 45); }); -test("the soft handle stops at the fresh-session one and at 100", () => { +test("an unset fresh-session handle does not hold the soft one up", () => { + const l = limitsOf("", ""); + assert.equal(clampSoft(20, l), 20); + assert.equal(clampSoft(5, l), 5); + assert.equal(limitsOf("", "20").fresh, 20, "it follows the soft handle down"); +}); + +test("the soft handle stops at a set fresh-session one and at 100", () => { const l = limitsOf("30", "60"); assert.equal(clampSoft(75, l), 75); assert.equal(clampSoft(10, l), 30);