UAT: format_output() called without command= parameter across actor, action, session commands — JSON envelope command field always empty string #5015

Open
opened 2026-04-09 00:48:21 +00:00 by HAL9000 · 1 comment
Owner

Bug Report

Feature Area: CLI Commands — JSON output envelope compliance
Severity: High
Discovered by: UAT Testing (uat-pool-1, worker: CLI Commands)


What Was Tested

Reviewed all format_output() call sites in actor.py, action.py, and session.py for compliance with the spec-required JSON envelope structure.

Expected Behavior (from spec)

The spec requires that --format json output wraps data in an envelope with a command field identifying the CLI command that produced the output:

{
  "command": "agents actor list",
  "status": "ok",
  "exit_code": 0,
  "data": { ... },
  "timing": { "duration_ms": 123 },
  "messages": [{ "level": "ok", "text": "agents actor list completed" }]
}

The format_output() function in formatting.py accepts a command= keyword argument for exactly this purpose.

Actual Behavior

All format_output() calls in actor.py, action.py, and session.py omit the command= parameter, causing the envelope's command field to always be an empty string "":

{
  "command": "",
  "status": "ok",
  "exit_code": 0,
  "data": { ... },
  ...
}

Affected call sites:

src/cleveragents/cli/commands/actor.py:

# _print_actor() — called by add, update, show, set-default
console.print(format_output(data, fmt))  # missing command=

# list_actors()
console.print(format_output(data, fmt))  # missing command=

src/cleveragents/cli/commands/action.py:

# _print_action() — called by create, show, archive
console.print(format_output(data, fmt))  # missing command=

# list_actions()
console.print(format_output(data, fmt))  # missing command=

src/cleveragents/cli/commands/session.py:

# create()
typer.echo(format_output(dict(data), fmt))  # missing command=

# list_sessions()
typer.echo(format_output(data, fmt))  # missing command=

# show()
typer.echo(format_output(dict(data), fmt))  # missing command=

Steps to Reproduce

agents actor list --format json | python3 -c "import sys,json; d=json.load(sys.stdin); print(repr(d['command']))"
# Output: ''   (should be 'agents actor list')

agents action list --format json | python3 -c "import sys,json; d=json.load(sys.stdin); print(repr(d['command']))"
# Output: ''   (should be 'agents action list')

Impact

  • Automation scripts that parse the command field to identify output source will receive empty strings
  • The messages[0].text field will also be wrong: " completed" instead of "agents actor list completed"
  • Breaks the spec contract for machine-readable output

Suggested Fix

Pass command= to each format_output() call:

# In actor.py _print_actor():
console.print(format_output(data, fmt, command="agents actor show"))

# In actor.py list_actors():
console.print(format_output(data, fmt, command="agents actor list"))

# In action.py _print_action():
console.print(format_output(data, fmt, command="agents action show"))

# etc.

Note: The _print_actor() and _print_action() helper functions are called from multiple commands with different titles. The command= string should be passed as a parameter to these helpers.


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

## Bug Report **Feature Area:** CLI Commands — JSON output envelope compliance **Severity:** High **Discovered by:** UAT Testing (uat-pool-1, worker: CLI Commands) --- ## What Was Tested Reviewed all `format_output()` call sites in `actor.py`, `action.py`, and `session.py` for compliance with the spec-required JSON envelope structure. ## Expected Behavior (from spec) The spec requires that `--format json` output wraps data in an envelope with a `command` field identifying the CLI command that produced the output: ```json { "command": "agents actor list", "status": "ok", "exit_code": 0, "data": { ... }, "timing": { "duration_ms": 123 }, "messages": [{ "level": "ok", "text": "agents actor list completed" }] } ``` The `format_output()` function in `formatting.py` accepts a `command=` keyword argument for exactly this purpose. ## Actual Behavior All `format_output()` calls in `actor.py`, `action.py`, and `session.py` omit the `command=` parameter, causing the envelope's `command` field to always be an empty string `""`: ```json { "command": "", "status": "ok", "exit_code": 0, "data": { ... }, ... } ``` ### Affected call sites: **`src/cleveragents/cli/commands/actor.py`:** ```python # _print_actor() — called by add, update, show, set-default console.print(format_output(data, fmt)) # missing command= # list_actors() console.print(format_output(data, fmt)) # missing command= ``` **`src/cleveragents/cli/commands/action.py`:** ```python # _print_action() — called by create, show, archive console.print(format_output(data, fmt)) # missing command= # list_actions() console.print(format_output(data, fmt)) # missing command= ``` **`src/cleveragents/cli/commands/session.py`:** ```python # create() typer.echo(format_output(dict(data), fmt)) # missing command= # list_sessions() typer.echo(format_output(data, fmt)) # missing command= # show() typer.echo(format_output(dict(data), fmt)) # missing command= ``` ## Steps to Reproduce ```bash agents actor list --format json | python3 -c "import sys,json; d=json.load(sys.stdin); print(repr(d['command']))" # Output: '' (should be 'agents actor list') agents action list --format json | python3 -c "import sys,json; d=json.load(sys.stdin); print(repr(d['command']))" # Output: '' (should be 'agents action list') ``` ## Impact - Automation scripts that parse the `command` field to identify output source will receive empty strings - The `messages[0].text` field will also be wrong: `" completed"` instead of `"agents actor list completed"` - Breaks the spec contract for machine-readable output ## Suggested Fix Pass `command=` to each `format_output()` call: ```python # In actor.py _print_actor(): console.print(format_output(data, fmt, command="agents actor show")) # In actor.py list_actors(): console.print(format_output(data, fmt, command="agents actor list")) # In action.py _print_action(): console.print(format_output(data, fmt, command="agents action show")) # etc. ``` Note: The `_print_actor()` and `_print_action()` helper functions are called from multiple commands with different titles. The `command=` string should be passed as a parameter to these helpers. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.2.0 milestone 2026-04-09 01:04:24 +00:00
Author
Owner

Issue triaged by project owner. Verified as valid spec compliance bug.


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

Issue triaged by project owner. Verified as valid spec compliance bug. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner
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#5015
No description provided.