The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(agent): threshold_tokens inline default matches DEFAULT_CONFIG like every other compression key
kshitijk4poored9e227257c9
diff --git a/agent/agent_init.py b/agent/agent_init.pyindex cd8700f147b..99f97e4ac49 100644--- a/agent/agent_init.py+++ b/agent/agent_init.py@@ -37,7 +37,7 @@ from agent.think_scrubber import StreamingThinkScrubberfrom agent.tool_guardrails import (ToolCallGuardrailConfig, ToolCallGuardrailController)-from hermes_cli.config import cfg_get+from hermes_cli.config import DEFAULT_CONFIG, cfg_getfrom hermes_cli.route_identity import normalize_route_base_urlfrom hermes_cli.timeouts import get_provider_request_timeoutfrom hermes_constants import get_hermes_home@@ -1483,8 +1483,9 @@ def _parse_compression_config(agent, _agent_cfg) -> CompressionSettings:if max_attempts < 1:max_attempts = 3# threshold_tokens: absolute cap (lower of ratio threshold and this); clamped to the- # window at apply-time.- threshold_tokens = cfg.get("threshold_tokens")+ # window at apply-time. Absent → the shipped default (the merged config always carries it; only a+ # failed config load hands us `{}`); an explicit null is the ratio-only opt-out and stays None.+ threshold_tokens = cfg.get("threshold_tokens", cfg_get(DEFAULT_CONFIG, "compression", "threshold_tokens"))if threshold_tokens is not None:threshold_tokens = _positive_int(threshold_tokens)# Non-system head messages to protect (system prompt is always protected); 0 is adiff --git a/tests/agent/test_compression_config_defaults.py b/tests/agent/test_compression_config_defaults.pynew file mode 100644index 00000000000..9711d7a923a--- /dev/null+++ b/tests/agent/test_compression_config_defaults.py@@ -0,0 +1,28 @@+"""``_parse_compression_config`` promises "Defaults here MUST match DEFAULT_CONFIG" — the config-load+failure path hands it ``{}`` and every key falls back inline. Regression for the one key that did not:+``threshold_tokens`` fell to None (no cap) while ``threshold`` kept 0.50, so a broken config.yaml+silently restored the pre-#115986 500K trigger on 1M-window models."""++from types import SimpleNamespace++import pytest++from agent.agent_init import _parse_compression_config+from hermes_cli.config import DEFAULT_CONFIG+++def _agent():+ return SimpleNamespace(model="m", provider="openrouter", api_mode="chat_completions", quiet_mode=True)+++ ("section", "expected"),+ [+ ({}, DEFAULT_CONFIG["compression"]["threshold_tokens"]), # absent → shipped default+ ({"threshold_tokens": None}, None), # explicit null → ratio-only opt-out+ ],+)+def test_absent_threshold_tokens_falls_back_like_every_other_key(section, expected):+ cs = _parse_compression_config(_agent(), {"compression": section} if section else {})+ assert cs.threshold_tokens == expected+ assert cs.threshold == DEFAULT_CONFIG["compression"]["threshold"]