Skip to content

Commit 01bec40

Browse files
committed
refactor(gateway): consolidate model resolution via _resolve_gateway_model()
Replace two inline copies of the env/config model resolution pattern (in _run_agent_sync and _run_agent) with the _resolve_gateway_model() helper introduced in PR #830. Left untouched: - Session hygiene block: different default (sonnet vs opus) + reads compression config from the same YAML load - /model command: also reads provider from same config block
1 parent 9b58b9b commit 01bec40

File tree

1 file changed

+3
-30
lines changed

1 file changed

+3
-30
lines changed

gateway/run.py

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,21 +2029,8 @@ async def _run_background_task(
20292029
)
20302030
return
20312031

2032-
# Read model from config (same as _run_agent)
2033-
model = os.getenv("HERMES_MODEL") or os.getenv("LLM_MODEL") or "anthropic/claude-opus-4.6"
2034-
try:
2035-
import yaml as _y
2036-
_cfg_path = _hermes_home / "config.yaml"
2037-
if _cfg_path.exists():
2038-
with open(_cfg_path, encoding="utf-8") as _f:
2039-
_cfg = _y.safe_load(_f) or {}
2040-
_model_cfg = _cfg.get("model", {})
2041-
if isinstance(_model_cfg, str):
2042-
model = _model_cfg
2043-
elif isinstance(_model_cfg, dict):
2044-
model = _model_cfg.get("default", model)
2045-
except Exception:
2046-
pass
2032+
# Read model from config via shared helper
2033+
model = _resolve_gateway_model()
20472034

20482035
# Determine toolset (same logic as _run_agent)
20492036
default_toolset_map = {
@@ -3128,21 +3115,7 @@ def run_sync():
31283115
except Exception:
31293116
pass
31303117

3131-
model = os.getenv("HERMES_MODEL") or os.getenv("LLM_MODEL") or "anthropic/claude-opus-4.6"
3132-
3133-
try:
3134-
import yaml as _y
3135-
_cfg_path = _hermes_home / "config.yaml"
3136-
if _cfg_path.exists():
3137-
with open(_cfg_path, encoding="utf-8") as _f:
3138-
_cfg = _y.safe_load(_f) or {}
3139-
_model_cfg = _cfg.get("model", {})
3140-
if isinstance(_model_cfg, str):
3141-
model = _model_cfg
3142-
elif isinstance(_model_cfg, dict):
3143-
model = _model_cfg.get("default", model)
3144-
except Exception:
3145-
pass
3118+
model = _resolve_gateway_model()
31463119

31473120
try:
31483121
runtime_kwargs = _resolve_runtime_agent_kwargs()

0 commit comments

Comments
 (0)