UAT: agents session delete --format json does not produce spec-required JSON envelope — outputs plain Rich text instead #5019

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

Bug Report

Feature Area: CLI Commands — agents session delete
Severity: Medium
Discovered by: UAT Testing (uat-pool-1, worker: CLI Commands)


What Was Tested

Reviewed the agents session delete command's non-rich format output path.

Expected Behavior (from spec)

When --format json is passed, agents session delete should produce a spec-compliant JSON envelope:

{
  "command": "agents session delete",
  "status": "ok",
  "exit_code": 0,
  "data": {
    "session_id": "...",
    "messages_removed": 5,
    "storage_freed": "0 KB"
  },
  "timing": { "duration_ms": 42 },
  "messages": [{ "level": "ok", "text": "agents session delete completed" }]
}

Actual Behavior

In session.py, the delete() command has this non-rich branch:

else:
    # Non-rich formats: simple message
    console.print(f"[green]✓ OK[/green] Session {session_id} deleted")

This outputs a Rich-formatted string (with markup) to stdout even when --format json is requested. It does not call format_output() and does not produce a JSON envelope.

Code Location

src/cleveragents/cli/commands/session.pydelete() function, the else branch after the if fmt == OutputFormat.RICH: block.

Steps to Reproduce

agents session delete <SESSION_ID> --yes --format json
# Expected: JSON envelope
# Actual: "[green]✓ OK[/green] Session <SESSION_ID> deleted" (Rich markup in stdout)

Impact

Automation scripts using --format json to parse deletion results will receive invalid JSON or Rich markup text instead of a structured response.

Suggested Fix

Replace the else branch with a proper format_output() call:

else:
    # Non-rich formats: emit structured output
    data = {
        "session_id": session_id,
        "messages_removed": message_count,
        "storage_freed": "0 KB",
        "plans_orphaned": 0,
    }
    typer.echo(format_output(data, fmt.value, command="agents session delete"))

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

## Bug Report **Feature Area:** CLI Commands — `agents session delete` **Severity:** Medium **Discovered by:** UAT Testing (uat-pool-1, worker: CLI Commands) --- ## What Was Tested Reviewed the `agents session delete` command's non-rich format output path. ## Expected Behavior (from spec) When `--format json` is passed, `agents session delete` should produce a spec-compliant JSON envelope: ```json { "command": "agents session delete", "status": "ok", "exit_code": 0, "data": { "session_id": "...", "messages_removed": 5, "storage_freed": "0 KB" }, "timing": { "duration_ms": 42 }, "messages": [{ "level": "ok", "text": "agents session delete completed" }] } ``` ## Actual Behavior In `session.py`, the `delete()` command has this non-rich branch: ```python else: # Non-rich formats: simple message console.print(f"[green]✓ OK[/green] Session {session_id} deleted") ``` This outputs a Rich-formatted string (with markup) to stdout even when `--format json` is requested. It does **not** call `format_output()` and does **not** produce a JSON envelope. ## Code Location `src/cleveragents/cli/commands/session.py` — `delete()` function, the `else` branch after the `if fmt == OutputFormat.RICH:` block. ## Steps to Reproduce ```bash agents session delete <SESSION_ID> --yes --format json # Expected: JSON envelope # Actual: "[green]✓ OK[/green] Session <SESSION_ID> deleted" (Rich markup in stdout) ``` ## Impact Automation scripts using `--format json` to parse deletion results will receive invalid JSON or Rich markup text instead of a structured response. ## Suggested Fix Replace the `else` branch with a proper `format_output()` call: ```python else: # Non-rich formats: emit structured output data = { "session_id": session_id, "messages_removed": message_count, "storage_freed": "0 KB", "plans_orphaned": 0, } typer.echo(format_output(data, fmt.value, command="agents session delete")) ``` --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.2.0 milestone 2026-04-09 01:01:48 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Medium — Spec compliance bug; deviates from documented behavior
  • Milestone: v3.2.0
  • Story Points: 3 — M
  • MoSCoW: Must Have — Spec compliance is required

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

Issue triaged by project owner: - **State**: Verified - **Priority**: Medium — Spec compliance bug; deviates from documented behavior - **Milestone**: v3.2.0 - **Story Points**: 3 — M - **MoSCoW**: Must Have — Spec compliance is required --- **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#5019
No description provided.