UAT: Global --format flag ignored by subcommands — agents --format json session list outputs rich table instead of JSON #5191

Open
opened 2026-04-09 03:05:38 +00:00 by HAL9000 · 0 comments
Owner

Bug Report

Feature Area: CLI Commands — Global --format flag propagation
Severity: Critical — machine-readable output (--format json/yaml/plain) is broken for all subcommands when using the global flag position
Source: src/cleveragents/cli/main.py (main_callback), src/cleveragents/cli/commands/session.py, src/cleveragents/cli/commands/actor.py, src/cleveragents/cli/commands/skill.py, src/cleveragents/cli/commands/tool.py, src/cleveragents/cli/commands/plan.py, src/cleveragents/cli/commands/automation_profile.py, src/cleveragents/cli/commands/lsp.py, src/cleveragents/cli/commands/config.py


What Was Tested

Runtime testing of the global --format flag position vs. the local --format flag position across multiple subcommands.

Expected Behavior (from spec §CLI Commands, §Output Rendering Framework)

The spec defines --format as a global flag:

agents|cleveragents  [--data-dir <DATA_PATH>] [--config-path <CONFIG_PATH>]
                     [--format (rich|color|table|plain|json|yaml)]
                     ...
                     <COMMAND> [<ARGS>...]

The spec states: "Set the output rendering format for all subcommands." This means agents --format json session list MUST produce JSON output.

Actual Behavior

agents --format json session list outputs a rich table (ignores the global --format json):

                           Sessions                            
┏━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓
┃ ID       ┃ Name      ┃ Actor  ┃ Messages ┃ Updated          ┃
...

But agents session list --format json (local flag) works correctly and outputs JSON.

Affected Commands

All subcommands that have their own local --format option ignore the global flag:

  • agents --format json session list → rich table
  • agents --format json actor list → rich table
  • agents --format json skill list → rich table
  • agents --format json tool list → rich table
  • agents --format json plan list → rich table
  • agents --format json automation-profile list → rich table
  • agents --format json lsp list → rich table
  • agents --format json config list → rich table
  • agents --format json invariant list → rich table

Commands that do NOT have a local --format option work correctly:

  • agents --format json version → JSON ✓
  • agents --format json info → JSON ✓
  • agents --format json diagnostics → JSON ✓

Root Cause

The main_callback stores the format in ctx.obj["format"], but subcommands that define their own --format option (e.g., fmt: str = typer.Option("--format", "-f", ...)) use their own local default ("rich") instead of reading from ctx.obj["format"]. The global context value is never consulted by these subcommands.

Steps to Reproduce

agents --format json session list
# Expected: JSON output
# Actual: Rich table output

agents session list --format json
# Expected: JSON output
# Actual: JSON output (works correctly)

Impact

This breaks the documented CLI contract. Scripts and automation that use the canonical agents --format json <command> pattern (as shown throughout the spec) will receive rich table output instead of machine-readable JSON, causing parsing failures.


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

## Bug Report **Feature Area:** CLI Commands — Global `--format` flag propagation **Severity:** Critical — machine-readable output (`--format json/yaml/plain`) is broken for all subcommands when using the global flag position **Source:** `src/cleveragents/cli/main.py` (main_callback), `src/cleveragents/cli/commands/session.py`, `src/cleveragents/cli/commands/actor.py`, `src/cleveragents/cli/commands/skill.py`, `src/cleveragents/cli/commands/tool.py`, `src/cleveragents/cli/commands/plan.py`, `src/cleveragents/cli/commands/automation_profile.py`, `src/cleveragents/cli/commands/lsp.py`, `src/cleveragents/cli/commands/config.py` --- ## What Was Tested Runtime testing of the global `--format` flag position vs. the local `--format` flag position across multiple subcommands. ## Expected Behavior (from spec §CLI Commands, §Output Rendering Framework) The spec defines `--format` as a **global** flag: ``` agents|cleveragents [--data-dir <DATA_PATH>] [--config-path <CONFIG_PATH>] [--format (rich|color|table|plain|json|yaml)] ... <COMMAND> [<ARGS>...] ``` The spec states: "Set the output rendering format for all subcommands." This means `agents --format json session list` MUST produce JSON output. ## Actual Behavior `agents --format json session list` outputs a **rich table** (ignores the global `--format json`): ``` Sessions ┏━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ ┃ ID ┃ Name ┃ Actor ┃ Messages ┃ Updated ┃ ... ``` But `agents session list --format json` (local flag) works correctly and outputs JSON. ## Affected Commands All subcommands that have their own local `--format` option ignore the global flag: - `agents --format json session list` → rich table ❌ - `agents --format json actor list` → rich table ❌ - `agents --format json skill list` → rich table ❌ - `agents --format json tool list` → rich table ❌ - `agents --format json plan list` → rich table ❌ - `agents --format json automation-profile list` → rich table ❌ - `agents --format json lsp list` → rich table ❌ - `agents --format json config list` → rich table ❌ - `agents --format json invariant list` → rich table ❌ Commands that do NOT have a local `--format` option work correctly: - `agents --format json version` → JSON ✓ - `agents --format json info` → JSON ✓ - `agents --format json diagnostics` → JSON ✓ ## Root Cause The `main_callback` stores the format in `ctx.obj["format"]`, but subcommands that define their own `--format` option (e.g., `fmt: str = typer.Option("--format", "-f", ...)`) use their own local default (`"rich"`) instead of reading from `ctx.obj["format"]`. The global context value is never consulted by these subcommands. ## Steps to Reproduce ```bash agents --format json session list # Expected: JSON output # Actual: Rich table output agents session list --format json # Expected: JSON output # Actual: JSON output (works correctly) ``` ## Impact This breaks the documented CLI contract. Scripts and automation that use the canonical `agents --format json <command>` pattern (as shown throughout the spec) will receive rich table output instead of machine-readable JSON, causing parsing failures. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.2.0 milestone 2026-04-09 03:12:51 +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.

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