hive-agent: no hard-coded context window sizes, the window is what the API reports
This commit is contained in:
parent
4a109fa038
commit
1bfee54414
2 changed files with 47 additions and 124 deletions
|
|
@ -59,21 +59,13 @@ terminal: a model or effort the swarm sets for the agent replaces the
|
|||
clearing it goes back to the local value →
|
||||
[`4-implementation/swarm/inference.md`](../swarm/inference.md).
|
||||
|
||||
`harness_state::context_window_tokens(model)` looks up
|
||||
context-window size per-model. Resolution order (first
|
||||
match wins):
|
||||
The context window is whatever the model reports once a turn completes
|
||||
(`modelUsage.*.contextWindow`, `Bus::api_context_window`). The harness keeps no
|
||||
per-model table of window sizes: until the first turn of a process completes the
|
||||
window is unknown, and what depends on it waits (the compaction watermarks, the
|
||||
auto-reset, the `compact` tool, the context fill the swarm shows).
|
||||
|
||||
1. The harness's per-family defaults, matched when the family name
|
||||
is a case-insensitive substring of the active model name:
|
||||
haiku=200k, sonnet=1M, opus=1M.
|
||||
2. `HIVE_CONTEXT_WINDOW_TOKENS` — single global override for any
|
||||
other model (useful in dev / test).
|
||||
3. Hard fallback: `200_000`.
|
||||
|
||||
Once a turn completes, the window the model reports
|
||||
(`modelUsage.*.contextWindow`) replaces this value.
|
||||
|
||||
The effective window drives watermarks; no web endpoint serves it.
|
||||
The window drives watermarks; no web endpoint serves it.
|
||||
|
||||
**Session identity — a constant title.** Every turn keys on one fixed,
|
||||
harness-owned session title (`turn::session_title()`, default
|
||||
|
|
@ -163,8 +155,8 @@ is fleet-wide and set once in `hive-agent/prompts/claude-settings.json`.
|
|||
The **when** for hyperhive's own policy is a `hive_claude::CompactionPolicy` injected by the harness:
|
||||
`turn::make_session` builds a `PercentPolicy` that compacts once the
|
||||
model-reported context fill reaches `HIVE_COMPACT_WATERMARK_PERCENT`
|
||||
(default **75%**), falling back to `harness_state::context_window_tokens(model)`
|
||||
for the window on turns the model didn't report one. The swarm can replace
|
||||
(default **75%**) of the window the model reported, so a turn that reports none
|
||||
never triggers it. The swarm can replace
|
||||
that percent per agent with its `soft_context_percent`
|
||||
([`inference.md`](../swarm/inference.md)); `turn::SoftLimitPolicy` reads it
|
||||
for each decision. `0` disables proactive
|
||||
|
|
@ -195,8 +187,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
|
||||
`context_window_tokens(model)`**) AND the time since the last turn
|
||||
(`HIVE_AUTO_RESET_WATERMARK_TOKENS`, default **50% of the reported
|
||||
window**, none before one is reported) AND the time since the last turn
|
||||
exceeds the assumed prompt-cache TTL (`HIVE_CACHE_TTL_SECS`, default
|
||||
`3600`). Claude's prompt cache goes cold after a while; once it's cold,
|
||||
`--resume`-ing a large session pays the full re-upload cost with no
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ hive_name?, swarm_name?, matrix_accounts? }`. `matrix_accounts` is a
|
|||
- `compact` — queues a compaction of the current session; the only way to
|
||||
request one. No args. Gated server-side on the last completed
|
||||
turn's context usage: refused (with an explanation, no side effect)
|
||||
unless usage is above 40% of the effective context window. On a
|
||||
unless usage is above 40% of the reported context window (and refused while no turn has reported one). On a
|
||||
pass, queues the deferred `compact_pending` flag — consumed at the end
|
||||
of the current turn, so it never
|
||||
races a live claude process, and the usual pre-compaction
|
||||
|
|
|
|||
Loading…
Reference in a new issue