UAT: agents session delete --format json does not produce structured JSON output #6766

Open
opened 2026-04-10 02:04:07 +00:00 by HAL9000 · 1 comment
Owner

Background and Context

UAT code analysis of src/cleveragents/cli/commands/session.py found that the delete command does not produce structured JSON/YAML output when non-rich formats are requested. The spec requires a full envelope with data.deletion_summary and data.cleanup sub-keys.

Current Behavior

Looking at delete() in session.py (line 457), the non-rich branch (else clause, line 524–526) is:

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

This means that agents session delete 01HXYZ... --format json produces only a Rich-markup console message string — not a valid JSON envelope.

Expected Behavior (from Spec)

Per docs/specification.md §"agents session delete" JSON tab:

{
  "command": "agents session delete 01HXM2A6K1P2E9Q9D4GQ7J4S7Z",
  "status": "ok",
  "exit_code": 0,
  "data": {
    "deletion_summary": {
      "session": "01HXM2A6K1P2E9Q9D4GQ7J4S7Z",
      "id": "01HXM2A6K1P2E9Q9D4GQ7J4S7Z",
      "messages_removed": 6,
      "storage_freed": "18 KB",
      "plans_orphaned": 0
    },
    "cleanup": {
      "backups": "none",
      "logs": "preserved",
      "context": "cleared",
      "checkpoints": "none"
    }
  },
  "timing": { "duration_ms": 62 },
  "messages": [{ "level": "ok", "text": "Session deleted" }]
}

Steps to Reproduce

  1. Clone the repository and run agents init
  2. Create a session: agents session create
  3. Note the session ID, then run: agents session delete <SESSION_ID> --yes --format json
  4. Observe: output is [green]✓ OK[/green] Session <SESSION_ID> deleted (Rich markup text), not a JSON envelope

Acceptance Criteria

  • agents session delete <ID> --format json emits a valid JSON envelope with data.deletion_summary and data.cleanup sub-objects
  • The data.deletion_summary.messages_removed field is an integer reflecting actual messages deleted
  • Same fix applies to --format yaml and --format plain
  • The command calls format_output(...) with structured data for non-rich formats (matching the pattern used by session create and session list)

Supporting Information

  • Source file: src/cleveragents/cli/commands/session.py, function delete() (line 457), else branch at line 524
  • Spec reference: docs/specification.md §"agents session delete" JSON and YAML tabs
  • The delete() function correctly stores message_count before deletion (line 485), so the data is available; it just needs to be formatted via format_output() instead of the plain console print

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

## Background and Context UAT code analysis of `src/cleveragents/cli/commands/session.py` found that the `delete` command does not produce structured JSON/YAML output when non-rich formats are requested. The spec requires a full envelope with `data.deletion_summary` and `data.cleanup` sub-keys. ## Current Behavior Looking at `delete()` in `session.py` (line 457), the non-rich branch (else clause, line 524–526) is: ```python else: # Non-rich formats: simple message console.print(f"[green]✓ OK[/green] Session {session_id} deleted") ``` This means that `agents session delete 01HXYZ... --format json` produces only a Rich-markup console message string — not a valid JSON envelope. ## Expected Behavior (from Spec) Per `docs/specification.md` §"agents session delete" JSON tab: ```json { "command": "agents session delete 01HXM2A6K1P2E9Q9D4GQ7J4S7Z", "status": "ok", "exit_code": 0, "data": { "deletion_summary": { "session": "01HXM2A6K1P2E9Q9D4GQ7J4S7Z", "id": "01HXM2A6K1P2E9Q9D4GQ7J4S7Z", "messages_removed": 6, "storage_freed": "18 KB", "plans_orphaned": 0 }, "cleanup": { "backups": "none", "logs": "preserved", "context": "cleared", "checkpoints": "none" } }, "timing": { "duration_ms": 62 }, "messages": [{ "level": "ok", "text": "Session deleted" }] } ``` ## Steps to Reproduce 1. Clone the repository and run `agents init` 2. Create a session: `agents session create` 3. Note the session ID, then run: `agents session delete <SESSION_ID> --yes --format json` 4. Observe: output is `[green]✓ OK[/green] Session <SESSION_ID> deleted` (Rich markup text), not a JSON envelope ## Acceptance Criteria - `agents session delete <ID> --format json` emits a valid JSON envelope with `data.deletion_summary` and `data.cleanup` sub-objects - The `data.deletion_summary.messages_removed` field is an integer reflecting actual messages deleted - Same fix applies to `--format yaml` and `--format plain` - The command calls `format_output(...)` with structured data for non-rich formats (matching the pattern used by `session create` and `session list`) ## Supporting Information - Source file: `src/cleveragents/cli/commands/session.py`, function `delete()` (line 457), else branch at line 524 - Spec reference: `docs/specification.md` §"agents session delete" JSON and YAML tabs - The `delete()` function correctly stores `message_count` before deletion (line 485), so the data is available; it just needs to be formatted via `format_output()` instead of the plain console print --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.4.0 milestone 2026-04-10 02:04:22 +00:00
Author
Owner

Verified — UAT bug: session delete JSON output not structured. MoSCoW: Should-have. Priority: Medium.


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

✅ **Verified** — UAT bug: session delete JSON output not structured. MoSCoW: Should-have. Priority: Medium. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
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#6766
No description provided.