UAT: agents plan cancel --format json returns raw plan dict instead of spec-required envelope — missing reason, cancelled_at, sandbox, child_plans, recovery objects #6865

Open
opened 2026-04-10 03:46:38 +00:00 by HAL9000 · 0 comments
Owner

Background and Context

agents plan cancel terminates a running plan and should return structured output that automation can use to understand the cancellation scope (sandbox preserved state, child plan disposition, recovery steps). The spec defines a specific output envelope for this command.

Current Behavior

Code at src/cleveragents/cli/commands/plan.py lines 3154–3158:

if fmt != OutputFormat.RICH.value:
    data = _plan_spec_dict(plan)
    if reason:
        data["cancel_reason"] = reason
    console.print(format_output(data, fmt))

_plan_spec_dict(plan) returns the raw plan domain dict, plus an optional cancel_reason field appended. This is a flat domain dump, not the spec-required structured response.

Note the field name is also wrong: code uses cancel_reason but spec uses reason.

Expected Behavior

Per spec §agents plan cancel (JSON example §14256–14287), the output must be:

{
  "command": "plan cancel",
  "status": "ok",
  "exit_code": 0,
  "data": {
    "plan_id": "01HXM8C2ZK4Q7C2B3F2R4VYV6J",
    "phase": "execute",
    "reason": "blocked on credentials",
    "state": "cancelled",
    "cancelled_at": "13:02:15",
    "sandbox": {
      "status": "preserved",
      "files_modified": 3,
      "checkpoints": 2
    },
    "child_plans": {
      "completed": 1,
      "cancelled": 1,
      "artifacts_preserved": true
    },
    "recovery": [
      "Resolve credentials",
      "Run agents plan execute 01HXM8C2ZK4Q7C2B3F2R4VYV6J"
    ]
  },
  "timing": { "started": "2026-02-08T13:02:15Z", "duration_ms": 340 },
  "messages": ["Plan cancelled"]
}

Missing from current implementation:

  • Top-level envelope: command, status, exit_code, timing, messages
  • data.reason (field named cancel_reason instead)
  • data.cancelled_at (timestamp when cancellation occurred)
  • data.sandbox object with status, files_modified, checkpoints
  • data.child_plans object with completed, cancelled, artifacts_preserved
  • data.recovery array (suggested recovery steps)
  • data.phase (while present in domain dict, it's correct)
  • data.state reflects cancelled state after cancellation

Acceptance Criteria

  • agents plan cancel --format json returns an object with command, status, exit_code, data, timing, messages
  • data.reason contains the cancellation reason (or null if not provided)
  • data.cancelled_at is the time of cancellation (HH:MM:SS format per spec example)
  • data.sandbox object reflects sandbox state after cancellation (preserved)
  • data.child_plans summarizes child plan disposition at time of cancellation
  • data.recovery provides suggested recovery steps

Supporting Information

  • Spec reference: §agents plan cancel, JSON example at lines 14256–14287
  • Code location: src/cleveragents/cli/commands/plan.py lines 3154–3158 (cancel_plan)
  • Field name bug: code uses cancel_reason, spec requires reason

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

## Background and Context `agents plan cancel` terminates a running plan and should return structured output that automation can use to understand the cancellation scope (sandbox preserved state, child plan disposition, recovery steps). The spec defines a specific output envelope for this command. ## Current Behavior Code at `src/cleveragents/cli/commands/plan.py` lines 3154–3158: ```python if fmt != OutputFormat.RICH.value: data = _plan_spec_dict(plan) if reason: data["cancel_reason"] = reason console.print(format_output(data, fmt)) ``` `_plan_spec_dict(plan)` returns the raw plan domain dict, plus an optional `cancel_reason` field appended. This is a flat domain dump, not the spec-required structured response. Note the field name is also wrong: code uses `cancel_reason` but spec uses `reason`. ## Expected Behavior Per spec §agents plan cancel (JSON example §14256–14287), the output **must** be: ```json { "command": "plan cancel", "status": "ok", "exit_code": 0, "data": { "plan_id": "01HXM8C2ZK4Q7C2B3F2R4VYV6J", "phase": "execute", "reason": "blocked on credentials", "state": "cancelled", "cancelled_at": "13:02:15", "sandbox": { "status": "preserved", "files_modified": 3, "checkpoints": 2 }, "child_plans": { "completed": 1, "cancelled": 1, "artifacts_preserved": true }, "recovery": [ "Resolve credentials", "Run agents plan execute 01HXM8C2ZK4Q7C2B3F2R4VYV6J" ] }, "timing": { "started": "2026-02-08T13:02:15Z", "duration_ms": 340 }, "messages": ["Plan cancelled"] } ``` **Missing from current implementation:** - Top-level envelope: `command`, `status`, `exit_code`, `timing`, `messages` - `data.reason` (field named `cancel_reason` instead) - `data.cancelled_at` (timestamp when cancellation occurred) - `data.sandbox` object with `status`, `files_modified`, `checkpoints` - `data.child_plans` object with `completed`, `cancelled`, `artifacts_preserved` - `data.recovery` array (suggested recovery steps) - `data.phase` (while present in domain dict, it's correct) - `data.state` reflects cancelled state after cancellation ## Acceptance Criteria - `agents plan cancel --format json` returns an object with `command`, `status`, `exit_code`, `data`, `timing`, `messages` - `data.reason` contains the cancellation reason (or `null` if not provided) - `data.cancelled_at` is the time of cancellation (HH:MM:SS format per spec example) - `data.sandbox` object reflects sandbox state after cancellation (`preserved`) - `data.child_plans` summarizes child plan disposition at time of cancellation - `data.recovery` provides suggested recovery steps ## Supporting Information - Spec reference: §agents plan cancel, JSON example at lines 14256–14287 - Code location: `src/cleveragents/cli/commands/plan.py` lines 3154–3158 (`cancel_plan`) - Field name bug: code uses `cancel_reason`, spec requires `reason` --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.4.0 milestone 2026-04-10 03:47:15 +00:00
HAL9000 self-assigned this 2026-04-10 06:06:35 +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.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#6865
No description provided.