b4fbd6fe9f
Deploy Site / deploy-vercel (push) Has been skipped
Deploy Site / deploy-docs (push) Has been skipped
Build Skills Index / build-index (push) Has been skipped
CI / Deny unrelated histories (push) Has been skipped
CI / Detect affected areas (push) Successful in 27m35s
CI / OSV scan (push) Failing after 4s
CI / Build&Test Docker image (push) Successful in 9s
CI / Supply-chain scan (push) Has been skipped
CI / Lint Docker scripts (push) Failing after 5m13s
CI / Check contributors (push) Failing after 12m8s
CI / Docs Site (push) Failing after 12m8s
CI / TypeScript (push) Failing after 12m8s
CI / Python lints (push) Failing after 12m9s
CI / Python tests (push) Failing after 12m9s
CI / Check uv.lock (push) Failing after 23m22s
CI / CI timing report (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
CI / All required checks pass (push) Has been cancelled
61 lines
2.1 KiB
Python
61 lines
2.1 KiB
Python
"""Regression test: /retry must return the agent response, not None.
|
|
|
|
Before the fix in PR #441, _handle_retry_command() called
|
|
_handle_message(retry_event) but discarded its return value with `return None`,
|
|
so users never received the final response.
|
|
"""
|
|
import pytest
|
|
from unittest.mock import AsyncMock, MagicMock
|
|
from gateway.run import GatewayRunner
|
|
from gateway.platforms.base import MessageEvent, MessageType
|
|
|
|
|
|
@pytest.fixture
|
|
def gateway(tmp_path):
|
|
config = MagicMock()
|
|
config.sessions_dir = tmp_path
|
|
config.max_context_messages = 20
|
|
gw = GatewayRunner.__new__(GatewayRunner)
|
|
gw.config = config
|
|
gw.session_store = MagicMock()
|
|
return gw
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_retry_returns_response_not_none(gateway):
|
|
"""_handle_retry_command must return the inner handler response, not None."""
|
|
gateway.session_store.get_or_create_session.return_value = MagicMock(
|
|
session_id="test-session"
|
|
)
|
|
gateway.session_store.load_transcript.return_value = [
|
|
{"role": "user", "content": "Hello Hermes"},
|
|
{"role": "assistant", "content": "Hi there!"},
|
|
]
|
|
gateway.session_store.rewrite_transcript = MagicMock()
|
|
expected_response = "Hi there! (retried)"
|
|
gateway._handle_message = AsyncMock(return_value=expected_response)
|
|
event = MessageEvent(
|
|
text="/retry",
|
|
message_type=MessageType.TEXT,
|
|
source=MagicMock(),
|
|
)
|
|
result = await gateway._handle_retry_command(event)
|
|
assert result is not None, "/retry must not return None"
|
|
assert result == expected_response
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_retry_no_previous_message(gateway):
|
|
"""If there is no previous user message, return early with a message."""
|
|
gateway.session_store.get_or_create_session.return_value = MagicMock(
|
|
session_id="test-session"
|
|
)
|
|
gateway.session_store.load_transcript.return_value = []
|
|
event = MessageEvent(
|
|
text="/retry",
|
|
message_type=MessageType.TEXT,
|
|
source=MagicMock(),
|
|
)
|
|
result = await gateway._handle_retry_command(event)
|
|
assert result == "No previous message to retry."
|