UAT: ToolRegistry.list_tools(tool_type=...) filter is a no-op — cannot distinguish plain tools from validations in-memory #1900

Open
opened 2026-04-03 00:10:06 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/uat-tool-registry-list-tools-type-filter-noop
  • Commit Message: fix(tools): add tool_type discriminator to ToolSpec and implement list_tools() filtering in ToolRegistry
  • Milestone: v3.7.0
  • Parent Epic: #374

Background and Context

Per docs/specification.md, the Tool Registry must support type-based filtering:

"Use --type validation to show only validations, or --type tool to show only plain tools. When --type is omitted, both are listed with a Type column distinguishing them."
"Each entry is tagged as either tool or validation."

The ToolRegistry.list_tools(tool_type=...) parameter is part of the public API and is expected to filter the returned list to only entries of the specified type. The database-backed repository (src/cleveragents/infrastructure/database/repositories.py) correctly filters by tool_type at the SQL level, but the in-memory ToolRegistry cannot because ToolSpec — the data class it stores — has no tool_type discriminator field.

Current Behavior

The tool_type parameter in ToolRegistry.list_tools() is explicitly documented as a no-op in the code:

# tool_type filtering is a no-op for now but the parameter is
# part of the public API to avoid a breaking change later.
_ = tool_type

Both tool_type='tool' and tool_type='validation' return all registered entries regardless of type.

Reproduction:

from cleveragents.tool.registry import ToolRegistry
from cleveragents.tool.runtime import ToolSpec

registry = ToolRegistry()
registry.register(ToolSpec(name='local/plain-tool', description='plain', handler=lambda: None))
registry.register(ToolSpec(name='local/my-validation', description='validation', handler=lambda: None))

# Both return 2 tools — filtering is broken
tools_only = registry.list_tools(tool_type='tool')       # Returns 2, expected 1
validations_only = registry.list_tools(tool_type='validation')  # Returns 2, expected 1

Expected Behavior

  • ToolRegistry.list_tools(tool_type='tool') returns only plain tools.
  • ToolRegistry.list_tools(tool_type='validation') returns only validations.
  • ToolRegistry.list_tools() (no filter) returns all entries with a Type column distinguishing them.
  • The agents tool list --type tool and agents tool list --type validation CLI commands work correctly when backed by the in-memory ToolRegistry.

Root Cause

ToolSpec (in src/cleveragents.tool.runtime.ToolSpec) lacks a tool_type discriminator field. The domain model Tool (in src/cleveragents.domain.models.core.tool.Tool) has a tool_type: ToolType field with ToolType.TOOL and ToolType.VALIDATION values, but ToolSpec does not carry this discriminator. Without it, ToolRegistry.list_tools() has no basis on which to filter.

Acceptance Criteria

  • ToolSpec gains a tool_type field (defaulting to ToolType.TOOL for backwards compatibility) that accepts ToolType.TOOL or ToolType.VALIDATION.
  • ToolRegistry.list_tools(tool_type='tool') returns only entries whose ToolSpec.tool_type is ToolType.TOOL.
  • ToolRegistry.list_tools(tool_type='validation') returns only entries whose ToolSpec.tool_type is ToolType.VALIDATION.
  • ToolRegistry.list_tools() with no filter returns all entries (existing behaviour preserved).
  • The no-op comment and _ = tool_type stub are removed from ToolRegistry.list_tools().
  • All existing callers that construct ToolSpec without tool_type continue to work (default value ensures backwards compatibility).
  • BDD scenarios cover: filter by 'tool', filter by 'validation', no filter, and mixed registry.

