UAT: context inspect --strategy filter checks wrong metadata field, never matches fragments #4777

Open
opened 2026-04-08 18:56:35 +00:00 by HAL9000 · 1 comment
Owner

Bug Report

Feature Area: ACMS — agents project context inspect command, --strategy filter option

Severity: Medium — the --strategy filter option silently returns no results instead of filtering by strategy name

What Was Tested

Code-level analysis of the context_inspect function in src/cleveragents/cli/commands/project_context.py lines 999-1006.

Expected Behavior (from spec)

The spec at docs/specification.md line 4124 says:

--strategy STRATEGY: Filter to show results from a specific strategy only.

When a user runs agents project context inspect --strategy breadth-depth-navigator <project>, they should see only the fragments that were produced by the breadth-depth-navigator strategy.

Actual Behavior

The implementation filters fragments using:

if strategy_filter is not None:
    project_fragments = [
        f
        for f in project_fragments
        if f.metadata.get("strategy") == strategy_filter
        or strategy_filter in (f.resource_id or "")
    ]

This checks f.metadata.get("strategy") — but TieredFragment objects (from the tier service) do not have a "strategy" key in their metadata. The strategy field is set on FragmentProvenance objects within ContextFragment (the CRP model), not on TieredFragment objects from the tier service.

The fallback strategy_filter in (f.resource_id or "") checks if the strategy name appears in the resource ID string, which will never match for strategy names like "breadth-depth-navigator".

As a result, --strategy always returns an empty list (or the full list if the strategy name happens to appear in a resource ID, which is unlikely).

Impact

  • The --strategy filter option is silently broken — it always returns 0 fragments
  • Users cannot filter context inspection by strategy, making it impossible to debug which strategy contributed which fragments

Code Location

src/cleveragents/cli/commands/project_context.py lines 999-1006

Fix Required

The filter should check the provenance.strategy field on ContextFragment objects, not metadata.get("strategy") on TieredFragment objects. Since context inspect works with TieredFragment objects from the tier service, the fix requires either:

  1. Storing the strategy name in TieredFragment.metadata["strategy"] when fragments are promoted to tiers
  2. Or querying the ACMS pipeline's last assembly result (which has ContextFragment objects with provenance.strategy) instead of the raw tier service

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: uat-tester

## Bug Report **Feature Area:** ACMS — `agents project context inspect` command, `--strategy` filter option **Severity:** Medium — the `--strategy` filter option silently returns no results instead of filtering by strategy name ### What Was Tested Code-level analysis of the `context_inspect` function in `src/cleveragents/cli/commands/project_context.py` lines 999-1006. ### Expected Behavior (from spec) The spec at `docs/specification.md` line 4124 says: > `--strategy STRATEGY`: Filter to show results from a specific strategy only. When a user runs `agents project context inspect --strategy breadth-depth-navigator <project>`, they should see only the fragments that were produced by the `breadth-depth-navigator` strategy. ### Actual Behavior The implementation filters fragments using: ```python if strategy_filter is not None: project_fragments = [ f for f in project_fragments if f.metadata.get("strategy") == strategy_filter or strategy_filter in (f.resource_id or "") ] ``` This checks `f.metadata.get("strategy")` — but `TieredFragment` objects (from the tier service) do not have a `"strategy"` key in their metadata. The `strategy` field is set on `FragmentProvenance` objects within `ContextFragment` (the CRP model), not on `TieredFragment` objects from the tier service. The fallback `strategy_filter in (f.resource_id or "")` checks if the strategy name appears in the resource ID string, which will never match for strategy names like `"breadth-depth-navigator"`. As a result, `--strategy` always returns an empty list (or the full list if the strategy name happens to appear in a resource ID, which is unlikely). ### Impact - The `--strategy` filter option is silently broken — it always returns 0 fragments - Users cannot filter context inspection by strategy, making it impossible to debug which strategy contributed which fragments ### Code Location `src/cleveragents/cli/commands/project_context.py` lines 999-1006 ### Fix Required The filter should check the `provenance.strategy` field on `ContextFragment` objects, not `metadata.get("strategy")` on `TieredFragment` objects. Since `context inspect` works with `TieredFragment` objects from the tier service, the fix requires either: 1. Storing the strategy name in `TieredFragment.metadata["strategy"]` when fragments are promoted to tiers 2. Or querying the ACMS pipeline's last assembly result (which has `ContextFragment` objects with `provenance.strategy`) instead of the raw tier service --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Medium — spec compliance bug identified by UAT testing
  • Story Points: 3 (M) — targeted fix to align implementation with spec
  • MoSCoW: Must Have — spec compliance is required for correct system behavior

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

Issue triaged by project owner: - **State**: Verified - **Priority**: Medium — spec compliance bug identified by UAT testing - **Story Points**: 3 (M) — targeted fix to align implementation with spec - **MoSCoW**: Must Have — spec compliance is required for correct system behavior --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner
HAL9000 added this to the v3.5.0 milestone 2026-04-09 03:04:22 +00:00
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.

Dependencies

No dependencies set.

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