diff --git a/src/core/services/tool_call_handlers/pytest_full_suite_handler.py b/src/core/services/tool_call_handlers/pytest_full_suite_handler.py index c15a82a6..35ad4515 100644 --- a/src/core/services/tool_call_handlers/pytest_full_suite_handler.py +++ b/src/core/services/tool_call_handlers/pytest_full_suite_handler.py @@ -13,6 +13,7 @@ import logging import re +from collections.abc import Sequence from dataclasses import dataclass from pathlib import Path from typing import Any @@ -81,7 +82,11 @@ def _extract_command(arguments: Any) -> str | None: return None - if isinstance(arguments, list): + if ( + isinstance(arguments, Sequence) + and not isinstance(arguments, str | bytes) + and arguments + ): return " ".join(str(item) for item in arguments) return None diff --git a/tests/unit/core/services/tool_call_handlers/test_pytest_full_suite_handler.py b/tests/unit/core/services/tool_call_handlers/test_pytest_full_suite_handler.py index 11ddf82c..f9a85cd4 100644 --- a/tests/unit/core/services/tool_call_handlers/test_pytest_full_suite_handler.py +++ b/tests/unit/core/services/tool_call_handlers/test_pytest_full_suite_handler.py @@ -143,6 +143,24 @@ async def test_handler_detects_list_based_command() -> None: assert result.should_swallow is True +@pytest.mark.asyncio +async def test_handler_detects_tuple_arguments_root_level() -> None: + handler = PytestFullSuiteHandler(enabled=True) + context = ToolCallContext( + session_id="session-tuple", + backend_name="backend", + model_name="model", + full_response={}, + tool_name="bash", + tool_arguments=("pytest", "-q"), + ) + + assert await handler.can_handle(context) is True + result = await handler.handle(context) + + assert result.should_swallow is True + + @pytest.mark.asyncio async def test_handler_enabled_flag_controls_behavior() -> None: handler = PytestFullSuiteHandler(enabled=False)