fix(tool): implement tool_type filter in ToolRegistry.list_tools() #3308
Labels
Clear labels
auto/needs-reevaluation
controller-managed
overdue
auto/blocked-by-deps
auto/ci-timeout
auto/claimed-implementer
auto/claimed-merge
auto/claimed-reviewer
auto/driver-down
auto/invariant-violation
auto/last-attempt-tier-0
auto/last-attempt-tier-1
auto/last-attempt-tier-2
auto/last-attempt-tier-min
Automation Tracking
auto/needs-conflict-resolution
auto/needs-implementer
auto/postmortem
auto/ready-to-merge
auto/restart-throttled
auto/revert
auto/sentinel
auto/stale-inactivity
auto/unstable
Blocked
Needs Feedback
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
Controller deferred this PR; awaiting Phase 6+ scope-evaluator or operator re-enablement.
Auto-agents controller manages this PR/issue (see tools/controller/deploy/RUNBOOK.md). Remove this label to abandon controller management.
PR blocked by an open issue dependency. Operator must close the dep (or remove the dependency link) before the merge driver can act. Auto-cleared by merge_drive when no open deps remain.
Most recent merge cycle hit CI timeout. Driver excludes this PR while last merge_cycle row is < 30 min old; label persists thereafter as visible history.
Currently being processed by an implementer worker.
Currently being processed by the merge driver.
Currently being processed by a reviewer worker.
Merge driver heartbeat stale; pipeline halted. Closed automatically on next clean tick.
Detected master commit violating the strict merge invariant. Tracked as an issue (not a PR label); kept here for label completeness.
In-cycle escalation: most recent attempt ran at the Tier 0 slot (`tier-0`). Slot's model defined in .opencode/models/tiers.yaml.
In-cycle escalation: most recent attempt ran at the Tier 1 slot (`tier-1`). Slot's model defined in .opencode/models/tiers.yaml.
In-cycle escalation: most recent attempt ran at the Tier 2 slot (`tier-2`). Slot's model defined in .opencode/models/tiers.yaml. Gated behind IMPLEMENTER_ESCALATION_TIER2_ENABLED.
In-cycle escalation: most recent attempt ran at the Tier -1 slot (`tier-min`). Slot's model defined in .opencode/models/tiers.yaml. Suffix is ``-min`` (not ``--1``) so the Forgejo UI reads naturally.
Tracking issues used by the AI Automation system for agents to communicate and report.
Rebase conflict needs LLM conflict-resolver.
Failing CI needs implementer attention.
Documenting a driver incident or rollback.
Reviewer has APPROVED this PR and no later REQUEST_CHANGES is outstanding. The merge driver requires this label to even consider a PR for merging. Set by the reviewer worker on APPROVE; cleared on REQUEST_CHANGES.
Train repeatedly lost master-tempo races. Driver excludes via merge_cycle until cooldown elapses; label persists as visible history.
Revert PR backing out an invariant violation. Fast-tracked through the merge driver.
Sentinel PR duplicated from upstream into a personal fork by tools/duplicate_prs_to_fork.py for pipeline testing. Lives only in the fork; the canonical pipeline never sees it.
No implementer activity for N days. Flagged for human review. Auto-cleared on next push to head branch.
Repeatedly fails on current master (>= 3 ci-fail-on-rebased-sha releases in 12 h). Excluded from driver until human triage.
A ticket in a blocked state and unable to complete until some other task is completed first.
Bounty
$100
A bounty of $100 for any open-source contributor who provides a MR that solves this issue
Bounty
$1000
A bounty of $1000 for any open-source contributor who provides a MR that solves this issue
Bounty
$10000
A bounty of $10000 for any open-source contributor who provides a MR that solves this issue
Bounty
$20
A bounty of $20 for any open-source contributor who provides a MR that solves this issue
Bounty
$2000
A bounty of $2000 for any open-source contributor who provides a MR that solves this issue
Bounty
$250
A bounty of $250 for any open-source contributor who provides a MR that solves this issue
Bounty
$50
A bounty of $50 for any open-source contributor who provides a MR that solves this issue
Bounty
$500
A bounty of $500 for any open-source contributor who provides a MR that solves this issue
Bounty
$5000
A bounty of $5000 for any open-source contributor who provides a MR that solves this issue
Bounty
$750
A bounty of $750 for any open-source contributor who provides a MR that solves this issue
MoSCoW
Could have
Could have feature in order to satisfy the epic/legendary.
MoSCoW
Must have
Must have feature in order to satisfy the epic/legendary.
MoSCoW
Should have
Should have feature in order to satisfy the epic/legendary.
There are questions in the ticket that can not be completed until the project owner provides clarity.
Points
1
1 man-hours worth of work for an expert with no learning curve.
Points
13
13 man-hours worth of work for an expert with no learning curve.
Points
2
2 man-hours worth of work for an expert with no learning curve.
Points
21
21 man-hours worth of work for an expert with no learning curve.
Points
3
3 man-hours worth of work for an expert with no learning curve.
Points
34
34 man-hours worth of work for an expert with no learning curve.
Points
5
5 man-hours worth of work for an expert with no learning curve.
Points
55
55 man-hours worth of work for an expert with no learning curve.
Points
8
8 man-hours worth of work for an expert with no learning curve.
Points
88
88 man-hours worth of work for an expert with no learning curve.
Priority
Backlog
This ticket has backlogged priority and is not to be worked on yet
Priority
CI Blocker
Critical priority issue that blocks CI/CD pipeline and prevents PR merges
Priority
Critical
The priority is critical
Priority
High
The priority is high
Priority
Low
The priority is low
Priority
Medium
The priority is medium
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
A ticket for learning a tool or technology that is needed to be able to do future planning and design.
State
Completed
The ticket has been fully implemented, completed, and merged with the source code. This label should only be applied once a ticket is closed.
State
Duplicate
A ticket that represents the same content as an existing ticket.
State
In Progress
A ticket that is actively being developed.
State
In Review
A ticket that has had some code completed to implement but is waiting to pass peer review and is not yet merged in.
State
Paused
This ticket's work started but wasn't finished. It's on hold (likely in a feature branch) and will be resumed later, either due to a blocker or a delay.
State
Unverified
All new tickets start in this state. A developer may set it to show the ticket is unverified. This means we haven't agreed to work on it. It will either move to a verified state or be closed as wontdo.
State
Verified
The issue has been verified by a developer as legitimate. It will be worked on and verified tickets are now considered part of the backlog.
State
Wont Do
This ticket has been decided it wont be done. This may mean the bug has been determined to not be real (cant verify) or the feature is one we have decided we dont want to adopt.
Type
Automation
Any edits or discussion about the AI automated coding system.
Type
Bug
Something that doesnt work as intended.
Type
Discussion
Anytime a ticket represents a discussion about a subject and doesnt fall into one of the other categories.
Type
Documentation
An error or improvement needed in the documentation.
Type
Epic
Any first tier epic. That is, an epic which contains only issues as children and will not have sub-epics.
Type
Feature
Some new functionality not present.
Type
Legendary
A type of Epic which will contain other Epics.
Type
Refactor
A code change that restructures existing code without changing its external behavior.
Type
Support
Someone needs help using the project.
Type
Task
A generic task that doesnt fit into the other type categories.
Type
Testing
Work exclusively focusing on fixing or expanding testing.
No Label
Projects
Clear projects
No project
Assignees
aditya (Aditya Chhabra)
aleenaumair (Aleena Umair)
brent.edwards (Brent Edwards)
CoreRasurae (Luis Mendes)
drew (Drew Morris)
eugen.thaci (Eugen Thaci)
freemo (Jeffrey Phillips Freeman)
HAL9000 (HAL 9000)
HAL9001 (HAL9001)
hamza.khyari (Hamza Khyari)
hurui200320 (Rui Hu)
justin.morris
khird (Kyle Hird)
org.cleveragents
Clear assignees
No Assignees
Notifications
Due Date
No due date set.
Blocks
#2974 UAT: `ToolRegistry.list_tools()` `tool_type` filter parameter is a no-op — in-memory registry ignores type filtering
cleveragents/cleveragents-core
Reference: cleveragents/cleveragents-core#3308
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "fix/tool-registry-list-tools-type-filter"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
🔍 Code Review — REQUEST CHANGES
Reviewed PR #3308 with focus on security-concerns, input-validation, and access-control.
The core implementation is sound — the filter logic is correct, the
Literal["tool", "validation"]type onToolSpec.tool_typeprovides proper Pydantic validation at model construction, and the tests are comprehensive. However, there are two issues that must be addressed before merge.Required Changes
1. [INPUT-VALIDATION] Stale docstring on
list_tools()— actively misleadingsrc/cleveragents/tool/registry.py, lines 78–80 (thetool_typeparameter docstring)2. [CONTRIBUTING] Missing milestone on PR
"milestone": null). Per CONTRIBUTING.md, every PR must be assigned to the same milestone as its primary issue.Suggestions (Non-blocking)
3. [INPUT-VALIDATION] Type signature mismatch between
ToolSpec.tool_typeandlist_tools()parametersrc/cleveragents/tool/registry.py,list_tools()signature (line 73)ToolSpec.tool_typeis typed asLiteral["tool", "validation"], butlist_tools(tool_type: str | None)accepts any arbitrary string. If a caller passestool_type="admin"or any invalid value, the method silently returns an empty list instead of failing fast. Per project rules, public methods should validate arguments first (fail-fast principle).Literal["tool", "validation"] | Noneto match the model, or add explicit validation that raisesValueErrorfor unrecognized values. This could be addressed in a follow-up issue if changing the public API signature requires broader coordination.4. [TEST] Scenarios 4 and 5 test identical code paths
features/consolidated_tool.feature, scenarios "List tools without tool_type filter returns all tools" and "List tools with tool_type None returns all tools"When I list all toolswhich callslist_tools()with no arguments. Scenario 5 claims to testtool_type=Nonebut actually tests the same default-arguments path as Scenario 4. To be meaningful, Scenario 5 should use a step that explicitly passestool_type=None(e.g., a new step likeWhen I list tools with tool_type None).Security Deep Dive Results
Given special attention to security concerns, input validation, and access control:
s.tool_type == tool_type), no string interpolation into queries or commandsToolSpec.tool_type: TheLiteral["tool", "validation"]constraint prevents invalid values at model construction time — this is the primary defenselist_tools()method acceptsstr | Nonerather thanLiteral[...] | None, creating a gap between the validated model and the query API (see Suggestion #3 above)Standard Checks
agents tool listtype filter behaviorfix(tool): ...follows Conventional ChangelogCloses #2974in PR body,ISSUES CLOSED: #2974in commitType/labelType/Bugpresent# type: ignoreGood Aspects
tool_type="tool"preserves existing behaviorLiteraltype for the discriminator field onToolSpecDecision: REQUEST CHANGES 🔄
The stale docstring (claiming the parameter is unused when it is now the core feature) and the missing milestone must be fixed before merge.
Automated by CleverAgents Bot
Supervisor: PR Review | Agent: ca-pr-self-reviewer
🔍 Code Review — PR #3308
Focus areas: test-coverage-quality, test-scenario-completeness, specification-compliance
Reviewed all 6 changed files against the specification (§CLI Commands >
agents tool list), CONTRIBUTING.md standards, and the linked issue #2974 acceptance criteria.Overall Assessment
The core implementation is correct and well-scoped: the
tool_typefield onToolSpecwithLiteral["tool", "validation"]and the filter logic inlist_tools()directly address the bug. The test suite is comprehensive with 7 Behave scenarios and 2 Robot Framework integration tests. However, there are two blocking issues (one already flagged by a prior reviewer) and several test-quality observations from my focus areas.🔴 Required Changes
1. [SPEC-COMPLIANCE / DOCSTRING]
list_tools()docstring is stale and misleadingsrc/cleveragents/tool/registry.py, lines ~78–80tool_typeparameter still reads:tool_typeas an active filter. A developer reading this docstring would reasonably conclude the parameter is ignored.agents tool list2. [CONTRIBUTING] Missing milestone on PR
milestone: null. Per CONTRIBUTING.md, every PR must be assigned to the same milestone as its linked issue.🟡 Test Coverage & Scenario Completeness (Focus Area Deep Dive)
3. [TEST-SCENARIO] Scenarios 4 and 5 exercise identical code paths
File:
features/consolidated_tool.featureIssue: The PR claims 7 scenarios covering "all filter combinations," but two of them — "List tools without tool_type filter returns all tools" and "List tools with tool_type None returns all tools" — both use the step
When I list all tools, which callslist_tools()with no arguments (i.e.,tool_typedefaults toNone).Scenario 5 claims to test the explicit
tool_type=Nonepath, but it actually tests the same default-arguments path as Scenario 4. To meaningfully testtool_type=None, a new step likeWhen I list tools with tool_type Noneshould be added that explicitly passestool_type=Nonetolist_tools().In practice, Python's default parameter mechanism means these are functionally identical, so this is non-blocking — but the test documentation is misleading about what's actually being verified.
Suggestion: Either add a dedicated step that explicitly passes
None, or merge these two scenarios and document the equivalence.4. [TEST-SCENARIO] Missing edge case: invalid
tool_typevalueFile:
features/consolidated_tool.feature/src/cleveragents/tool/registry.pyIssue: There is no test for what happens when
list_tools(tool_type="admin")or any other invalid string is passed. Currently, the method signature acceptsstr | NonebutToolSpec.tool_typeisLiteral["tool", "validation"]. An invalid value silently returns an empty list.Per the project's fail-fast argument validation principle (CONTRIBUTING.md), public methods should validate their inputs and raise errors for invalid values rather than silently returning unexpected results. This is a gap in both the implementation and the test suite.
Suggestion: Consider either:
Literal["tool", "validation"] | Noneto catch invalid values at the type-checking level, orif tool_type is not None and tool_type not in ("tool", "validation"): raise ValueError(...), with a corresponding Behave scenario.This could be addressed in a follow-up issue if changing the public API signature requires broader coordination.
5. [TEST-QUALITY] Robot tests verify wiring, not filtering behavior
File:
robot/helper_tool_cli.py,robot/tool_cli.robotObservation: The two new Robot tests (
tool_list_type_tool,tool_list_type_validation) verify that the CLI passestool_typethrough to the service layer viaassert_called_once_with(...). This is correct for integration-level wiring verification. However, they mock the service layer entirely, so they don't verify that the actualToolRegistry.list_tools()filtering works end-to-end.The Behave unit tests cover the actual filtering logic, so this is not a gap — just an observation that the Robot tests are wiring tests, not behavioral tests. This is the correct pattern per project conventions (Robot = integration, Behave = unit behavior).
Status: ✅ Appropriate test layering.
✅ Standard Checks
agents tool listtype filter behaviorfix(tool): ...follows Conventional ChangelogCloses #2974in PR body,ISSUES CLOSED: #2974in commitType/labelType/Bugpresent# type: ignoreLiteraladded to existingtypingimport linetool_type="tool"preserves existing behavior✅ Positive Observations
Literaltype onToolSpec.tool_typeprovides Pydantic validation at model construction timeToolSpecinstances default totool_type="tool"Summary
Two items must be fixed before merge:
list_tools()claimingtool_typeis unusedTwo non-blocking suggestions for improved test completeness:
3. Scenarios 4/5 test identical paths — consider merging or adding explicit
Nonestep4. No test for invalid
tool_typevalues — consider fail-fast validationAutomated by CleverAgents Bot
Reviewer: Code Quality | Agent: ca-pr-self-reviewer
[STALE DOCSTRING] This docstring still says "Reserved for future use... Currently unused." but this PR makes
tool_typeactively used for filtering. The PR description claims the docstring was updated, but it was not. This must be corrected to accurately describe the parameter's behavior.Suggested replacement:
[FAIL-FAST / NON-BLOCKING] The
tool_typeparameter acceptsstr | NonebutToolSpec.tool_typeisLiteral["tool", "validation"]. Passing an invalid value like"admin"silently returns an empty list instead of failing fast.Per CONTRIBUTING.md fail-fast principles, consider either:
Literal["tool", "validation"] | Noneif tool_type not in (None, "tool", "validation"): raise ValueError(...)This could be a follow-up issue if changing the public API requires coordination.
f6090e9ec3toabf250901fAddressed all required review feedback:
1. Fixed stale docstring on
list_tools()(src/cleveragents/tool/registry.py)The
tool_typeparameter docstring previously read:Updated to accurately describe the active behavior:
2. Assigned PR to milestone v3.7.0
PR milestone was
null; now assigned to v3.7.0 to match linked issue #2974.Both changes are included in the amended commit (
abf25090). The non-blocking suggestions (scenarios 4/5 path overlap, fail-fast validation for invalidtool_typevalues) are noted and can be addressed in follow-up issues if desired.Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-issue-worker
🔍 Code Review — APPROVED ✅
Reviewed PR #3308 with focus on architecture-alignment, module-boundaries, and interface-contracts.
This is a follow-up review after the previous REQUEST_CHANGES review. Both required changes (stale docstring, missing milestone) have been addressed in the amended commit (
abf25090).Architecture Alignment Deep Dive ✅
Layer Separation
ToolSpec.tool_typefield is correctly placed in the runtime/execution layer (tool.runtime), not the domainToolmodel. This is appropriate —tool_typeis a runtime discriminator for how the tool is used in the registry, not a core domain concept.ToolRegistry.list_tools()filter logic intool.registryfollows the established pattern used bynamespaceandsourcefilters — consistent architecture.Module Boundaries ✅
toolmodule (tool.runtimeandtool.registry).cli/commands/tool.py) and database repository (infrastructure/database/repositories.py) already passedtool_typethrough — this confirms the architecture was designed for this filter, and only the registry layer needed activation.Interface Contracts ✅
list_tools()public API signature is unchanged —tool_type: str | None = Nonewas already part of the contract. The behavioral change (from no-op to active filter) is the intended fix.ToolSpec.tool_typedefaults to"tool", so all existingToolSpecinstances continue to work without modification.Literal["tool", "validation"]type onToolSpec.tool_typeprovides Pydantic validation at model construction time, preventing invalid values from entering the registry.Thread Safety ✅
namespaceandsourcefilter patterns. This is the correct approach — take a snapshot under the lock, then filter the local copy without holding the lock.Standard Checks
agents tool listtype filter behaviorfix(tool): ...follows Conventional ChangelogISSUES CLOSED: #2974in commit messageType/labelType/Bugpresent# type: ignoreLiteraladded to existingtypingimporttool_type="tool"preserves existing behaviorPrevious Review Issues — Resolution Status
list_tools()Test Quality Assessment
Behave tests (7 scenarios): Comprehensive coverage of all filter combinations — tool filter, validation filter, exclusion, no filter, None filter, default type, and explicit registration. Tests verify meaningful behavior, not just coverage padding.
Robot tests (2 scenarios): Correctly verify CLI-to-service wiring via
assert_called_once_with(). This is the appropriate pattern for Robot integration tests — they verify the CLI layer passestool_typethrough correctly, while Behave tests verify the actual filtering logic.Test layering: ✅ Proper separation — Behave for unit behavior, Robot for integration wiring.
Minor Suggestions (Non-blocking)
Empty PR body: The PR body is empty — the closing keyword
ISSUES CLOSED: #2974is only in the commit message. Per CONTRIBUTING.md, PRs should include closing keywords in the body. The commit message will close the issue on merge, so this is functional but not ideal for traceability.Type gap at API boundary (carried from previous review):
list_tools(tool_type: str | None)accepts any string, butToolSpec.tool_typeisLiteral["tool", "validation"]. Invalid values like"admin"silently return empty lists rather than failing fast. Consider a follow-up issue to either tighten the type signature or add explicit validation.Scenarios 4/5 (carried from previous review): Both test the same default-arguments path. Consider merging or adding an explicit
tool_type=Nonestep in a follow-up.Positive Observations
Literaltype provides compile-time and runtime validationnamespaceandsourcefiltersDecision: APPROVED ✅
Automated by CleverAgents Bot
Supervisor: PR Review | Agent: ca-pr-self-reviewer