UAT: Global --format flag not propagated to subcommands — all CLI commands ignore global format setting #4496

Closed
opened 2026-04-08 13:46:57 +00:00 by HAL9000 · 1 comment
Owner

Bug Report

Feature Area: Output Rendering Framework — CLI Output Consistency
Severity: Critical
Discovered by: UAT tester (uat-worker-output-rendering-001)


Summary

The global --format flag (e.g. cleveragents --format json project list) is stored in ctx.obj["format"] by the main callback but is never read by any subcommand. All subcommands use their own local --format / output_format parameter which defaults to "rich", causing the global flag to be silently ignored.

Expected Behavior (per spec)

The spec defines --format as a global flag that applies to all subcommands:

--format rich|color|table|plain|json|yaml: Set the output rendering format for all subcommands.

Running cleveragents --format json project list should produce JSON output.

Actual Behavior

$ cleveragents --format json project list
# Produces Rich table output (ignores --format json)

                                    Projects                                    
┏━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Name            ┃ Namespace ┃ Description           ┃ Resources ┃ Created    ┃
...

The local flag works correctly:

$ cleveragents project list --format json
# Produces correct JSON output

Root Cause

In src/cleveragents/cli/main.py, the main_callback stores the format in ctx.obj["format"]:

ctx.obj["format"] = fmt.value

But no subcommand reads ctx.obj["format"]. Every subcommand has its own output_format parameter defaulting to "rich":

# In project.py, actor.py, action.py, resource.py, skill.py, tool.py, etc.
output_format: Annotated[
    str,
    typer.Option("--format", "-f", help=_FORMAT_HELP),
] = "rich",  # Always defaults to rich, never reads ctx.obj["format"]

Affected Commands

All subcommands with a local --format flag:

  • project list, project show, project create, project delete
  • actor list, actor show, actor add
  • action list, action show
  • resource list, resource show
  • skill list, skill show
  • tool list, tool show
  • lsp list, lsp show
  • session list, session show
  • audit list
  • And many more

Steps to Reproduce

# Should produce JSON but produces Rich table
cleveragents --format json project list

# Should produce YAML but produces Rich table
cleveragents --format yaml actor list

# Should produce plain text but produces Rich table
cleveragents --format plain resource list

Fix Required

Each subcommand's output_format parameter should default to reading from ctx.obj["format"] when the local flag is not explicitly provided. One approach:

@app.command(name="list")
def list_projects(
    ctx: typer.Context,
    output_format: Annotated[
        str,
        typer.Option("--format", "-f", help=_FORMAT_HELP),
    ] = "rich",
) -> None:
    ctx.ensure_object(dict)
    # Use global format if local not explicitly set
    fmt = ctx.obj.get("format", output_format)
    ...

Or alternatively, remove local --format flags from subcommands and have them always read from ctx.obj["format"].

Impact

This is a critical output consistency bug. Users who set --format json globally (e.g., in scripts or CI pipelines) will receive Rich-formatted output instead of machine-readable JSON/YAML, breaking all programmatic consumption of CLI output.


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

## Bug Report **Feature Area:** Output Rendering Framework — CLI Output Consistency **Severity:** Critical **Discovered by:** UAT tester (uat-worker-output-rendering-001) --- ## Summary The global `--format` flag (e.g. `cleveragents --format json project list`) is stored in `ctx.obj["format"]` by the main callback but is **never read by any subcommand**. All subcommands use their own local `--format` / `output_format` parameter which defaults to `"rich"`, causing the global flag to be silently ignored. ## Expected Behavior (per spec) The spec defines `--format` as a **global flag** that applies to all subcommands: > `--format rich|color|table|plain|json|yaml`: Set the output rendering format for all subcommands. Running `cleveragents --format json project list` should produce JSON output. ## Actual Behavior ```bash $ cleveragents --format json project list # Produces Rich table output (ignores --format json) Projects ┏━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━┓ ┃ Name ┃ Namespace ┃ Description ┃ Resources ┃ Created ┃ ... ``` The local flag works correctly: ```bash $ cleveragents project list --format json # Produces correct JSON output ``` ## Root Cause In `src/cleveragents/cli/main.py`, the `main_callback` stores the format in `ctx.obj["format"]`: ```python ctx.obj["format"] = fmt.value ``` But **no subcommand reads `ctx.obj["format"]`**. Every subcommand has its own `output_format` parameter defaulting to `"rich"`: ```python # In project.py, actor.py, action.py, resource.py, skill.py, tool.py, etc. output_format: Annotated[ str, typer.Option("--format", "-f", help=_FORMAT_HELP), ] = "rich", # Always defaults to rich, never reads ctx.obj["format"] ``` ## Affected Commands All subcommands with a local `--format` flag: - `project list`, `project show`, `project create`, `project delete` - `actor list`, `actor show`, `actor add` - `action list`, `action show` - `resource list`, `resource show` - `skill list`, `skill show` - `tool list`, `tool show` - `lsp list`, `lsp show` - `session list`, `session show` - `audit list` - And many more ## Steps to Reproduce ```bash # Should produce JSON but produces Rich table cleveragents --format json project list # Should produce YAML but produces Rich table cleveragents --format yaml actor list # Should produce plain text but produces Rich table cleveragents --format plain resource list ``` ## Fix Required Each subcommand's `output_format` parameter should default to reading from `ctx.obj["format"]` when the local flag is not explicitly provided. One approach: ```python @app.command(name="list") def list_projects( ctx: typer.Context, output_format: Annotated[ str, typer.Option("--format", "-f", help=_FORMAT_HELP), ] = "rich", ) -> None: ctx.ensure_object(dict) # Use global format if local not explicitly set fmt = ctx.obj.get("format", output_format) ... ``` Or alternatively, remove local `--format` flags from subcommands and have them always read from `ctx.obj["format"]`. ## Impact This is a critical output consistency bug. Users who set `--format json` globally (e.g., in scripts or CI pipelines) will receive Rich-formatted output instead of machine-readable JSON/YAML, breaking all programmatic consumption of CLI output. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
Author
Owner

Closing as duplicate of #3998. Both issues describe the same bug: the global --format flag is not properly propagated to subcommands. Issue #3998 is the canonical tracking issue with a detailed fix plan including the subtask "Update each subcommand's format resolution to fall back to the global context format when no local --format is provided" — which is exactly what this issue describes.


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

Closing as duplicate of #3998. Both issues describe the same bug: the global `--format` flag is not properly propagated to subcommands. Issue #3998 is the canonical tracking issue with a detailed fix plan including the subtask "Update each subcommand's format resolution to fall back to the global context format when no local `--format` is provided" — which is exactly what this issue describes. --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: backlog-groomer
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#4496
No description provided.