hermes-agent-features/tests/gateway/test_shutdown_pending_followup.py

33 lines
1.1 KiB
Python

"""Regression tests for queued follow-ups during gateway shutdown.
A user message can arrive while the gateway is still draining an active agent
turn (for example during a service restart after a code update). The active
turn may finish cleanly while the gateway is in draining mode. In that case
we must process the already-queued follow-up before exiting instead of dropping
it silently.
"""
from gateway.run import _should_process_pending_during_drain
def test_clean_result_processes_pending_followup_during_drain():
result = {"final_response": "done", "messages": [], "api_calls": 1}
assert _should_process_pending_during_drain(result) is True
def test_interrupted_result_drops_pending_followup_during_drain():
result = {"interrupted": True, "final_response": ""}
assert _should_process_pending_during_drain(result) is False
def test_failed_result_drops_pending_followup_during_drain():
result = {"failed": True, "final_response": "boom"}
assert _should_process_pending_during_drain(result) is False
def test_missing_result_drops_pending_followup_during_drain():
assert _should_process_pending_during_drain(None) is False