Watch
0
0
Fork
You've already forked hyperhive
0

swarm: set the fresh-session threshold per agent

This commit is contained in:
iris 2026-11-16 10:50:13 +01:00
commit 5175d3663e
2 changed files with 154 additions and 32 deletions

View file

@ -29,10 +29,17 @@ swarmctl agent inference clear iris
dialog; `set` has no flag for it either. It's the percent of the model's
context window at which the agent compacts at the end of a turn, in place of
the harness's own 75%: 20 on a 1M window compacts once the context passes
200k. A turn can still run past it, and it changes nothing else (the idle
autoreset, the context shown in the UI). It's a whole number from 5 to 100;
200k. A turn can still run past it, and it changes nothing else (the
context shown in the UI). It's a whole number from 5 to 100;
unset keeps the harness's own watermark
([`claude-invocation.md`](../turn-loop/claude-invocation.md)).
- You set the fresh-session threshold, `fresh_session_percent`, with it: the
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
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.
- `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.
@ -54,6 +61,7 @@ effort: (not set; the agent's own)
subagent_models: (not set; the agent's own)
max_subagents: (not set; no cap)
soft_context_percent: (not set; the harness's own watermark)
fresh_session_percent: (not set; the harness's own half)
running model: opus (swarm)
running effort: medium (local_file)
```
@ -103,7 +111,8 @@ which swarm-controller alone writes:
"effort": "high",
"subagent_models": ["haiku", "sonnet"],
"max_subagents": 3,
"soft_context_percent": 20
"soft_context_percent": 20,
"fresh_session_percent": 10
}
```
@ -130,7 +139,9 @@ 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; a key with no limit, or no key, clears it on the next read.
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
next read.
The subagent daemon (`hive-subagent-mcp`'s `swarm_models`) reads
`subagent_models` and `max_subagents` with the same direct get, under the

View file

@ -188,7 +188,8 @@ still applies.
- **Auto session-reset** — a third path (`turn::maybe_auto_reset`,
pre-turn) that fires when both conditions hold: context is ≥ a watermark
(`HIVE_AUTO_RESET_WATERMARK_TOKENS`, default **50% of the reported
window**, none until the API reports one) AND the time since the last turn
window**, none until the API reports one; the swarm replaces the 50% per
agent with its `fresh_session_percent`, [`inference.md`](../swarm/inference.md)) AND the time since the last turn
exceeds the assumed prompt-cache TTL (`HIVE_CACHE_TTL_SECS`, default
`3600`; `0` turns the check off, so an idle session is always resumed, and
the harness logs a warning at start when it's off). Claude's prompt cache goes cold after a while; once it's cold,