Subtasks

  • Add tool_type: ToolType field to ToolSpec in src/cleveragents/tool/runtime.py with a default of ToolType.TOOL
  • Implement tool_type filtering logic in ToolRegistry.list_tools() in src/cleveragents/tool/registry.py (remove the no-op stub)
  • Update any ToolSpec construction sites that register validations to pass tool_type=ToolType.VALIDATION
  • Tests (Behave): Add BDD scenarios for list_tools(tool_type='tool'), list_tools(tool_type='validation'), and list_tools() with no filter
  • Tests (Robot): Add integration test verifying agents tool list --type tool and agents tool list --type validation CLI commands return correct subsets
  • Verify coverage >= 97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
  • All nox stages pass.
  • Coverage >= 97%.

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/uat-tool-registry-list-tools-type-filter-noop` - **Commit Message**: `fix(tools): add tool_type discriminator to ToolSpec and implement list_tools() filtering in ToolRegistry` - **Milestone**: v3.7.0 - **Parent Epic**: #374 ## Background and Context Per `docs/specification.md`, the Tool Registry must support type-based filtering: > "Use `--type validation` to show only validations, or `--type tool` to show only plain tools. When `--type` is omitted, both are listed with a `Type` column distinguishing them." > "Each entry is tagged as either `tool` or `validation`." The `ToolRegistry.list_tools(tool_type=...)` parameter is part of the public API and is expected to filter the returned list to only entries of the specified type. The database-backed repository (`src/cleveragents/infrastructure/database/repositories.py`) correctly filters by `tool_type` at the SQL level, but the in-memory `ToolRegistry` cannot because `ToolSpec` — the data class it stores — has no `tool_type` discriminator field. ## Current Behavior The `tool_type` parameter in `ToolRegistry.list_tools()` is explicitly documented as a no-op in the code: ```python # tool_type filtering is a no-op for now but the parameter is # part of the public API to avoid a breaking change later. _ = tool_type ``` Both `tool_type='tool'` and `tool_type='validation'` return all registered entries regardless of type. **Reproduction:** ```python from cleveragents.tool.registry import ToolRegistry from cleveragents.tool.runtime import ToolSpec registry = ToolRegistry() registry.register(ToolSpec(name='local/plain-tool', description='plain', handler=lambda: None)) registry.register(ToolSpec(name='local/my-validation', description='validation', handler=lambda: None)) # Both return 2 tools — filtering is broken tools_only = registry.list_tools(tool_type='tool') # Returns 2, expected 1 validations_only = registry.list_tools(tool_type='validation') # Returns 2, expected 1 ``` ## Expected Behavior - `ToolRegistry.list_tools(tool_type='tool')` returns only plain tools. - `ToolRegistry.list_tools(tool_type='validation')` returns only validations. - `ToolRegistry.list_tools()` (no filter) returns all entries with a `Type` column distinguishing them. - The `agents tool list --type tool` and `agents tool list --type validation` CLI commands work correctly when backed by the in-memory `ToolRegistry`. ## Root Cause `ToolSpec` (in `src/cleveragents.tool.runtime.ToolSpec`) lacks a `tool_type` discriminator field. The domain model `Tool` (in `src/cleveragents.domain.models.core.tool.Tool`) has a `tool_type: ToolType` field with `ToolType.TOOL` and `ToolType.VALIDATION` values, but `ToolSpec` does not carry this discriminator. Without it, `ToolRegistry.list_tools()` has no basis on which to filter. ## Acceptance Criteria - `ToolSpec` gains a `tool_type` field (defaulting to `ToolType.TOOL` for backwards compatibility) that accepts `ToolType.TOOL` or `ToolType.VALIDATION`. - `ToolRegistry.list_tools(tool_type='tool')` returns only entries whose `ToolSpec.tool_type` is `ToolType.TOOL`. - `ToolRegistry.list_tools(tool_type='validation')` returns only entries whose `ToolSpec.tool_type` is `ToolType.VALIDATION`. - `ToolRegistry.list_tools()` with no filter returns all entries (existing behaviour preserved). - The no-op comment and `_ = tool_type` stub are removed from `ToolRegistry.list_tools()`. - All existing callers that construct `ToolSpec` without `tool_type` continue to work (default value ensures backwards compatibility). - BDD scenarios cover: filter by `'tool'`, filter by `'validation'`, no filter, and mixed registry. ## Subtasks - [ ] Add `tool_type: ToolType` field to `ToolSpec` in `src/cleveragents/tool/runtime.py` with a default of `ToolType.TOOL` - [ ] Implement `tool_type` filtering logic in `ToolRegistry.list_tools()` in `src/cleveragents/tool/registry.py` (remove the no-op stub) - [ ] Update any `ToolSpec` construction sites that register validations to pass `tool_type=ToolType.VALIDATION` - [ ] Tests (Behave): Add BDD scenarios for `list_tools(tool_type='tool')`, `list_tools(tool_type='validation')`, and `list_tools()` with no filter - [ ] Tests (Robot): Add integration test verifying `agents tool list --type tool` and `agents tool list --type validation` CLI commands return correct subsets - [ ] Verify coverage >= 97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. - All nox stages pass. - Coverage >= 97%. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
freemo added this to the v3.7.0 milestone 2026-04-03 00:10:37 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: MoSCoW/Should Have — bug or error handling improvement.

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: MoSCoW/Should Have — bug or error handling improvement. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#1900
No description provided.