Skip to content

The agent that grows with you

test(gateway): pin the startup Agent-budget line through GatewayRunner.start()

teknium13b7eda08878c
diff --git a/tests/gateway/test_startup_agent_budget_log.py b/tests/gateway/test_startup_agent_budget_log.py
index d14c8585ea0..a8a6118a828 100644
--- a/tests/gateway/test_startup_agent_budget_log.py
+++ b/tests/gateway/test_startup_agent_budget_log.py
@@ -4,13 +4,14 @@ import logging
import pytest
+from gateway.config import GatewayConfig
from gateway.run import GatewayRunner, _bridge_max_turns_to_env, _current_max_iterations
from hermes_cli.config import TURN_LIMIT_UNLIMITED
@pytest.mark.parametrize(
("max_turns", "expected"),
- [({"max_turns": "unlimited"}, "unlimited"), ({"max_turns": 50}, "50"), ({}, "90")],
+ [({"max_turns": 50}, "50"), ({}, "90")],
)
def test_agent_budget_line_matches_enforced_limit(monkeypatch, max_turns, expected):
monkeypatch.setenv("HERMES_MAX_ITERATIONS", "90") # .env value: config wins when set, else it is the legacy bridge
@@ -34,3 +35,17 @@ def test_agent_budget_line_matches_enforced_limit(monkeypatch, max_turns, expect
assert line, records
assert f"max_iterations={expected}" in line[0]
assert ("unlimited" in line[0]) == (enforced == TURN_LIMIT_UNLIMITED)
+
+
+async def test_gateway_start_logs_unlimited_agent_budget(monkeypatch, tmp_path, caplog):
+ """Drive the real startup path: ``GatewayRunner.start()`` must emit the budget line, and with the
+ bridged ``unlimited`` spelling it says so instead of ``int()`` raising inside ``suppress()``
+ and logging nothing (#116888)."""
+ monkeypatch.setenv("HERMES_HOME", str(tmp_path))
+ monkeypatch.setenv("HERMES_MAX_ITERATIONS", "unlimited") # what _bridge_max_turns_to_env writes for max_turns: unlimited
+ runner = GatewayRunner(GatewayConfig(sessions_dir=tmp_path / "sessions"))
+ with caplog.at_level(logging.INFO, logger="gateway.run"):
+ assert await runner.start() is True
+ lines = [r.getMessage() for r in caplog.records if "Agent budget" in r.getMessage()]
+ assert lines and "max_iterations=unlimited" in lines[0], caplog.text