Skip to content

The agent that grows with you

test: patch load_config_readonly alongside load_config across affected suites

teknium1243c9182b1f5
diff --git a/tests/agent/lsp/test_service.py b/tests/agent/lsp/test_service.py
index 9a526252a22..61fc72d4f6e 100644
--- a/tests/agent/lsp/test_service.py
+++ b/tests/agent/lsp/test_service.py
@@ -295,6 +295,10 @@ def test_create_from_config_reads_idle_timeout(monkeypatch):
"hermes_cli.config.load_config",
lambda: {"lsp": {"enabled": False, "idle_timeout": 42}},
)
+ monkeypatch.setattr(
+ "hermes_cli.config.load_config_readonly",
+ lambda: {"lsp": {"enabled": False, "idle_timeout": 42}},
+ )
svc = LSPService.create_from_config()
assert svc is not None
assert svc._idle_timeout == 42.0
@@ -307,6 +311,10 @@ def test_create_from_config_invalid_idle_timeout_falls_back(monkeypatch):
"hermes_cli.config.load_config",
lambda: {"lsp": {"enabled": False, "idle_timeout": "not-a-number"}},
)
+ monkeypatch.setattr(
+ "hermes_cli.config.load_config_readonly",
+ lambda: {"lsp": {"enabled": False, "idle_timeout": "not-a-number"}},
+ )
svc = LSPService.create_from_config()
assert svc is not None
assert svc._idle_timeout == DEFAULT_IDLE_TIMEOUT
@@ -322,6 +330,10 @@ def test_create_from_config_clamps_tiny_idle_timeout(monkeypatch):
"hermes_cli.config.load_config",
lambda: {"lsp": {"enabled": False, "idle_timeout": 2}},
)
+ monkeypatch.setattr(
+ "hermes_cli.config.load_config_readonly",
+ lambda: {"lsp": {"enabled": False, "idle_timeout": 2}},
+ )
svc = LSPService.create_from_config()
assert svc is not None
assert svc._idle_timeout == MIN_IDLE_TIMEOUT
@@ -330,6 +342,10 @@ def test_create_from_config_clamps_tiny_idle_timeout(monkeypatch):
"hermes_cli.config.load_config",
lambda: {"lsp": {"enabled": False, "idle_timeout": 0}},
)
+ monkeypatch.setattr(
+ "hermes_cli.config.load_config_readonly",
+ lambda: {"lsp": {"enabled": False, "idle_timeout": 0}},
+ )
svc = LSPService.create_from_config()
assert svc is not None
assert svc._idle_timeout == 0
diff --git a/tests/agent/test_auxiliary_client.py b/tests/agent/test_auxiliary_client.py
index 58d615e5c85..c700408c4cb 100644
--- a/tests/agent/test_auxiliary_client.py
+++ b/tests/agent/test_auxiliary_client.py
@@ -290,6 +290,7 @@ class TestResolveTaskProviderModel:
lambda cfg, name: preset,
)
monkeypatch.setattr("hermes_cli.config.load_config", lambda: {"moa": {}})
+ monkeypatch.setattr("hermes_cli.config.load_config_readonly", lambda: {"moa": {}})
resolved_provider, model, base_url, api_key, api_mode = _resolve_task_provider_model(
task="title_generation",
@@ -325,6 +326,7 @@ class TestResolveTaskProviderModel:
lambda cfg, name: preset,
)
monkeypatch.setattr("hermes_cli.config.load_config", lambda: {"moa": {}})
+ monkeypatch.setattr("hermes_cli.config.load_config_readonly", lambda: {"moa": {}})
resolved_provider, model, base_url, api_key, api_mode = _resolve_task_provider_model(
task="title_generation",
@@ -355,6 +357,7 @@ class TestResolveTaskProviderModel:
)
monkeypatch.setattr("hermes_cli.moa_config.resolve_moa_preset", fake_resolve)
monkeypatch.setattr("hermes_cli.config.load_config", lambda: {"moa": {}})
+ monkeypatch.setattr("hermes_cli.config.load_config_readonly", lambda: {"moa": {}})
resolved_provider, model, base_url, api_key, api_mode = _resolve_task_provider_model(
task="title_generation",
@@ -373,6 +376,7 @@ class TestResolveTaskProviderModel:
lambda cfg, name: (_ for _ in ()).throw(KeyError("gone-preset")),
)
monkeypatch.setattr("hermes_cli.config.load_config", lambda: {"moa": {}})
+ monkeypatch.setattr("hermes_cli.config.load_config_readonly", lambda: {"moa": {}})
resolved_provider, model, base_url, api_key, api_mode = _resolve_task_provider_model(
task="title_generation",
@@ -3765,7 +3769,7 @@ class TestAuxiliaryTaskExtraBody:
}
}
- with patch("hermes_cli.config.load_config", return_value=config), patch(
+ with patch("hermes_cli.config.load_config", return_value=config), patch("hermes_cli.config.load_config_readonly", return_value=config), patch(
"agent.auxiliary_client._get_cached_client",
return_value=(client, "glm-4.5-air"),
):
@@ -3796,7 +3800,7 @@ class TestAuxiliaryTaskExtraBody:
}
}
- with patch("hermes_cli.config.load_config", return_value=config), patch(
+ with patch("hermes_cli.config.load_config", return_value=config), patch("hermes_cli.config.load_config_readonly", return_value=config), patch(
"agent.auxiliary_client._get_cached_client",
return_value=(client, "glm-4.5-air"),
):
@@ -3822,7 +3826,7 @@ class TestAuxiliaryTaskExtraBody:
}
}
- with patch("hermes_cli.config.load_config", return_value=config), patch(
+ with patch("hermes_cli.config.load_config", return_value=config), patch("hermes_cli.config.load_config_readonly", return_value=config), patch(
"agent.auxiliary_client._get_cached_client",
return_value=(client, "glm-4.5-air"),
):
@@ -3841,7 +3845,7 @@ class TestAuxiliaryTaskExtraBody:
config = {"auxiliary": {"session_search": {"reasoning_effort": "none"}}}
- with patch("hermes_cli.config.load_config", return_value=config), patch(
+ with patch("hermes_cli.config.load_config", return_value=config), patch("hermes_cli.config.load_config_readonly", return_value=config), patch(
"agent.auxiliary_client._get_cached_client",
return_value=(client, "glm-4.5-air"),
):
@@ -3865,7 +3869,7 @@ class TestAuxiliaryTaskExtraBody:
}
}
- with patch("hermes_cli.config.load_config", return_value=config), patch(
+ with patch("hermes_cli.config.load_config", return_value=config), patch("hermes_cli.config.load_config_readonly", return_value=config), patch(
"agent.auxiliary_client._get_cached_client",
return_value=(client, "glm-4.5-air"),
):
@@ -3881,7 +3885,7 @@ class TestAuxiliaryTaskExtraBody:
config = {"auxiliary": {"session_search": {"reasoning_effort": "warp9"}}}
- with patch("hermes_cli.config.load_config", return_value=config), patch(
+ with patch("hermes_cli.config.load_config", return_value=config), patch("hermes_cli.config.load_config_readonly", return_value=config), patch(
"agent.auxiliary_client._get_cached_client",
return_value=(client, "glm-4.5-air"),
), caplog.at_level(logging.WARNING, logger="agent.auxiliary_client"):
@@ -3896,7 +3900,7 @@ class TestAuxiliaryTaskExtraBody:
from agent.auxiliary_client import _get_task_extra_body
config = {"auxiliary": {"session_search": {"reasoning_effort": ""}}}
- with patch("hermes_cli.config.load_config", return_value=config):
+ with patch("hermes_cli.config.load_config", return_value=config), patch("hermes_cli.config.load_config_readonly", return_value=config):
assert _get_task_extra_body("session_search") == {}
@pytest.mark.parametrize("moa_task", ["moa_reference", "moa_aggregator"])
@@ -3906,7 +3910,7 @@ class TestAuxiliaryTaskExtraBody:
from agent.auxiliary_client import _get_task_extra_body
config = {"auxiliary": {moa_task: {"reasoning_effort": "xhigh"}}}
- with patch("hermes_cli.config.load_config", return_value=config), \
+ with patch("hermes_cli.config.load_config", return_value=config), patch("hermes_cli.config.load_config_readonly", return_value=config), \
caplog.at_level(logging.WARNING, logger="agent.auxiliary_client"):
result = _get_task_extra_body(moa_task)
@@ -6665,7 +6669,7 @@ class TestCustomEndpointApiKeyInheritance:
captured.update(kwargs)
return MagicMock()
- with patch("hermes_cli.config.load_config", return_value=fake_config), \
+ with patch("hermes_cli.config.load_config", return_value=fake_config), patch("hermes_cli.config.load_config_readonly", return_value=fake_config), \
patch.object(ac, "_create_openai_client", side_effect=_capture_create):
client, model = resolve_provider_client(
"custom",
@@ -6693,7 +6697,7 @@ class TestCustomEndpointApiKeyInheritance:
captured.update(kwargs)
return MagicMock()
- with patch("hermes_cli.config.load_config", return_value=fake_config), \
+ with patch("hermes_cli.config.load_config", return_value=fake_config), patch("hermes_cli.config.load_config_readonly", return_value=fake_config), \
patch.object(ac, "_create_openai_client", side_effect=_capture_create):
client, model = resolve_provider_client(
"custom",
@@ -6718,7 +6722,7 @@ class TestCustomEndpointApiKeyInheritance:
captured.update(kwargs)
return MagicMock()
- with patch("hermes_cli.config.load_config", return_value=fake_config), \
+ with patch("hermes_cli.config.load_config", return_value=fake_config), patch("hermes_cli.config.load_config_readonly", return_value=fake_config), \
patch.object(ac, "_create_openai_client", side_effect=_capture_create):
client, model = resolve_provider_client(
"custom",
@@ -6745,6 +6749,7 @@ class TestCustomEndpointApiKeyInheritance:
with patch.object(ac, "_RUNTIME_MAIN_API_KEY", "sk-runtime-key"), \
patch.object(ac, "_RUNTIME_MAIN_BASE_URL", "https://gw.example.com/v1"), \
patch("hermes_cli.config.load_config", return_value={"model": {}}), \
+ patch("hermes_cli.config.load_config_readonly", return_value={"model": {}}), \
patch.object(ac, "_create_openai_client", side_effect=_capture_create):
client, model = resolve_provider_client(
"custom",
@@ -6776,7 +6781,7 @@ class TestCustomEndpointApiKeyInheritance:
captured.update(kwargs)
return MagicMock()
- with patch("hermes_cli.config.load_config", return_value=fake_config), \
+ with patch("hermes_cli.config.load_config", return_value=fake_config), patch("hermes_cli.config.load_config_readonly", return_value=fake_config), \
patch.object(ac, "_create_openai_client", side_effect=_capture_create):
client, model = resolve_provider_client(
"custom",
@@ -6801,7 +6806,7 @@ class TestCustomEndpointApiKeyInheritance:
captured.update(kwargs)
return MagicMock()
- with patch("hermes_cli.config.load_config", return_value=fake_config), \
+ with patch("hermes_cli.config.load_config", return_value=fake_config), patch("hermes_cli.config.load_config_readonly", return_value=fake_config), \
patch.object(ac, "_create_openai_client", side_effect=_capture_create):
client, model = resolve_provider_client(
"custom",
diff --git a/tests/agent/test_auxiliary_client_azure_foundry.py b/tests/agent/test_auxiliary_client_azure_foundry.py
index f3e06e5a513..37e1c67f886 100644
--- a/tests/agent/test_auxiliary_client_azure_foundry.py
+++ b/tests/agent/test_auxiliary_client_azure_foundry.py
@@ -73,6 +73,10 @@ def patch_load_config(monkeypatch):
"hermes_cli.config.load_config",
lambda: {"model": model_cfg},
)
+ monkeypatch.setattr(
+ "hermes_cli.config.load_config_readonly",
+ lambda: {"model": model_cfg},
+ )
return _apply
diff --git a/tests/agent/test_curator.py b/tests/agent/test_curator.py
index f0630d7850c..3f0f360d92d 100644
--- a/tests/agent/test_curator.py
+++ b/tests/agent/test_curator.py
@@ -1332,6 +1332,14 @@ def test_review_fork_forwards_runtime_pool_and_overrides(curator_env, monkeypatc
"hermes_cli.config.load_config",
lambda: {"model": {"provider": "custom:hyper-charm", "default": "glm-5.2"}},
)
+ monkeypatch.setattr(
+ "hermes_cli.config.load_config_readonly",
+ lambda: {"model": {"provider": "custom:hyper-charm", "default": "glm-5.2"}},
+ )
+ monkeypatch.setattr(
+ "hermes_cli.config.load_config_readonly",
+ lambda: {"model": {"provider": "custom:hyper-charm", "default": "glm-5.2"}},
+ )
monkeypatch.setattr(
"hermes_cli.runtime_provider.resolve_runtime_provider",
_fake_resolve_runtime_provider,
@@ -1355,6 +1363,14 @@ def test_review_fork_uses_runtime_model_and_output_cap(curator_env, monkeypatch)
"hermes_cli.config.load_config",
lambda: {"model": {"provider": "custom:gateway", "default": "gateway"}},
)
+ monkeypatch.setattr(
+ "hermes_cli.config.load_config_readonly",
+ lambda: {"model": {"provider": "custom:gateway", "default": "gateway"}},
+ )
+ monkeypatch.setattr(
+ "hermes_cli.config.load_config_readonly",
+ lambda: {"model": {"provider": "custom:gateway", "default": "gateway"}},
+ )
monkeypatch.setattr(
"hermes_cli.runtime_provider.resolve_runtime_provider",
lambda **_kwargs: {
@@ -1404,6 +1420,18 @@ def test_review_fork_merges_slot_extra_body_over_runtime(curator_env, monkeypatc
},
},
)
+ monkeypatch.setattr(
+ "hermes_cli.config.load_config_readonly",
+ lambda: {
+ "auxiliary": {
+ "curator": {
+ "provider": "custom:gateway",
+ "model": "gateway",
+ "extra_body": {"shared": "slot", "slot_only": True},
+ },
+ },
+ },
+ )
monkeypatch.setattr(
"hermes_cli.runtime_provider.resolve_runtime_provider",
lambda **_kwargs: {
diff --git a/tests/agent/test_openrouter_response_cache.py b/tests/agent/test_openrouter_response_cache.py
index 4bbbcc964d3..4bae25c7cea 100644
--- a/tests/agent/test_openrouter_response_cache.py
+++ b/tests/agent/test_openrouter_response_cache.py
@@ -119,7 +119,7 @@ class TestBuildOrHeaders:
fake_cfg = {
"openrouter": {"response_cache": True, "response_cache_ttl": 900},
}
- with patch("hermes_cli.config.load_config", return_value=fake_cfg):
+ with patch("hermes_cli.config.load_config", return_value=fake_cfg), patch("hermes_cli.config.load_config_readonly", return_value=fake_cfg):
headers = build_or_headers(or_config=None)
assert headers["X-OpenRouter-Cache"] == "true"
assert headers["X-OpenRouter-Cache-TTL"] == "900"
@@ -128,7 +128,8 @@ class TestBuildOrHeaders:
"""When load_config() fails, build_or_headers still returns base headers."""
from agent.auxiliary_client import build_or_headers
- with patch("hermes_cli.config.load_config", side_effect=RuntimeError("boom")):
+ with patch("hermes_cli.config.load_config", side_effect=RuntimeError("boom")), \
+ patch("hermes_cli.config.load_config_readonly", side_effect=RuntimeError("boom")):
headers = build_or_headers(or_config=None)
# Should have base attribution but no cache headers
assert "HTTP-Referer" in headers
diff --git a/tests/agent/test_prompt_builder.py b/tests/agent/test_prompt_builder.py
index d0639c22745..7dad71bcadb 100644
--- a/tests/agent/test_prompt_builder.py
+++ b/tests/agent/test_prompt_builder.py
@@ -138,6 +138,8 @@ class TestTruncateContent:
monkeypatch.setattr("hermes_cli.config.load_config", default_load_config)
+ monkeypatch.setattr("hermes_cli.config.load_config_readonly", default_load_config)
+
def test_context_file_max_chars_default_matches_upstream_limit(self):
assert CONTEXT_FILE_MAX_CHARS == 20_000
@@ -171,6 +173,8 @@ class TestTruncateContent:
return {"context_file_max_chars": 120}
monkeypatch.setattr("hermes_cli.config.load_config", fake_load_config)
+
+ monkeypatch.setattr("hermes_cli.config.load_config_readonly", fake_load_config)
content = "HEAD" + "x" * 160 + "TAIL"
result = _truncate_content(content, "config.md")
@@ -186,6 +190,8 @@ class TestTruncateContent:
return {"context_file_max_chars": 120}
monkeypatch.setattr("hermes_cli.config.load_config", fake_load_config)
+
+ monkeypatch.setattr("hermes_cli.config.load_config_readonly", fake_load_config)
content = "x" * 180
result = _truncate_content(content, "explicit.md", max_chars=200)
@@ -198,6 +204,8 @@ class TestTruncateContent:
monkeypatch.setattr("hermes_cli.config.load_config", fake_load_config)
+ monkeypatch.setattr("hermes_cli.config.load_config_readonly", fake_load_config)
+
_truncate_content("x" * 180, "warning.md")
warnings = drain_truncation_warnings()
@@ -215,6 +223,8 @@ class TestTruncateContent:
monkeypatch.setattr("hermes_cli.config.load_config", fake_load_config)
+ monkeypatch.setattr("hermes_cli.config.load_config_readonly", fake_load_config)
+
# Generate a warning in a fresh child context, then assert it did NOT
# leak into the parent context's accumulator.
def _child():
@@ -242,6 +252,7 @@ class TestDynamicContextFileCap:
def _no_explicit_config(self, monkeypatch):
# No explicit context_file_max_chars → dynamic path is eligible.
monkeypatch.setattr("hermes_cli.config.load_config", lambda: {})
+ monkeypatch.setattr("hermes_cli.config.load_config_readonly", lambda: {})
def test_dynamic_floor_for_small_window(self):
# A small context window never drops below the historical 20K floor.
@@ -273,6 +284,14 @@ class TestDynamicContextFileCap:
"hermes_cli.config.load_config",
lambda: {"context_file_max_chars": 1_000},
)
+ monkeypatch.setattr(
+ "hermes_cli.config.load_config_readonly",
+ lambda: {"context_file_max_chars": 1_000},
+ )
+ monkeypatch.setattr(
+ "hermes_cli.config.load_config_readonly",
+ lambda: {"context_file_max_chars": 1_000},
+ )
assert _get_context_file_max_chars(200_000) == 1_000
def test_large_window_avoids_truncation_of_midsize_doc(self):
@@ -1406,6 +1425,14 @@ class TestEnvironmentHints:
"hermes_cli.config.load_config",
lambda: {"agent": {"environment_hint": "CONFIG-VALUE"}},
)
+ monkeypatch.setattr(
+ "hermes_cli.config.load_config_readonly",
+ lambda: {"agent": {"environment_hint": "CONFIG-VALUE"}},
+ )
+ monkeypatch.setattr(
+ "hermes_cli.config.load_config_readonly",
+ lambda: {"agent": {"environment_hint": "CONFIG-VALUE"}},
+ )
_pb._clear_backend_probe_cache()
result = _pb.build_environment_hints()
assert "ENV-WINS" in result
@@ -1421,6 +1448,14 @@ class TestEnvironmentHints:
"hermes_cli.config.load_config",
lambda: {"agent": {"environment_hint": "CONFIG-VALUE"}},
)
+ monkeypatch.setattr(
+ "hermes_cli.config.load_config_readonly",
+ lambda: {"agent": {"environment_hint": "CONFIG-VALUE"}},
+ )
+ monkeypatch.setattr(
+ "hermes_cli.config.load_config_readonly",
+ lambda: {"agent": {"environment_hint": "CONFIG-VALUE"}},
+ )
_pb._clear_backend_probe_cache()
result = _pb.build_environment_hints()
assert "CONFIG-VALUE" in result
@@ -1432,6 +1467,7 @@ class TestEnvironmentHints:
monkeypatch.delenv("TERMINAL_ENV", raising=False)
monkeypatch.delenv("HERMES_ENVIRONMENT_HINT", raising=False)
monkeypatch.setattr("hermes_cli.config.load_config", lambda: {"agent": {}})
+ monkeypatch.setattr("hermes_cli.config.load_config_readonly", lambda: {"agent": {}})
_pb._clear_backend_probe_cache()
result = _pb.build_environment_hints()
assert "Host:" in result
diff --git a/tests/agent/test_title_generator.py b/tests/agent/test_title_generator.py
index 8f0af90ab31..02408aa3693 100644
--- a/tests/agent/test_title_generator.py
+++ b/tests/agent/test_title_generator.py
@@ -54,11 +54,12 @@ class TestGenerateTitle:
def test_title_language_reads_config(self):
cfg = {"auxiliary": {"title_generation": {"language": " French "}}}
- with patch("hermes_cli.config.load_config", return_value=cfg):
+ with patch("hermes_cli.config.load_config", return_value=cfg), patch("hermes_cli.config.load_config_readonly", return_value=cfg):
assert _title_language() == "French"
- with patch("hermes_cli.config.load_config", return_value={}):
+ with patch("hermes_cli.config.load_config", return_value={}), patch("hermes_cli.config.load_config_readonly", return_value={}):
assert _title_language() == ""
- with patch("hermes_cli.config.load_config", side_effect=RuntimeError("bad config")):
+ with patch("hermes_cli.config.load_config", side_effect=RuntimeError("bad config")), \
+ patch("hermes_cli.config.load_config_readonly", side_effect=RuntimeError("bad config")):
assert _title_language() == ""
def test_default_timeout_delegates_to_auxiliary_config(self):
diff --git a/tests/run_agent/test_background_review_cost_controls.py b/tests/run_agent/test_background_review_cost_controls.py
index 7e5da983faf..e8a8df20cbc 100644
--- a/tests/run_agent/test_background_review_cost_controls.py
+++ b/tests/run_agent/test_background_review_cost_controls.py
@@ -44,7 +44,7 @@ class _FakeAgent:
def test_routing_auto_inherits_parent_and_downgrades_codex_app_server():
agent = _FakeAgent()
cfg = {"auxiliary": {"background_review": {"provider": "auto", "model": ""}}}
- with patch("hermes_cli.config.load_config", return_value=cfg):
+ with patch("hermes_cli.config.load_config", return_value=cfg), patch("hermes_cli.config.load_config_readonly", return_value=cfg):
rt = br._resolve_review_runtime(agent)
assert rt["routed"] is False
assert rt["provider"] == "openai-codex"
@@ -64,7 +64,7 @@ def test_routing_to_different_model_marks_routed_and_resolves_credentials():
"request_overrides": {"extra_body": {"store": False}},
"max_output_tokens": 2048,
}
- with patch("hermes_cli.config.load_config", return_value=cfg), \
+ with patch("hermes_cli.config.load_config", return_value=cfg), patch("hermes_cli.config.load_config_readonly", return_value=cfg), \
patch("hermes_cli.runtime_provider.resolve_runtime_provider", return_value=fake_rp):
rt = br._resolve_review_runtime(agent)
assert rt["routed"] is True
@@ -81,7 +81,7 @@ def test_unrouted_runtime_keeps_parent_pool_and_overrides():
agent._credential_pool = "parent-pool"
agent.request_overrides = {"service_tier": "priority"}
agent.max_tokens = 4096
- with patch("hermes_cli.config.load_config", return_value={}):
+ with patch("hermes_cli.config.load_config", return_value={}), patch("hermes_cli.config.load_config_readonly", return_value={}):
rt = br._resolve_review_runtime(agent)
assert rt["credential_pool"] == "parent-pool"
assert rt["request_overrides"] == {"service_tier": "priority"}
@@ -93,7 +93,7 @@ def test_routing_same_model_as_parent_is_not_routed():
cfg = {"auxiliary": {"background_review": {
"provider": "openrouter", "model": "anthropic/claude-opus-4.8",
}}}
- with patch("hermes_cli.config.load_config", return_value=cfg):
+ with patch("hermes_cli.config.load_config", return_value=cfg), patch("hermes_cli.config.load_config_readonly", return_value=cfg):
rt = br._resolve_review_runtime(agent)
assert rt["routed"] is False # same model/provider → keep full-replay path
@@ -103,7 +103,7 @@ def test_routing_resolution_failure_falls_back_to_parent():
cfg = {"auxiliary": {"background_review": {
"provider": "openrouter", "model": "google/gemini-3-flash-preview",
}}}
- with patch("hermes_cli.config.load_config", return_value=cfg), \
+ with patch("hermes_cli.config.load_config", return_value=cfg), patch("hermes_cli.config.load_config_readonly", return_value=cfg), \
patch("hermes_cli.runtime_provider.resolve_runtime_provider",
side_effect=RuntimeError("boom")):
rt = br._resolve_review_runtime(agent)
diff --git a/tests/run_agent/test_compression_feasibility.py b/tests/run_agent/test_compression_feasibility.py
index 8988d3db581..7eff0dca20c 100644
--- a/tests/run_agent/test_compression_feasibility.py
+++ b/tests/run_agent/test_compression_feasibility.py
@@ -270,7 +270,7 @@ def test_init_feasibility_check_uses_aux_context_override_from_config():
mock_client.api_key = "sk-custom"
with (
- patch("hermes_cli.config.load_config", return_value=cfg),
+ patch("hermes_cli.config.load_config", return_value=cfg), patch("hermes_cli.config.load_config_readonly", return_value=cfg),
patch("run_agent.get_tool_definitions", return_value=[]),
patch("run_agent.check_toolset_requirements", return_value={}),
patch("run_agent.OpenAI"),
diff --git a/tests/run_agent/test_provider_attribution_headers.py b/tests/run_agent/test_provider_attribution_headers.py
index 109f8bd4e9c..024a3d664db 100644
--- a/tests/run_agent/test_provider_attribution_headers.py
+++ b/tests/run_agent/test_provider_attribution_headers.py
@@ -232,6 +232,8 @@ def test_openrouter_headers_include_response_cache_when_enabled(mock_openai):
with patch("hermes_cli.config.load_config", return_value={
"openrouter": {"response_cache": True, "response_cache_ttl": 600},
+ }), patch("hermes_cli.config.load_config_readonly", return_value={
+ "openrouter": {"response_cache": True, "response_cache_ttl": 600},
}):
agent._apply_client_headers_for_base_url("https://openrouter.ai/api/v1")
@@ -263,6 +265,8 @@ def test_user_default_headers_override_sdk_user_agent(mock_openai):
with patch("hermes_cli.config.load_config", return_value={
"model": {"default_headers": {"User-Agent": "curl/8.7.1", "X-Extra": "1"}},
+ }), patch("hermes_cli.config.load_config_readonly", return_value={
+ "model": {"default_headers": {"User-Agent": "curl/8.7.1", "X-Extra": "1"}},
}):
agent._apply_client_headers_for_base_url("http://localhost:8080/v1")
@@ -286,6 +290,8 @@ def test_user_default_headers_win_over_provider_defaults(mock_openai):
with patch("hermes_cli.config.load_config", return_value={
"model": {"default_headers": {"X-Title": "MyApp"}},
+ }), patch("hermes_cli.config.load_config_readonly", return_value={
+ "model": {"default_headers": {"X-Title": "MyApp"}},
}):
agent._apply_client_headers_for_base_url("https://openrouter.ai/api/v1")
@@ -306,7 +312,7 @@ def test_no_user_default_headers_leaves_provider_defaults_untouched(mock_openai)
skip_memory=True,
)
- with patch("hermes_cli.config.load_config", return_value={"model": {}}):
+ with patch("hermes_cli.config.load_config", return_value={"model": {}}), patch("hermes_cli.config.load_config_readonly", return_value={"model": {}}):
agent._apply_client_headers_for_base_url("https://openrouter.ai/api/v1")
headers = agent._client_kwargs["default_headers"]
@@ -332,6 +338,8 @@ def test_user_default_headers_skipped_for_anthropic_mode(mock_openai):
with patch("hermes_cli.config.load_config", return_value={
"model": {"default_headers": {"User-Agent": "curl/8.7.1"}},
+ }), patch("hermes_cli.config.load_config_readonly", return_value={
+ "model": {"default_headers": {"User-Agent": "curl/8.7.1"}},
}):
agent._apply_user_default_headers()
@@ -353,6 +361,8 @@ def test_openrouter_headers_no_cache_when_disabled(mock_openai):
with patch("hermes_cli.config.load_config", return_value={
"openrouter": {"response_cache": False},
+ }), patch("hermes_cli.config.load_config_readonly", return_value={
+ "openrouter": {"response_cache": False},
}):
agent._apply_client_headers_for_base_url("https://openrouter.ai/api/v1")
diff --git a/tests/run_agent/test_switch_model_context.py b/tests/run_agent/test_switch_model_context.py
index db63f58ab4e..d77ab7fbbf8 100644
--- a/tests/run_agent/test_switch_model_context.py
+++ b/tests/run_agent/test_switch_model_context.py
@@ -99,7 +99,7 @@ def _make_direct_start_agent(
cfg: dict, *, model: str, provider: str, base_url: str
) -> AIAgent:
with (
- patch("hermes_cli.config.load_config", return_value=cfg),
+ patch("hermes_cli.config.load_config", return_value=cfg), patch("hermes_cli.config.load_config_readonly", return_value=cfg),
patch("run_agent.get_tool_definitions", return_value=[]),
patch("run_agent.check_toolset_requirements", return_value={}),
patch("run_agent.OpenAI"),
@@ -1043,6 +1043,8 @@ def test_lmstudio_switch_uses_destination_context_and_verified_runtime(monkeypat
return LMStudioLoadResult(100_000)
monkeypatch.setattr("hermes_cli.config.load_config", fake_load_config)
+
+ monkeypatch.setattr("hermes_cli.config.load_config_readonly", fake_load_config)
monkeypatch.setattr("hermes_cli.config.get_compatible_custom_providers", fake_compatible)
monkeypatch.setattr("hermes_cli.config.get_custom_provider_context_length", fake_provider_context)
monkeypatch.setattr(AIAgent, "_ensure_lmstudio_runtime_loaded", fake_lmstudio_load)