Skip to content

The agent that grows with you

fix(config): a sparse save no longer writes an empty `agent:` section

teknium10698be87bc2b
diff --git a/hermes_cli/config.py b/hermes_cli/config.py
index 311eb992dd1..36a4415e19e 100644
--- a/hermes_cli/config.py
+++ b/hermes_cli/config.py
@@ -1902,7 +1902,8 @@ def _normalize_max_turns_config(config: Dict[str, Any]) -> Dict[str, Any]:
agent_config = dict(config.get("agent") or {})
if "max_turns" in config and "max_turns" not in agent_config:
agent_config["max_turns"] = config["max_turns"]
- config["agent"] = agent_config
+ if agent_config or "agent" in config: # a sparse save must not grow an `agent: {}` section
+ config["agent"] = agent_config
config.pop("max_turns", None)
return config
diff --git a/tests/hermes_cli/test_config.py b/tests/hermes_cli/test_config.py
index e29b63521e4..a8616fefc84 100644
--- a/tests/hermes_cli/test_config.py
+++ b/tests/hermes_cli/test_config.py
@@ -918,8 +918,8 @@ class TestConfigSupportFloor:
_V20_EXPECTED = {
"_config_version": 33,
# v31 writes verify_on_stop=False, but False now equals the schema
- # default (opt-in) so the write invariant strips it from disk.
- "agent": {},
+ # default (opt-in) so the write invariant strips it, and the emptied
+ # section goes with it (it survived only as the phantom `agent: {}`).
"model": {"default": "anthropic/claude-fable-5", "provider": "nous"},
"model_catalog": {},
"plugins": {"disabled": ["foo"], "enabled": []},
diff --git a/tests/hermes_cli/test_config_save_integrity.py b/tests/hermes_cli/test_config_save_integrity.py
index 7c6e6397051..25427197a48 100644
--- a/tests/hermes_cli/test_config_save_integrity.py
+++ b/tests/hermes_cli/test_config_save_integrity.py
@@ -35,6 +35,7 @@ def test_authored_nulls_survive_config_writes(tmp_path, monkeypatch, operation):
assert raw["prompt_caching"]["cache_ttl"] is None
assert raw["x_null_preservation"] == seed["x_null_preservation"]
assert "terminal" not in raw
+ assert "agent" not in raw # no section the user never wrote, not even an empty one
assert configured_nofile_soft_limit() is None
assert prompt_caching_disabled_from_config() is True
if operation == "migrate":