UAT: JSON/YAML envelope command field is always empty string — spec requires actual command name #5194

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

Bug Report

Feature Area: CLI Commands — JSON/YAML output envelope command field
Severity: High — programmatic consumers relying on the command field for routing/logging receive empty string instead of the command name
Source: src/cleveragents/cli/formatting.py (format_output function, _build_envelope function)


What Was Tested

Runtime testing of --format json and --format yaml output across multiple commands, examining the envelope structure.

Expected Behavior (from spec §Output Rendering Framework §json format)

The spec defines the JSON envelope as:

{
  "command": "project show",
  "status": "ok",
  "exit_code": 0,
  "data": { ... },
  "timing": { "duration_ms": 42 },
  "metadata": { ... }
}

The command field must contain the actual command that was run (e.g., "version", "session list", "project show local/api-service").

Additional spec examples:

  • agents --format json version"command": "version"
  • agents --format json session list"command": "session list" (or "agents session list")
  • agents --format json plan list --phase execute"command": "plan list"

Actual Behavior

The command field is always an empty string "" regardless of which command was run:

{
  "command": "",
  "status": "ok",
  "exit_code": 0,
  "data": { ... },
  "timing": { "duration_ms": 0 },
  "messages": [{ "level": "ok", "text": "ok" }]
}

Observed for all tested commands:

  • agents --format json version"command": ""
  • agents --format json info"command": ""
  • agents --format json diagnostics"command": ""
  • agents session list --format json"command": ""
  • agents project list --format json"command": ""
  • agents resource list --format json"command": ""

Root Cause

In src/cleveragents/cli/formatting.py, the format_output function has a command parameter that defaults to "":

def format_output(
    data: dict[str, Any] | list[dict[str, Any]],
    format_type: str,
    *,
    command: str = "",  # ← defaults to empty string
    ...

All callers pass format_output(data, fmt) without providing the command argument, so it always defaults to "". No command ever passes its name to format_output.

Steps to Reproduce

agents --format json version
# Expected: { "command": "version", ... }
# Actual:   { "command": "", ... }

agents session list --format json
# Expected: { "command": "session list", ... }
# Actual:   { "command": "", ... }

Impact

  • Programmatic consumers that use command for routing, logging, or audit trails receive empty string
  • The JSON output does not match the documented spec schema
  • Automation scripts that validate the command field will fail

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

## Bug Report **Feature Area:** CLI Commands — JSON/YAML output envelope `command` field **Severity:** High — programmatic consumers relying on the `command` field for routing/logging receive empty string instead of the command name **Source:** `src/cleveragents/cli/formatting.py` (`format_output` function, `_build_envelope` function) --- ## What Was Tested Runtime testing of `--format json` and `--format yaml` output across multiple commands, examining the envelope structure. ## Expected Behavior (from spec §Output Rendering Framework §json format) The spec defines the JSON envelope as: ```json { "command": "project show", "status": "ok", "exit_code": 0, "data": { ... }, "timing": { "duration_ms": 42 }, "metadata": { ... } } ``` The `command` field must contain the actual command that was run (e.g., `"version"`, `"session list"`, `"project show local/api-service"`). Additional spec examples: - `agents --format json version` → `"command": "version"` - `agents --format json session list` → `"command": "session list"` (or `"agents session list"`) - `agents --format json plan list --phase execute` → `"command": "plan list"` ## Actual Behavior The `command` field is **always an empty string** `""` regardless of which command was run: ```json { "command": "", "status": "ok", "exit_code": 0, "data": { ... }, "timing": { "duration_ms": 0 }, "messages": [{ "level": "ok", "text": "ok" }] } ``` Observed for all tested commands: - `agents --format json version` → `"command": ""` ❌ - `agents --format json info` → `"command": ""` ❌ - `agents --format json diagnostics` → `"command": ""` ❌ - `agents session list --format json` → `"command": ""` ❌ - `agents project list --format json` → `"command": ""` ❌ - `agents resource list --format json` → `"command": ""` ❌ ## Root Cause In `src/cleveragents/cli/formatting.py`, the `format_output` function has a `command` parameter that defaults to `""`: ```python def format_output( data: dict[str, Any] | list[dict[str, Any]], format_type: str, *, command: str = "", # ← defaults to empty string ... ``` All callers pass `format_output(data, fmt)` without providing the `command` argument, so it always defaults to `""`. No command ever passes its name to `format_output`. ## Steps to Reproduce ```bash agents --format json version # Expected: { "command": "version", ... } # Actual: { "command": "", ... } agents session list --format json # Expected: { "command": "session list", ... } # Actual: { "command": "", ... } ``` ## Impact - Programmatic consumers that use `command` for routing, logging, or audit trails receive empty string - The JSON output does not match the documented spec schema - Automation scripts that validate the `command` field will fail --- **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#5194
No description provided.