The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
Compaction follows compression.threshold again: no default 256K token cap (#117915, #125235) (#126064)
Siddharth Balyan98278833e29b
diff --git a/cli-config.yaml.example b/cli-config.yaml.exampleindex ff5425436d4..ee68877fc20 100644--- a/cli-config.yaml.example+++ b/cli-config.yaml.example@@ -7,7 +7,7 @@# Schema version of this file. The installers copy it to seed config.yaml, and# `hermes update` uses it to know which one-time migrations the file already# has. Hermes manages it: do not copy it into another config.-_config_version: 46+_config_version: 47# =============================================================================# Database Configuration@@ -691,12 +691,11 @@ compression:# "claude-sonnet": 0.35# "gpt-5": 0.30- # Absolute token cap for the compression trigger (default: 256000).- # Compression fires at the LOWER of the ratio-based threshold and this count,- # bounding large-window sessions while lower proportional triggers still win- # whenever they fall below the cap. The cap survives model switches and fallbacks.- # Set null to restore ratio-only behavior.- threshold_tokens: 256000+ # Optional absolute token cap for the compression trigger (default: null = disabled).+ # When set, compression fires at the LOWER of the ratio-based threshold and this+ # absolute token count. Clamped to the model's context length at apply-time, so a+ # cap above the window is a no-op. Survives model switches and fallback activations.+ # threshold_tokens: 200000# Existing Codex gpt-5.5 behavior: raise Hermes' compaction trigger to 85%# for the ChatGPT Codex OAuth route. Set false to opt back down to threshold.diff --git a/hermes_cli/config_defaults.py b/hermes_cli/config_defaults.pyindex a1fa4ffb3eb..9f605c65ec7 100644--- a/hermes_cli/config_defaults.py+++ b/hermes_cli/config_defaults.py@@ -573,11 +573,10 @@ DEFAULT_CONFIG = {# are floored at 0.75 (raise-only) so compaction doesn't fire with half the window free; set# above 0.75 to override the floor."threshold": 0.50,- # threshold_tokens: absolute token cap — compression triggers at the lower of the ratio- # threshold and this count. Clamped to the model's context length. 256K bounds 1M-window- # models (their 50% trigger sat at 500K, so compaction never fired) while every lower- # ratio trigger still wins; null = ratio-only.- "threshold_tokens": 256_000,+ # threshold_tokens: optional absolute token cap — when set, compression triggers at the+ # lower of the ratio threshold and this count. Clamped to the model's context length.+ # Off by default: no single count suits windows from 64K to 1M+, so the ratio decides.+ "threshold_tokens": None,# "progress_notices": False, # opt-in (#52995): when True, routine compression"target_ratio": 0.20, # fraction of threshold to preserve as recent tail# tail_mode: "lean" = clamped 2.5%-of-window tail (10K floor / 25K cap) plus chunked@@ -2681,7 +2680,7 @@ DEFAULT_CONFIG = {# Extra ports detection probes for an external llama-server (besides 8080)."detect_ports": [],},- "_config_version": 46, # Config schema version - bump this when adding new required fields+ "_config_version": 47, # Config schema version - bump this when adding new required fields}diff --git a/hermes_cli/config_migrations.py b/hermes_cli/config_migrations.pyindex 04d4b157fc7..1f087fee1e5 100644--- a/hermes_cli/config_migrations.py+++ b/hermes_cli/config_migrations.py@@ -754,6 +754,17 @@ MIGRATIONS: Tuple[Tuple[int, Callable[[Dict[str, Any], bool], None]], ...] = ((45, _migrate_to_45),# 45 → 46: legacy editor `disabled: true` on MCP servers becomes `enabled: false` (see _migrate_to_46).(46, _migrate_to_46),+ # 46 → 47: compression.threshold_tokens defaults back to null (ratio-only). The briefly shipped+ # 256000 default was copied into config.yaml by the template seeder and `doctor --fix`, where it+ # reads as a user choice and keeps capping 1M-window models at 256K. Drop only that exact value;+ # any other explicit cap, and an explicit null, are preserved.+ (47, _rewrite_stale_default(+ section="compression", key="threshold_tokens", old=256000, new=None,+ added="removed compression.threshold_tokens: 256000 (the old default)",+ message=(+ " ✓ Removed compression.threshold_tokens: 256000 — the old default. Compaction "+ "follows compression.threshold (50% of the window) again. Set threshold_tokens "+ "to a token count to cap it on purpose."))),)#: Steps triggered by a legacy key or identifier (a renamed or retired key, a removed plugin ordiff --git a/tests/agent/test_context_compressor.py b/tests/agent/test_context_compressor.pyindex befa90976fd..029af6e5c54 100644--- a/tests/agent/test_context_compressor.py+++ b/tests/agent/test_context_compressor.py@@ -2210,14 +2210,13 @@ class TestThresholdTokensCap:assert comp.threshold_tokens_cap is None@pytest.mark.parametrize("context_length", [128_000, 1_000_000])- def test_default_config_uses_lower_effective_trigger(self, context_length):- """Shipped defaults: the trigger is the LOWER of the ratio trigger and the absolute cap, so a- 1M window compacts at the cap while windows whose ratio trigger sits below it are untouched."""+ def test_default_config_compacts_at_the_ratio_trigger(self, context_length):+ """Shipped defaults carry no token cap: every window compacts at its ratio trigger, so a 1M+ window is not cut to a fixed count that suits some models and not others."""from hermes_cli.config import DEFAULT_CONFIGdefault_pct = DEFAULT_CONFIG["compression"]["threshold"]default_cap = DEFAULT_CONFIG["compression"]["threshold_tokens"]- assert isinstance(default_cap, int) and 0 < default_cap < 1_000_000with patch("agent.context_compressor.get_model_context_length", return_value=context_length):ratio_only = ContextCompressor("model-a", threshold_percent=default_pct, quiet_mode=True)comp = ContextCompressor(@@ -2225,10 +2224,8 @@ class TestThresholdTokensCap:)_ = ratio_only.context_length, comp.context_length- expected_threshold = min(ratio_only.threshold_tokens, default_cap)- assert comp.threshold_tokens == expected_threshold- assert comp.should_compress(expected_threshold - 1) is False- assert comp.should_compress(expected_threshold) is True+ assert comp.threshold_tokens_cap is None+ assert comp.threshold_tokens == ratio_only.threshold_tokens@@ -2271,23 +2268,16 @@ class TestThresholdTokensCap:assert comp.should_compress(200_000) is True # at cap (below 500K pct)assert comp.should_compress(250_000) is True # above cap- def test_default_config_cap_survives_model_switch(self):- """The shipped cap remains effective when the active model changes."""- from hermes_cli.config import DEFAULT_CONFIG-+ def test_explicit_cap_survives_model_switch(self):+ """A user-set cap remains effective when the active model changes."""+ cap = 200_000with patch("agent.context_compressor.get_model_context_length", return_value=1_000_000):- comp = ContextCompressor(- "model-a",- threshold_percent=DEFAULT_CONFIG["compression"]["threshold"],- threshold_tokens_cap=DEFAULT_CONFIG["compression"]["threshold_tokens"],- quiet_mode=True,- )+ comp = ContextCompressor("model-a", threshold_percent=0.50, threshold_tokens_cap=cap, quiet_mode=True)_ = comp.context_length- default_cap = DEFAULT_CONFIG["compression"]["threshold_tokens"]- assert comp.threshold_tokens == default_cap+ assert comp.threshold_tokens == capcomp.update_model("model-b", context_length=2_000_000)- assert comp.threshold_tokens == default_cap+ assert comp.threshold_tokens == capdiff --git a/tests/gateway/test_agent_cache.py b/tests/gateway/test_agent_cache.pyindex 127a562f678..37ac2f88e00 100644--- a/tests/gateway/test_agent_cache.py+++ b/tests/gateway/test_agent_cache.py@@ -149,16 +149,16 @@ class TestExtractCacheBustingConfig:for section, key in GatewayRunner._CACHE_BUSTING_CONFIG_KEYS:assert out[f"{section}.{key}"] == cfg_get(DEFAULT_CONFIG, section, key)- def test_explicit_null_differs_from_absent_when_default_is_set(self):- """`threshold_tokens: null` opts out of the shipped cap; the signature must keep it distinct from- 'absent' (= the default) so the opt-out rebuilds the cached agent instead of waiting for a restart."""+ def test_explicit_cap_differs_from_absent(self):+ """Setting or clearing `threshold_tokens` rebuilds the cached agent (the signature changes), while+ absent and an explicit default build the same agent (the signature matches)."""from gateway.run import GatewayRunnerdefault_cap = DEFAULT_CONFIG["compression"]["threshold_tokens"]- assert default_cap is not None # the premise: a non-None default whose opt-out is null+ other_cap = (default_cap or 0) + 100_000sig = lambda cfg: GatewayRunner._extract_cache_busting_config(cfg)["compression.threshold_tokens"] # noqa: E731assert sig({}) == sig({"compression": {"threshold_tokens": default_cap}}) == default_cap- assert sig({"compression": {"threshold_tokens": None}}) is None+ assert sig({"compression": {"threshold_tokens": other_cap}}) == other_cap != sig({})def test_legacy_checkpoints_bool_carries_defaults_for_the_other_keys(self):"""`checkpoints: true` builds the agent with DEFAULT_CONFIG's limits (`_checkpoint_agent_kwargs`), sodiff --git a/tests/tui_gateway/test_compression_config_hot_reload.py b/tests/tui_gateway/test_compression_config_hot_reload.pyindex 81287784066..253abca79e1 100644--- a/tests/tui_gateway/test_compression_config_hot_reload.py+++ b/tests/tui_gateway/test_compression_config_hot_reload.py@@ -114,6 +114,17 @@ def test_unchanged_compression_config_is_noop(monkeypatch):assert compressor.threshold_tokens == 99_999+def _default_cap():+ from hermes_cli.config_defaults import DEFAULT_CONFIG++ return DEFAULT_CONFIG["compression"]["threshold_tokens"]+++def _with_default_cap(trigger: int) -> int:+ cap = _default_cap()+ return min(trigger, cap) if cap else trigger++def test_clearing_threshold_tokens_restores_default_cap(monkeypatch):session, compressor = _session_with_compressor(threshold_tokens_cap=100_000)assert compressor.threshold_tokens == 100_000@@ -128,22 +139,20 @@ def test_clearing_threshold_tokens_restores_default_cap(monkeypatch):)server._sync_agent_compression_with_config("sid-95151", session)- # Key removal restores what a fresh agent build installs (merged DEFAULT_CONFIG), not "no- # cap": a None here re-derives the uncapped ratio trigger and the 256K default is lost.- assert compressor.threshold_tokens_cap == 256_000+ # Key removal restores what a fresh agent build installs (merged DEFAULT_CONFIG).+ assert compressor.threshold_tokens_cap == _default_cap()assert compressor.threshold_tokens > 100_000def test_absent_threshold_tokens_keeps_default_cap_on_1m_window(monkeypatch):- """#117093: the live read is unmerged (missing key = unset), so a config.yaml without- compression.threshold_tokens used to wipe the ctor-installed 256K cap at the first- turn's sync — the trigger re-derived to the uncapped ratio value (500K on a 1M window)- and compaction stopped firing at 256K while telemetry still reported the capped figure."""+ """#117093: the live read is unmerged (missing key = unset), while agent construction reads the+ merged config. A config.yaml without compression.threshold_tokens must leave the live session on+ the same cap a fresh build installs, not re-derive a different trigger at the first turn's sync."""compressor = ContextCompressor(model="unset-test-model",threshold_percent=0.85,config_context_length=1_000_000,- threshold_tokens_cap=256_000,+ threshold_tokens_cap=_default_cap(),quiet_mode=True,)agent = SimpleNamespace(@@ -156,7 +165,7 @@ def test_absent_threshold_tokens_keeps_default_cap_on_1m_window(monkeypatch):codex_responses_compact_threshold=200_000,)session = {"agent": agent, "session_key": "session-unset"}- assert compressor.threshold_tokens == 256_000 # min(1M * 0.85, 256K cap)+ assert compressor.threshold_tokens == _with_default_cap(850_000)# The pin is scoped to the configured default route (#116467); that scoping has its own tests,# this one is about the cap, so keep the 1M window in scope for the bare test runtime.@@ -165,9 +174,9 @@ def test_absent_threshold_tokens_keeps_default_cap_on_1m_window(monkeypatch):monkeypatch.setattr(agent_init, "config_context_length_for_runtime", lambda _agent, _cfg=None: 1_000_000)_sync_with_cfg(monkeypatch, session, {"model": {"context_length": 1_000_000}, "compression": {}})- assert compressor.threshold_tokens_cap == 256_000- # threshold is absent too, so the derived 0.50 ratio applies — the 256K cap must still win.- assert compressor.threshold_tokens == 256_000+ assert compressor.threshold_tokens_cap == _default_cap()+ # threshold is absent too, so the derived 0.50 ratio applies under the default cap.+ assert compressor.threshold_tokens == _with_default_cap(500_000)@@ -249,8 +258,8 @@ def test_removing_threshold_restores_derived_default(monkeypatch):)assert compressor._config_threshold_percent == 0.50assert compressor.threshold_percent == 0.50- # The absent cap key restores the 256K default, which binds below the 300K ratio value.- assert compressor.threshold_tokens == min(int(600_000 * 0.50), 256_000)+ # The absent cap key restores DEFAULT_CONFIG's cap on top of the derived ratio trigger.+ assert compressor.threshold_tokens == _with_default_cap(int(600_000 * 0.50))def test_removing_context_length_reinfers_from_model_metadata(monkeypatch):@@ -267,7 +276,7 @@ def test_removing_context_length_reinfers_from_model_metadata(monkeypatch):_sync_with_cfg(monkeypatch, session, {"model": {}, "compression": {}})assert compressor._config_context_length is Noneassert compressor.context_length == 1_000_000- assert compressor.threshold_tokens == min(int(1_000_000 * 0.50), 256_000)+ assert compressor.threshold_tokens == _with_default_cap(int(1_000_000 * 0.50))def test_removing_idle_compact_after_seconds_restores_zero(monkeypatch):diff --git a/tui_gateway/session_compression.py b/tui_gateway/session_compression.pyindex e2e6f549750..0c828efc466 100644--- a/tui_gateway/session_compression.py+++ b/tui_gateway/session_compression.py@@ -42,9 +42,8 @@ def _compressor_ctor_default(name: str, fallback: Any) -> Any:def _default_threshold_tokens_cap():"""The cap a fresh agent build installs when the key is absent: DEFAULT_CONFIG's``compression.threshold_tokens``. agent_init reads the MERGED config, so "no key in- config.yaml" still installs the 256K default at construction; key removal here must- restore that same value. ``None`` instead would re-derive the uncapped ratio trigger- (500K on a 1M-window model) and the default cap would be gone after the first turn+ config.yaml" installs that default at construction; key removal here must restore the+ same value, or a live session would diverge from a rebuilt one after the first turn(#117093). An explicit ``threshold_tokens: null`` stays ratio-only — the key is present,so ``.get`` returns it untouched."""from hermes_cli.config_defaults import DEFAULT_CONFIGdiff --git a/website/docs/developer-guide/context-compression-and-caching.md b/website/docs/developer-guide/context-compression-and-caching.mdindex 3199d9a11b9..b7e84c076ef 100644--- a/website/docs/developer-guide/context-compression-and-caching.md+++ b/website/docs/developer-guide/context-compression-and-caching.md@@ -33,8 +33,8 @@ The static fallback for `xai.grok-4.6` (including `global.` and `us.` inferenceprofiles) is 500,000 tokens, per the[AWS model card](https://docs.aws.amazon.com/bedrock/latest/userguide/model-card-xai-grok-4-6.html).This is Bedrock-specific, not the direct xAI API window. Existing compression-rules still apply: without output reservation, the small-window 75% threshold floor-yields 375,000 at this window, which the default `threshold_tokens` cap (256,000) then lowers.+rules still apply: without output reservation or an explicit token cap, the+small-window 75% threshold floor yields a 375,000-token trigger at this window.## Pluggable Context Engine@@ -262,10 +262,10 @@ auxiliary:| Parameter | Default | Range | Description ||-----------|---------|-------|-------------|| `threshold` | `0.50` | 0.0-1.0 | Compression triggers when prompt tokens ≥ `threshold × context_length` (floored at 0.75 below 512K windows) |-| `threshold_tokens` | `256000` | int or `null` | Absolute cap on the trigger: compaction fires at the lower of the ratio trigger and this count, so a 1M window compacts at 256K instead of 500K. `null` = ratio-only |+| `threshold_tokens` | `null` | int or `null` | Optional absolute cap on the trigger: when set, compaction fires at the lower of the ratio trigger and this count. `null` = ratio-only || `model_thresholds` | `{}` | map | Per-model overrides of `threshold`. Keys are substring-matched against the model name (longest match wins); `"<provider>:<substring>"` keys apply only on that provider. The small-context floor still applies on top (see below) || `target_ratio` | `0.20` | 0.10-0.80 | Controls tail protection token budget: `threshold_tokens × target_ratio` (legacy mode only — `lean` uses its own clamp) |-| `tail_mode` | `lean` | `lean`, `legacy` | Tail retention policy. `legacy` keeps a `target_ratio`-sized verbatim tail (~100K+ tokens on big-window models without the `threshold_tokens` cap). `lean` keeps a clamped tail of `2.5% × context window` (10K floor, 25K cap) and instead carries continuity in the summary: a detailed identifier-preserving session log (produced by the same single summary request — lean compaction makes exactly one auxiliary LLM call per attempt), a mechanically extracted anchor index (PR numbers, SHAs, paths, error strings — regex, never paraphrased), every real user message quoted verbatim (newest-first budget), and a `session_search` recovery pointer so the agent can re-access anything summarized away. Oversized regions are evenly sampled into the summarizer input (with explicit elision markers) rather than triggering extra calls. Result on 500K-token real sessions: ~49K retained vs ~162K, with higher recall when paired with recovery (see `evals/compaction/results/`). Old tool results inside the lean tail are demoted to one-line stubs carrying a recovery pointer |+| `tail_mode` | `lean` | `lean`, `legacy` | Tail retention policy. `legacy` keeps a `target_ratio`-sized verbatim tail (~100K+ tokens on big-window models). `lean` keeps a clamped tail of `2.5% × context window` (10K floor, 25K cap) and instead carries continuity in the summary: a detailed identifier-preserving session log (produced by the same single summary request — lean compaction makes exactly one auxiliary LLM call per attempt), a mechanically extracted anchor index (PR numbers, SHAs, paths, error strings — regex, never paraphrased), every real user message quoted verbatim (newest-first budget), and a `session_search` recovery pointer so the agent can re-access anything summarized away. Oversized regions are evenly sampled into the summarizer input (with explicit elision markers) rather than triggering extra calls. Result on 500K-token real sessions: ~49K retained vs ~162K, with higher recall when paired with recovery (see `evals/compaction/results/`). Old tool results inside the lean tail are demoted to one-line stubs carrying a recovery pointer || `protect_last_n` | `20` | ≥1 | Minimum number of recent messages always preserved || `min_tail_user_messages` | `1` | ≥1 | Minimum number of REAL (actionable) user messages guaranteed to survive in the uncompressed tail. `1` = the existing single last-user anchor (behavior-preserving default). Raise to e.g. `3` to keep the last 3 real user turns verbatim even when bulky tool outputs fill the tail token budget. Blank platform echoes, compaction handoffs, and synthetic continuation rows never count toward N. The guarantee wins over the tail token budget — the tail may exceed the budget when the anchor pulls the cut back || `protect_first_n` | `3` | (hardcoded) | System prompt + first exchange always preserved |@@ -295,7 +295,7 @@ changing the selected tail policy. In `lean` mode the selection budget remains bon the **main model's context window**: 2.5%, clamped to 10K–25K tokens, and never morethan 20% of that window (the 10K floor alone is 61% of a 16K local window, so without the cap asmall model's "protected" tail was the whole request and compaction reclaimed nothing). For example,-a 1M main model (`threshold_tokens: null`) with a 512K auxiliary model retains a 25K+a 1M main model with a 512K auxiliary model retains a 25Kselection budget even when feasibility lowers its trigger from 850K to 512K. Explicit `legacy` mode insteadrecomputes `threshold_tokens × target_ratio` (102,400 tokens at 512K × 0.20).These are tail-selection budgets, not strict limits on the entire compacted context:@@ -478,7 +478,7 @@ max_summary_tokens = min(200,000 × 0.05, 12,000) = 10,000```:::note Threshold is derived from the MAIN model's context window-`threshold_tokens` is `threshold × context_length` (then capped by `compression.threshold_tokens`), where `context_length`+`threshold_tokens` is `threshold × context_length` (then capped by `compression.threshold_tokens` when set), where `context_length`is the **main agent model's** context window — never the auxiliary/summarymodel's. On a 262,144-token model at the default `0.50`, the threshold is`262,144 × 0.50 = 131,072`. That number being close to a common "128K context"diff --git a/website/docs/user-guide/configuration.md b/website/docs/user-guide/configuration.mdindex 50d7570015d..23aaa7fc5f7 100644--- a/website/docs/user-guide/configuration.md+++ b/website/docs/user-guide/configuration.md@@ -991,7 +991,7 @@ compression:enabled: true # Toggle compression on/offprogress_notices: false # Opt-in: deliver routine compression progress notices to chat platforms — see belowthreshold: 0.50 # Compress at this % of context limit- threshold_tokens: 256000 # Absolute token cap — takes lower of ratio vs absolute+ threshold_tokens: null # Absolute token cap (optional) — takes lower of ratio vs absolutetarget_ratio: 0.20 # Fraction of threshold to preserve as recent tailtail_mode: lean # Tail retention: "lean" (default — clamped 2.5% tail, 10K-25K, never above 20% of the window, with a detailed session log + anchor index + session_search recovery pointers in the summary, all from ONE auxiliary summarizer call; ~3x fewer retained tokens after compaction) or "legacy" (0.20×threshold verbatim tail)protect_last_n: 20 # Min recent messages to keep uncompressed@@ -1045,7 +1045,7 @@ The value is the **first rung** of an escalating ladder, not a fixed interval: c`in_place` (default `true`) controls what happens to the session identity when compaction fires. When `true`, compaction rewrites the message list and rebuilds the system prompt **without rotating the session id** — the conversation keeps one durable id for its whole life (no `parent_session_id` chain, no `name #2` / `#3` renumbering in session lists). Compaction is non-destructive: the live context is compacted, but the pre-compaction turns are soft-archived under the same id (marked inactive/compacted) — still searchable via `session_search` and recoverable, not deleted. Hooks see the mode via the `in_place` field on the `session:compress` event. Set `in_place: false` to restore the legacy behavior where each compaction rotates to a new session id linked to the old one.-`threshold_tokens` sets an **absolute token cap** for the compression trigger. Compression fires at the lower of the ratio-based `threshold` and this absolute count, so large-window models cannot silently defer compaction to hundreds of thousands of tokens. The default is `256000`: it bounds a 1M model's default 50% trigger at 256K, while any lower proportional trigger still wins (including the 272K Codex window). The cap survives model switches and fallback activations and is clamped to the model's context length. Set it to `null` to restore ratio-only behavior, or choose a different positive count for your workload.+`threshold_tokens` sets an optional **absolute token cap** for the compression trigger. When set, compression fires at the lower of the ratio-based `threshold` and this absolute count, so compaction never fires later than that token count regardless of which model is active. Use it when you want a fixed cost ceiling per call, for example `threshold_tokens: 256000` to compact a 1M-window model at 256K instead of 500K. The cap is clamped to the model's context length, so a value above the window is a no-op. Default `null` (disabled — ratio-based threshold only). The cap survives model switches and fallback activations.`idle_compact_after_seconds` is an **opt-in, time-based** trigger that complements the size-based `threshold`. Default `0` (disabled). When set above 0, a session that resumes after at least that many seconds of inactivity compacts its accumulated history up front, before the first reply — so a long-lived thread (e.g. a Telegram conversation you come back to hours later) doesn't re-read its full stale context on every subsequent turn. It never fires when the context is already at or below the post-compression target (`threshold × target_ratio`), and it honors the same failure-cooldown, anti-thrash, and per-session lock guards as every automatic compaction. Example: `idle_compact_after_seconds: 1800` compacts after 30 minutes idle.diff --git a/website/docs/user-guide/features/delegation.md b/website/docs/user-guide/features/delegation.mdindex fa9bd16a717..95c4268fea6 100644--- a/website/docs/user-guide/features/delegation.md+++ b/website/docs/user-guide/features/delegation.md@@ -664,7 +664,7 @@ delegation:When `base_url` points at an Anthropic-compatible endpoint — for example a path ending in `/anthropic`, an Azure Foundry Claude route, or a MiniMax `/anthropic` proxy — `api_mode` is auto-detected as `anthropic_messages` so the subagent uses the right wire format without you setting anything. Set `api_mode` explicitly when the auto-detection guess is wrong (rare).-Subagents compact where their parent does — the lower of `compression.threshold` × window and the global `compression.threshold_tokens` cap (256K on a 1M model by default). `delegation.compression_threshold_tokens` (default `0`, off) adds an optional absolute cap on a child's compaction *trigger*, applied as the lower of it and the ratio threshold; it never touches the request payload or the parent. A token count of at least 16000 enables it; `true` or `"200k"` are config errors that are warned and ignored. It stays off by default because a replay of a 1,393-agent run put 200K–400K caps within 5% of each other in cost once cache prefixes are intact, and every compaction is a chance to lose detail.+Subagents compact where their parent does: at `compression.threshold` × window (0.50 by default), or the global `compression.threshold_tokens` cap when one is set and lower. `delegation.compression_threshold_tokens` (default `0`, off) adds an optional absolute cap on a child's compaction *trigger*, applied as the lower of it and the ratio threshold; it never touches the request payload or the parent. A token count of at least 16000 enables it; `true` or `"200k"` are config errors that are warned and ignored. It stays off by default because a replay of a 1,393-agent run put 200K–400K caps within 5% of each other in cost once cache prefixes are intact, and every compaction is a chance to lose detail.`delegation.request_overrides` works on **all three** resolution branches — direct `base_url`, named `provider`, and pure inherit — so it always takes effect. Top-level keys are API kwargs (e.g. `service_tier`); an `extra_body` sub-dict is merged into the request's `extra_body`. Explicit values merge **over** runtime- or parent-derived overrides: explicit top-level keys win, and `extra_body` is deep-merged one level, so a provider's own request personality (e.g. `thinking: {type: disabled}`) survives unless your key redefines it. See [Configuration → Delegation](../configuration.md#delegation) for details.