mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-26 01:01:40 +00:00
Adds optional providers.<id>.request_timeout_seconds and providers.<id>.models.<model>.timeout_seconds config, resolved via a new hermes_cli/timeouts.py helper and applied where client_kwargs is built in run_agent.py. Zero default behavior change: when both keys are unset, the openai SDK default takes over. Mirrors the existing _get_task_timeout pattern in agent/auxiliary_client.py for auxiliary tasks - the primary turn path just never got the equivalent knob. Cross-project demand: openclaw/openclaw#43946 (17 reactions) asks for exactly this config - specifically calls out Ollama cold-start hanging the client.
78 lines
2.1 KiB
Python
78 lines
2.1 KiB
Python
from __future__ import annotations
|
|
|
|
import textwrap
|
|
|
|
from hermes_cli.timeouts import get_provider_request_timeout
|
|
|
|
|
|
def _write_config(tmp_path, body: str) -> None:
|
|
(tmp_path / "config.yaml").write_text(textwrap.dedent(body), encoding="utf-8")
|
|
|
|
|
|
def test_model_timeout_override_wins(monkeypatch, tmp_path):
|
|
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
|
_write_config(
|
|
tmp_path,
|
|
"""\
|
|
providers:
|
|
anthropic:
|
|
request_timeout_seconds: 30
|
|
models:
|
|
claude-opus-4.6:
|
|
timeout_seconds: 120
|
|
""",
|
|
)
|
|
|
|
assert get_provider_request_timeout("anthropic", "claude-opus-4.6") == 120.0
|
|
|
|
|
|
def test_provider_timeout_used_when_no_model_override(monkeypatch, tmp_path):
|
|
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
|
_write_config(
|
|
tmp_path,
|
|
"""\
|
|
providers:
|
|
ollama-local:
|
|
request_timeout_seconds: 300
|
|
""",
|
|
)
|
|
|
|
assert get_provider_request_timeout("ollama-local", "qwen3:32b") == 300.0
|
|
|
|
|
|
def test_missing_timeout_returns_none(monkeypatch, tmp_path):
|
|
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
|
_write_config(
|
|
tmp_path,
|
|
"""\
|
|
providers:
|
|
anthropic:
|
|
models:
|
|
claude-opus-4.6:
|
|
context_length: 200000
|
|
""",
|
|
)
|
|
|
|
assert get_provider_request_timeout("anthropic", "claude-opus-4.6") is None
|
|
assert get_provider_request_timeout("missing-provider", "claude-opus-4.6") is None
|
|
|
|
|
|
def test_invalid_timeout_values_return_none(monkeypatch, tmp_path):
|
|
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
|
_write_config(
|
|
tmp_path,
|
|
"""\
|
|
providers:
|
|
anthropic:
|
|
request_timeout_seconds: "fast"
|
|
models:
|
|
claude-opus-4.6:
|
|
timeout_seconds: -5
|
|
ollama-local:
|
|
request_timeout_seconds: -1
|
|
""",
|
|
)
|
|
|
|
assert get_provider_request_timeout("anthropic", "claude-opus-4.6") is None
|
|
assert get_provider_request_timeout("anthropic", "claude-sonnet-4.5") is None
|
|
assert get_provider_request_timeout("ollama-local") is None
|