fix(tool): implement tool_type filter in ToolRegistry.list_tools()
CI / lint (pull_request) Successful in 21s
CI / quality (pull_request) Successful in 33s
CI / typecheck (pull_request) Successful in 51s
CI / security (pull_request) Successful in 1m1s
CI / build (pull_request) Successful in 17s
CI / helm (pull_request) Successful in 53s
CI / unit_tests (pull_request) Failing after 2m4s
CI / docker (pull_request) Has been skipped
CI / e2e_tests (pull_request) Successful in 17m4s
CI / integration_tests (pull_request) Successful in 23m32s
CI / coverage (pull_request) Failing after 2m7s
CI / status-check (pull_request) Failing after 2s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Successful in 56m42s
CI / lint (pull_request) Successful in 21s
CI / quality (pull_request) Successful in 33s
CI / typecheck (pull_request) Successful in 51s
CI / security (pull_request) Successful in 1m1s
CI / build (pull_request) Successful in 17s
CI / helm (pull_request) Successful in 53s
CI / unit_tests (pull_request) Failing after 2m4s
CI / docker (pull_request) Has been skipped
CI / e2e_tests (pull_request) Successful in 17m4s
CI / integration_tests (pull_request) Successful in 23m32s
CI / coverage (pull_request) Failing after 2m7s
CI / status-check (pull_request) Failing after 2s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Successful in 56m42s
The tool_type parameter in ToolRegistry.list_tools() was explicitly silenced with '_ = tool_type', making it a no-op. Both 'agents tool list --type validation' and 'agents tool list --type tool' returned the full unfiltered tool list. Changes: - src/cleveragents/tool/runtime.py: Add tool_type: Literal['tool', 'validation'] field to ToolSpec (default 'tool') so the registry has a discriminator to filter on. - src/cleveragents/tool/registry.py: Remove '_ = tool_type' no-op and implement actual filter: specs = [s for s in specs if s.tool_type == tool_type]. Update docstring to reflect the parameter is now active. - features/consolidated_tool.feature: Add 7 comprehensive Behave scenarios covering all filter combinations (tool, validation, None, default type, exclusion). - features/steps/tool_runtime_steps.py: Add step definition for registering a ToolSpec with an explicit tool_type. - robot/helper_tool_cli.py: Add tool_list_type_tool() and tool_list_type_validation() helper functions that verify the CLI passes tool_type through to the service layer. - robot/tool_cli.robot: Add two Robot test cases for 'tool list --type tool' and 'tool list --type validation'. The CLI handler (cli/commands/tool.py) and database repository (infrastructure/database/repositories.py) already passed tool_type through correctly — no changes needed there. ISSUES CLOSED: #2974
This commit is contained in:
@@ -193,9 +193,43 @@ def validation_detach() -> None:
|
||||
print("validation-cli-detach-ok")
|
||||
|
||||
|
||||
def tool_list_type_tool() -> None:
|
||||
"""Verify tool list --type tool returns only tools."""
|
||||
svc = MagicMock()
|
||||
svc.list_tools.return_value = [_mock_tool("local/smoke-tool", "tool")]
|
||||
with patch(
|
||||
"cleveragents.cli.commands.tool._get_tool_registry_service",
|
||||
return_value=svc,
|
||||
):
|
||||
result = runner.invoke(tool_app, ["list", "--type", "tool"])
|
||||
assert result.exit_code == 0, f"exit={result.exit_code}: {result.output}"
|
||||
svc.list_tools.assert_called_once_with(
|
||||
namespace=None, tool_type="tool", source=None
|
||||
)
|
||||
print("tool-cli-list-type-tool-ok")
|
||||
|
||||
|
||||
def tool_list_type_validation() -> None:
|
||||
"""Verify tool list --type validation returns only validations."""
|
||||
svc = MagicMock()
|
||||
svc.list_tools.return_value = [_mock_tool("local/smoke-val", "validation")]
|
||||
with patch(
|
||||
"cleveragents.cli.commands.tool._get_tool_registry_service",
|
||||
return_value=svc,
|
||||
):
|
||||
result = runner.invoke(tool_app, ["list", "--type", "validation"])
|
||||
assert result.exit_code == 0, f"exit={result.exit_code}: {result.output}"
|
||||
svc.list_tools.assert_called_once_with(
|
||||
namespace=None, tool_type="validation", source=None
|
||||
)
|
||||
print("tool-cli-list-type-validation-ok")
|
||||
|
||||
|
||||
_COMMANDS = {
|
||||
"tool-add-config": tool_add_config,
|
||||
"tool-list": tool_list_all,
|
||||
"tool-list-type-tool": tool_list_type_tool,
|
||||
"tool-list-type-validation": tool_list_type_validation,
|
||||
"tool-show": tool_show_name,
|
||||
"tool-remove": tool_remove_name,
|
||||
"validation-add-config": validation_add_config,
|
||||
|
||||
Reference in New Issue
Block a user