mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-07 02:51:50 +00:00
fix: inherit reasoning config in API server runs
This commit is contained in:
parent
aede94e757
commit
8a364df2c8
2 changed files with 39 additions and 2 deletions
|
|
@ -738,10 +738,11 @@ class APIServerAdapter(BasePlatformAdapter):
|
||||||
gateway platforms), falling back to the hermes-api-server default.
|
gateway platforms), falling back to the hermes-api-server default.
|
||||||
"""
|
"""
|
||||||
from run_agent import AIAgent
|
from run_agent import AIAgent
|
||||||
from gateway.run import _resolve_runtime_agent_kwargs, _resolve_gateway_model, _load_gateway_config
|
from gateway.run import _resolve_runtime_agent_kwargs, _resolve_gateway_model, _load_gateway_config, GatewayRunner
|
||||||
from hermes_cli.tools_config import _get_platform_tools
|
from hermes_cli.tools_config import _get_platform_tools
|
||||||
|
|
||||||
runtime_kwargs = _resolve_runtime_agent_kwargs()
|
runtime_kwargs = _resolve_runtime_agent_kwargs()
|
||||||
|
reasoning_config = GatewayRunner._load_reasoning_config()
|
||||||
model = _resolve_gateway_model()
|
model = _resolve_gateway_model()
|
||||||
|
|
||||||
user_config = _load_gateway_config()
|
user_config = _load_gateway_config()
|
||||||
|
|
@ -751,7 +752,6 @@ class APIServerAdapter(BasePlatformAdapter):
|
||||||
|
|
||||||
# Load fallback provider chain so the API server platform has the
|
# Load fallback provider chain so the API server platform has the
|
||||||
# same fallback behaviour as Telegram/Discord/Slack (fixes #4954).
|
# same fallback behaviour as Telegram/Discord/Slack (fixes #4954).
|
||||||
from gateway.run import GatewayRunner
|
|
||||||
fallback_model = GatewayRunner._load_fallback_model()
|
fallback_model = GatewayRunner._load_fallback_model()
|
||||||
|
|
||||||
agent = AIAgent(
|
agent = AIAgent(
|
||||||
|
|
@ -770,6 +770,7 @@ class APIServerAdapter(BasePlatformAdapter):
|
||||||
tool_complete_callback=tool_complete_callback,
|
tool_complete_callback=tool_complete_callback,
|
||||||
session_db=self._ensure_session_db(),
|
session_db=self._ensure_session_db(),
|
||||||
fallback_model=fallback_model,
|
fallback_model=fallback_model,
|
||||||
|
reasoning_config=reasoning_config,
|
||||||
)
|
)
|
||||||
return agent
|
return agent
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -246,6 +246,42 @@ class TestAdapterInit:
|
||||||
adapter = APIServerAdapter(config)
|
adapter = APIServerAdapter(config)
|
||||||
assert adapter._port == 8642
|
assert adapter._port == 8642
|
||||||
|
|
||||||
|
def test_create_agent_forwards_config_reasoning_effort(self, monkeypatch):
|
||||||
|
captured = {}
|
||||||
|
|
||||||
|
class FakeAgent:
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
captured.update(kwargs)
|
||||||
|
|
||||||
|
monkeypatch.setattr("run_agent.AIAgent", FakeAgent)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
"gateway.run._resolve_runtime_agent_kwargs",
|
||||||
|
lambda: {
|
||||||
|
"provider": "openai-codex",
|
||||||
|
"base_url": "https://example.test/v1",
|
||||||
|
"api_mode": "codex_responses",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
monkeypatch.setattr("gateway.run._resolve_gateway_model", lambda: "gpt-5.5")
|
||||||
|
monkeypatch.setattr(
|
||||||
|
"gateway.run._load_gateway_config",
|
||||||
|
lambda: {"agent": {"reasoning_effort": "xhigh"}},
|
||||||
|
)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
"gateway.run.GatewayRunner._load_reasoning_config",
|
||||||
|
staticmethod(lambda: {"enabled": True, "effort": "xhigh"}),
|
||||||
|
)
|
||||||
|
monkeypatch.setattr("gateway.run.GatewayRunner._load_fallback_model", staticmethod(lambda: None))
|
||||||
|
monkeypatch.setattr("hermes_cli.tools_config._get_platform_tools", lambda *_: set())
|
||||||
|
|
||||||
|
adapter = APIServerAdapter(PlatformConfig(enabled=True))
|
||||||
|
monkeypatch.setattr(adapter, "_ensure_session_db", lambda: None)
|
||||||
|
|
||||||
|
agent = adapter._create_agent(session_id="api-session")
|
||||||
|
|
||||||
|
assert isinstance(agent, FakeAgent)
|
||||||
|
assert captured["reasoning_config"] == {"enabled": True, "effort": "xhigh"}
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Auth checking
|
# Auth checking
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue