UAT: ToolRegistry.list_tools() tool_type filter parameter is a no-op — in-memory registry ignores type filtering #2974

Closed
opened 2026-04-05 03:00:22 +00:00 by freemo · 3 comments
Owner

Metadata

  • Branch: fix/tool-registry-list-tools-type-filter
  • Commit Message: fix(tool): implement tool_type filter in ToolRegistry.list_tools()
  • Milestone: v3.7.0
  • Parent Epic: #393

Background and context

The ToolRegistry.list_tools() method in src/cleveragents/tool/registry.py exposes a tool_type parameter as part of its public API but explicitly ignores it with _ = tool_type. The specification (§CLI Commands > agents tool list) requires that --type validation returns only validations and --type tool returns only plain tools. Because the parameter is silently discarded, both filter values return the full unfiltered tool list, making type-based filtering impossible via the in-memory registry.

Current behavior

In src/cleveragents/tool/registry.py, the list_tools() method explicitly ignores the tool_type parameter:

def list_tools(
    self,
    namespace: str | None = None,
    tool_type: str | None = None,
    source: str | None = None,
) -> list[ToolSpec]:
    """List registered tools with optional filters.

    Parameters
    ----------
    ...
    tool_type:
        Reserved for future use (e.g. filtering by ``tool`` vs
        ``validation``).  Currently unused.
    ...
    """
    ...
    # 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

    return specs

The comment says "Reserved for future use" and "Currently unused." This means:

  • agents tool list --type validation returns all tools (both tools and validations) instead of only validations.
  • agents tool list --type tool also returns all tools instead of only plain tools.

Steps to Reproduce

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

registry = ToolRegistry()
# Register a plain tool
registry.register(ToolSpec(name="local/my-tool", description="A tool", ...))
# Register a validation (tool_type="validation")
registry.register(ToolSpec(name="local/my-validation", description="A validation", ...))

# This should return only validations but returns ALL tools:
results = registry.list_tools(tool_type="validation")
assert len(results) == 1  # FAILS — returns 2

Code location: src/cleveragents/tool/registry.py, list_tools() method — tool_type parameter is explicitly ignored with _ = tool_type.

Expected behavior

Per the specification (§CLI Commands > agents tool list):

Purpose: List registered tools with optional filters. Because Validations are a subtype of Tool and share the same registry, this command lists both plain tools and validations. 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.

ToolRegistry.list_tools(tool_type="validation") must return only ToolSpec entries whose type is "validation", and list_tools(tool_type="tool") must return only plain tool entries. When tool_type=None, all entries are returned.

Acceptance criteria

  • ToolRegistry.list_tools(tool_type="validation") returns only validation-typed ToolSpec entries.
  • ToolRegistry.list_tools(tool_type="tool") returns only plain tool ToolSpec entries.
  • ToolRegistry.list_tools() (no filter) continues to return all registered entries.
  • ToolRegistry.list_tools(tool_type=None) is equivalent to no filter.
  • ToolSpec carries a tool_type field (or equivalent discriminator) that the registry can filter on; if ToolSpec does not yet have this field, it is added as part of this fix.
  • agents tool list --type validation CLI command returns only validations.
  • agents tool list --type tool CLI command returns only plain tools.
  • All existing list_tools() call sites remain compatible (no breaking changes).

Supporting information

  • Spec reference: §CLI Commands > agents tool list — type filter behaviour
  • Code location: src/cleveragents/tool/registry.pylist_tools() method, _ = tool_type line
  • Related: Validations are a subtype of Tool (§Tools & Skills > Validation) and share the same registry; the tool_type field is the discriminator between them.
  • Severity: Medium — agents tool list --type tool and agents tool list --type validation do not filter correctly, returning all entries regardless of type.

Subtasks

  • Confirm whether ToolSpec already has a tool_type / type-discriminator field; if not, add one (e.g., tool_type: Literal["tool", "validation"] = "tool")
  • Remove the _ = tool_type no-op in ToolRegistry.list_tools() and implement the filter logic
  • Ensure ToolRegistry.register() correctly stores the tool_type on each ToolSpec
  • Update agents tool list CLI handler to pass --type value through to list_tools(tool_type=...)
  • Tests (pytest/Behave): add unit tests for list_tools(tool_type="tool"), list_tools(tool_type="validation"), and list_tools() (no filter)
  • Tests (Robot): add or update integration scenario for agents tool list --type validation and agents tool list --type tool
  • 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.
  • ToolRegistry.list_tools(tool_type=...) correctly filters by type for all valid values ("tool", "validation", None).
  • 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/tool-registry-list-tools-type-filter` - **Commit Message**: `fix(tool): implement tool_type filter in ToolRegistry.list_tools()` - **Milestone**: v3.7.0 - **Parent Epic**: #393 ## Background and context The `ToolRegistry.list_tools()` method in `src/cleveragents/tool/registry.py` exposes a `tool_type` parameter as part of its public API but explicitly ignores it with `_ = tool_type`. The specification (§CLI Commands > agents tool list) requires that `--type validation` returns only validations and `--type tool` returns only plain tools. Because the parameter is silently discarded, both filter values return the full unfiltered tool list, making type-based filtering impossible via the in-memory registry. ## Current behavior In `src/cleveragents/tool/registry.py`, the `list_tools()` method explicitly ignores the `tool_type` parameter: ```python def list_tools( self, namespace: str | None = None, tool_type: str | None = None, source: str | None = None, ) -> list[ToolSpec]: """List registered tools with optional filters. Parameters ---------- ... tool_type: Reserved for future use (e.g. filtering by ``tool`` vs ``validation``). Currently unused. ... """ ... # 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 return specs ``` The comment says "Reserved for future use" and "Currently unused." This means: - `agents tool list --type validation` returns **all** tools (both tools and validations) instead of only validations. - `agents tool list --type tool` also returns **all** tools instead of only plain tools. ### Steps to Reproduce ```python from cleveragents.tool.registry import ToolRegistry from cleveragents.tool.runtime import ToolSpec, ToolCapability registry = ToolRegistry() # Register a plain tool registry.register(ToolSpec(name="local/my-tool", description="A tool", ...)) # Register a validation (tool_type="validation") registry.register(ToolSpec(name="local/my-validation", description="A validation", ...)) # This should return only validations but returns ALL tools: results = registry.list_tools(tool_type="validation") assert len(results) == 1 # FAILS — returns 2 ``` **Code location**: `src/cleveragents/tool/registry.py`, `list_tools()` method — `tool_type` parameter is explicitly ignored with `_ = tool_type`. ## Expected behavior Per the specification (§CLI Commands > agents tool list): > **Purpose**: List registered tools with optional filters. Because Validations are a subtype of Tool and share the same registry, this command lists both plain tools and validations. 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. `ToolRegistry.list_tools(tool_type="validation")` must return only `ToolSpec` entries whose type is `"validation"`, and `list_tools(tool_type="tool")` must return only plain tool entries. When `tool_type=None`, all entries are returned. ## Acceptance criteria - [ ] `ToolRegistry.list_tools(tool_type="validation")` returns only validation-typed `ToolSpec` entries. - [ ] `ToolRegistry.list_tools(tool_type="tool")` returns only plain tool `ToolSpec` entries. - [ ] `ToolRegistry.list_tools()` (no filter) continues to return all registered entries. - [ ] `ToolRegistry.list_tools(tool_type=None)` is equivalent to no filter. - [ ] `ToolSpec` carries a `tool_type` field (or equivalent discriminator) that the registry can filter on; if `ToolSpec` does not yet have this field, it is added as part of this fix. - [ ] `agents tool list --type validation` CLI command returns only validations. - [ ] `agents tool list --type tool` CLI command returns only plain tools. - [ ] All existing `list_tools()` call sites remain compatible (no breaking changes). ## Supporting information - **Spec reference**: §CLI Commands > `agents tool list` — type filter behaviour - **Code location**: `src/cleveragents/tool/registry.py` — `list_tools()` method, `_ = tool_type` line - **Related**: Validations are a subtype of Tool (§Tools & Skills > Validation) and share the same registry; the `tool_type` field is the discriminator between them. - **Severity**: Medium — `agents tool list --type tool` and `agents tool list --type validation` do not filter correctly, returning all entries regardless of type. ## Subtasks - [ ] Confirm whether `ToolSpec` already has a `tool_type` / type-discriminator field; if not, add one (e.g., `tool_type: Literal["tool", "validation"] = "tool"`) - [ ] Remove the `_ = tool_type` no-op in `ToolRegistry.list_tools()` and implement the filter logic - [ ] Ensure `ToolRegistry.register()` correctly stores the `tool_type` on each `ToolSpec` - [ ] Update `agents tool list` CLI handler to pass `--type` value through to `list_tools(tool_type=...)` - [ ] Tests (pytest/Behave): add unit tests for `list_tools(tool_type="tool")`, `list_tools(tool_type="validation")`, and `list_tools()` (no filter) - [ ] Tests (Robot): add or update integration scenario for `agents tool list --type validation` and `agents tool list --type tool` - [ ] 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. - `ToolRegistry.list_tools(tool_type=...)` correctly filters by type for all valid values (`"tool"`, `"validation"`, `None`). - 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-05 03:00:54 +00:00
