model/context: defaults in nix module, no heuristic in rust

This commit is contained in:
damocles 2026-05-20 15:31:06 +02:00 committed by Mara
parent 770cbaccf9
commit 7e2f13cad8
2 changed files with 32 additions and 31 deletions

View file

@ -38,26 +38,35 @@
options.hyperhive.contextWindowTokens = lib.mkOption {
type = lib.types.attrsOf lib.types.int;
default = { };
# Canonical defaults for known Anthropic model families.
# Override any entry in your agent.nix, or add new keys for
# model families not listed here.
default = {
haiku = 200000;
sonnet = 1000000;
opus = 1000000;
};
example = {
haiku = 150000;
sonnet = 900000;
};
description = ''
Per-model context-window overrides. Each attribute name is a
Per-model context-window sizes in tokens. Each key is a
model-family short name (e.g. `"haiku"`, `"sonnet"`) matched as a
case-insensitive substring of the active model name at runtime, so
`"sonnet"` matches `"claude-sonnet-4-5"` and any future variant.
Empty map (the default) means auto-derive: haiku 200 000,
sonnet / opus 1 000 000.
The defaults declared here cover the known Anthropic model families.
Add or override entries in your `agent.nix` when using a
non-standard model or when Anthropic changes a model's window.
Each entry is rendered as
`HIVE_CONTEXT_WINDOW_TOKENS_<KEY_UPPER>` (e.g.
`HIVE_CONTEXT_WINDOW_TOKENS_SONNET = "900000"`). The harness checks
these per-model vars first, then the global
`HIVE_CONTEXT_WINDOW_TOKENS`, then the model-family heuristic.
At runtime, the effective window drives compaction (75%) and
auto-reset (50%) watermarks, and is exposed via `/api/state` as
`HIVE_CONTEXT_WINDOW_TOKENS_SONNET = "1000000"`). The harness
checks these per-model vars in order (first substring match wins),
then falls back to `200000` when no key matches. At runtime the
effective window drives compaction (75%) and auto-reset (50%)
watermarks, and is exposed via `/api/state` as
`context_window_tokens`.
'';
};