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.
This commit is contained in:
teknium1 2026-07-29 11:54:48 -07:00 committed by Teknium
parent bfe4cbdc2a
commit 3c6e7b1b11

View file

@ -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.