Author
Owner

Starting implementation on branch fix/tool-registry-list-tools-type-filter.

Analysis complete:

  • ToolSpec in src/cleveragents/tool/runtime.py was missing a tool_type field — adding tool_type: Literal["tool", "validation"] = Field(default="tool", ...)
  • ToolRegistry.list_tools() in src/cleveragents/tool/registry.py had _ = tool_type (explicit no-op) — replacing with actual filter logic
  • CLI handler in src/cleveragents/cli/commands/tool.py already passes tool_type through to the service correctly — no changes needed there
  • Database repository ToolRegistryRepository.list_all() already implements tool_type filtering correctly — no changes needed

Implementation plan:

  1. Add tool_type: Literal["tool", "validation"] field to ToolSpec (default "tool")
  2. Remove _ = tool_type no-op and implement filter in ToolRegistry.list_tools()
  3. Add comprehensive Behave scenarios for all filter combinations
  4. Add Robot Framework CLI tests for --type tool and --type validation

Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-issue-worker

Starting implementation on branch `fix/tool-registry-list-tools-type-filter`. **Analysis complete:** - `ToolSpec` in `src/cleveragents/tool/runtime.py` was missing a `tool_type` field — adding `tool_type: Literal["tool", "validation"] = Field(default="tool", ...)` - `ToolRegistry.list_tools()` in `src/cleveragents/tool/registry.py` had `_ = tool_type` (explicit no-op) — replacing with actual filter logic - CLI handler in `src/cleveragents/cli/commands/tool.py` already passes `tool_type` through to the service correctly — no changes needed there - Database repository `ToolRegistryRepository.list_all()` already implements `tool_type` filtering correctly — no changes needed **Implementation plan:** 1. Add `tool_type: Literal["tool", "validation"]` field to `ToolSpec` (default `"tool"`) 2. Remove `_ = tool_type` no-op and implement filter in `ToolRegistry.list_tools()` 3. Add comprehensive Behave scenarios for all filter combinations 4. Add Robot Framework CLI tests for `--type tool` and `--type validation` --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: ca-issue-worker
Author
Owner

All subtasks complete. Quality gates passed. PR #3308 created on branch fix/tool-registry-list-tools-type-filter.

Implementation summary:

  • Added tool_type: Literal["tool", "validation"] field to ToolSpec (default "tool")
  • Removed _ = tool_type no-op in ToolRegistry.list_tools() and implemented actual filter
  • Added 7 Behave scenarios + 2 Robot Framework CLI tests
  • nox -s lint, nox -s format, nox -s typecheck all pass

PR review and merge handled by continuous review stream.


Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-issue-worker

All subtasks complete. Quality gates passed. PR #3308 created on branch `fix/tool-registry-list-tools-type-filter`. **Implementation summary:** - Added `tool_type: Literal["tool", "validation"]` field to `ToolSpec` (default `"tool"`) - Removed `_ = tool_type` no-op in `ToolRegistry.list_tools()` and implemented actual filter - Added 7 Behave scenarios + 2 Robot Framework CLI tests - `nox -s lint`, `nox -s format`, `nox -s typecheck` all pass ✅ PR review and merge handled by continuous review stream. --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: ca-issue-worker
Owner

State label reconciliation:

  • Previous state: State/In Review
  • Corrected to: State/Completed
  • Reason: Issue is closed but had a non-terminal state label. CONTRIBUTING.md requires closed issues to have State/Completed or State/Wont Do.

Automated by CleverAgents Bot
Supervisor: Backlog Grooming | Agent: backlog-groomer

State label reconciliation: - Previous state: `State/In Review` - Corrected to: `State/Completed` - Reason: Issue is closed but had a non-terminal state label. CONTRIBUTING.md requires closed issues to have `State/Completed` or `State/Wont Do`. --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: backlog-groomer
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Blocks
#393 Epic: Skill & Tool Lifecycle
cleveragents/cleveragents-core
Depends on
Reference
cleveragents/cleveragents-core#2974
No description provided.