diff --git a/claude_bridge.py b/claude_bridge.py index 4f949aa..2eb5e0b 100644 --- a/claude_bridge.py +++ b/claude_bridge.py @@ -61,6 +61,8 @@ try: QUEUE_KEEPALIVE = float(os.environ.get("AGENT_QUEUE_KEEPALIVE", "20")) except ValueError: QUEUE_KEEPALIVE = 20.0 +if QUEUE_KEEPALIVE <= 0: # ноль крутил бы keepalive без пауз + QUEUE_KEEPALIVE = 20.0 _waiting = 0 diff --git a/tests/test_agent_queue.py b/tests/test_agent_queue.py index abd2e7f..f2a950b 100644 --- a/tests/test_agent_queue.py +++ b/tests/test_agent_queue.py @@ -115,3 +115,12 @@ def test_limit_comes_from_setting(monkeypatch): monkeypatch.setenv("AGENT_MAX_CONCURRENT", "abc") importlib.reload(claude_bridge) assert claude_bridge.MAX_CONCURRENT == 3 # мусор в настройке — прежний предел + + +def test_zero_keepalive_setting_falls_back(monkeypatch): + # Ноль или минус дали бы бешеный цикл keepalive без пауз (нашёл дипсик 28.10.2026). + import claude_bridge + for bad in ("0", "-5", "abc"): + monkeypatch.setenv("AGENT_QUEUE_KEEPALIVE", bad) + importlib.reload(claude_bridge) + assert claude_bridge.QUEUE_KEEPALIVE == 20.0