From 3c6e7b1b114db790ae377f101a756e2d69bc70d9 Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Wed, 29 Jul 2026 11:54:48 -0700 Subject: [PATCH] fix(config): don't share the cached models mapping with normalized entries Companion to the no-mutate fix: normalized['models'] retained a reference to the caller's (possibly cached) models dict, and the normalized entry escapes into long-lived runtime state (agent._custom_providers). Shallow-copy so runtime writes can never reach the shared config cache. --- hermes_cli/config.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hermes_cli/config.py b/hermes_cli/config.py index d139e2e0b14..38669ed3521 100644 --- a/hermes_cli/config.py +++ b/hermes_cli/config.py @@ -1399,7 +1399,10 @@ def _normalize_custom_provider_entry( models = entry.get("models") if isinstance(models, dict) and models: - normalized["models"] = models + # Shallow-copy: `entry` may alias a cached config sub-dict, and the + # normalized entry escapes into long-lived runtime state + # (agent._custom_providers) — don't share the cached models mapping. + normalized["models"] = dict(models) elif isinstance(models, list) and models: # Hand-edited configs (and older Hermes versions) may write # ``models`` as a plain list of ids or as ``[{id: ...}]`` rows.