Skip to content

[BUG] [v0.0.7] cortex agent list --filter inflates hidden count — visible non-matching agents counted as hidden (list.rs:131) #53389

@nightmare0329

Description

@nightmare0329

Project

Repository: CortexLM/cortex
Version: v0.0.7
Component: cortex agent list — hidden count display (src/cortex-cli/src/agent_cmd/handlers/list.rs)

Description

When using cortex agent list --filter <pattern>, the footer message incorrectly reports the number of "hidden" agents. The hidden count is computed as:

// src/cortex-cli/src/agent_cmd/handlers/list.rs:131-135
let hidden_count = if !args.all {
    agents.len() - filtered.len()  // BUG: counts ALL non-displayed agents as "hidden"
} else {
    0
};

agents.len() is the total of ALL agents. filtered.len() is agents after all filters (hidden flag + mode + pattern). So agents.len() - filtered.len() includes both:

  1. Truly hidden agents (have hidden: true)
  2. Visible agents that simply don't match the --filter pattern

The footer then prints this inflated count as "N hidden", misleading users into thinking N agents exist but are hidden, when in reality most of them are visible agents that just don't match the search pattern.

CLI Output Demonstrating the Bug

With 6 agents total (4 visible, 2 hidden), running cortex agent list --filter foo:

$ cortex agent list --filter foo

Name                 Mode       Source     Description
----------------------------------------------------------------------------------
foo-analyzer         primary    local      Analyzes foo files
foo-reviewer         subagent   local      Reviews foo code

Showing 2 agents (2 primary, 1 subagents, 4 hidden - use --all to show all)
                                            ^^^^^^^^
                                            WRONG: only 1 hidden agent matches "foo"
                                            The other 3 are visible agents that don't
                                            match the pattern

Expected output:

Showing 2 agents (2 primary, 1 subagents, 1 hidden - use --all to show all)

Steps to Reproduce

  1. Have a workspace with multiple agents, some hidden and some visible, with varying names
  2. Run cortex agent list --filter <pattern> where the pattern matches fewer agents than the total
  3. Observe the N hidden count in the footer is inflated — it includes visible agents that don't match the filter

Expected Behavior

hidden_count should only count truly hidden agents (those not shown because of hidden: true), not agents that are merely excluded by the --filter pattern.

Fix: Compute hidden count independently of the pattern filter:

let hidden_count = if !args.all {
    agents.iter().filter(|a| a.hidden).count()
} else {
    0
};

Actual Behavior

hidden_count = agents.len() - filtered.len() counts all non-displayed agents as "hidden", including visible ones excluded by --filter.

Environment

  • OS: Linux
  • Version: v0.0.7
  • File: src/cortex-cli/src/agent_cmd/handlers/list.rs, lines 131–135

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions