`_cap_binds` was the last inline copy of the cap-clamped-to-window predicate that #119406 centralised; the banner still prints the raw configured cap. Plugin engines without the helper report "not binding", as before when no cap was set. The threshold_tokens comment and the new test module stop narrating the incident; the parametrize takes the whole agent config so the `{}` failure path is spelled out rather than derived from a ternary.
27 lines
991 B
Python
27 lines
991 B
Python
"""A failed config load hands ``_parse_compression_config`` ``{}``; every key must fall back to
|
|
DEFAULT_CONFIG, and an explicit ``threshold_tokens: null`` must stay the ratio-only opt-out."""
|
|
|
|
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)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("agent_cfg", "expected"),
|
|
[
|
|
({}, DEFAULT_CONFIG["compression"]["threshold_tokens"]), # config-load failure → shipped default
|
|
({"compression": {"threshold_tokens": None}}, None), # explicit null → ratio-only opt-out
|
|
],
|
|
)
|
|
def test_threshold_tokens_default_and_null_opt_out(agent_cfg, expected):
|
|
cs = _parse_compression_config(_agent(), agent_cfg)
|
|
assert cs.threshold_tokens == expected
|
|
assert cs.threshold == DEFAULT_CONFIG["compression"]["threshold"]
|