mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 06:51:16 +08:00
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
This commit is contained in:
@@ -2029,21 +2029,8 @@ class GatewayRunner:
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Read model from config (same as _run_agent)
|
# Read model from config via shared helper
|
||||||
model = os.getenv("HERMES_MODEL") or os.getenv("LLM_MODEL") or "anthropic/claude-opus-4.6"
|
model = _resolve_gateway_model()
|
||||||
try:
|
|
||||||
import yaml as _y
|
|
||||||
_cfg_path = _hermes_home / "config.yaml"
|
|
||||||
if _cfg_path.exists():
|
|
||||||
with open(_cfg_path, encoding="utf-8") as _f:
|
|
||||||
_cfg = _y.safe_load(_f) or {}
|
|
||||||
_model_cfg = _cfg.get("model", {})
|
|
||||||
if isinstance(_model_cfg, str):
|
|
||||||
model = _model_cfg
|
|
||||||
elif isinstance(_model_cfg, dict):
|
|
||||||
model = _model_cfg.get("default", model)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Determine toolset (same logic as _run_agent)
|
# Determine toolset (same logic as _run_agent)
|
||||||
default_toolset_map = {
|
default_toolset_map = {
|
||||||
@@ -3128,21 +3115,7 @@ class GatewayRunner:
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
model = os.getenv("HERMES_MODEL") or os.getenv("LLM_MODEL") or "anthropic/claude-opus-4.6"
|
model = _resolve_gateway_model()
|
||||||
|
|
||||||
try:
|
|
||||||
import yaml as _y
|
|
||||||
_cfg_path = _hermes_home / "config.yaml"
|
|
||||||
if _cfg_path.exists():
|
|
||||||
with open(_cfg_path, encoding="utf-8") as _f:
|
|
||||||
_cfg = _y.safe_load(_f) or {}
|
|
||||||
_model_cfg = _cfg.get("model", {})
|
|
||||||
if isinstance(_model_cfg, str):
|
|
||||||
model = _model_cfg
|
|
||||||
elif isinstance(_model_cfg, dict):
|
|
||||||
model = _model_cfg.get("default", model)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
runtime_kwargs = _resolve_runtime_agent_kwargs()
|
runtime_kwargs = _resolve_runtime_agent_kwargs()
|
||||||
|
|||||||
Reference in New Issue
Block a user