UAT: agents plan apply --format json/yaml returns plan state dict instead of spec-required output envelope #4715

Open
opened 2026-04-08 18:11:16 +00:00 by HAL9000 · 1 comment
Owner

Bug Report

Feature Area: Plan execution and apply phase
Command: agents plan apply --format json / agents plan apply --format yaml

What Was Tested

The JSON/YAML output format of agents plan apply when using --format json or --format yaml.

Expected Behavior (from spec §agents plan apply)

The spec defines a structured output envelope for agents plan apply --format json:

{
  "command": "plan apply",
  "status": "ok",
  "exit_code": 0,
  "data": {
    "plan_id": "01HXM8C2ZK4Q7C2B3F2R4VYV6J",
    "artifacts": 6,
    "changes": { "insertions": 42, "deletions": 9 },
    "project": "local/api-service",
    "applied_at": "2026-02-08T13:04:00Z",
    "validation": { ... },
    "sandbox_cleanup": { ... },
    "lifecycle": {
      "phase": "apply",
      "state": "applied",
      "total_duration": "00:06:14",
      "total_cost": "$0.0847",
      "decisions_made": 8,
      "child_plans": 2
    }
  },
  "timing": { "started": "...", "duration_ms": 1250 },
  "messages": ["Changes applied"]
}

Actual Behavior (from code analysis)

File: src/cleveragents/cli/commands/plan.py, lines 2270–2272 and 1119–1121

Both the lifecycle_apply_plan command and the _lifecycle_apply_with_id helper use _plan_spec_dict(plan) for non-rich output:

# lifecycle_apply_plan (line 2270-2272)
if fmt != OutputFormat.RICH.value:
    data = _plan_spec_dict(plan)
    console.print(format_output(data, fmt))

# _lifecycle_apply_with_id (line 1119-1121)
if fmt != OutputFormat.RICH.value:
    data = _plan_spec_dict(plan)
    console.print(format_output(data, fmt))

_plan_spec_dict(plan) returns the plan's internal state fields (plan_id, phase, processing_state, project_links, arguments, etc.) — not the spec-required apply output envelope with command, status, exit_code, data, timing, and messages keys.

The actual JSON output looks like:

{
  "plan_id": "01HXM8C2ZK4Q7C2B3F2R4VYV6J",
  "namespaced_name": "local/my-action",
  "phase": "apply",
  "processing_state": "applied",
  "state": "applied",
  "project_links": [...],
  ...
}

This is missing:

  • The command: "plan apply" envelope key
  • The status: "ok" / exit_code: 0 fields
  • The data.artifacts count
  • The data.changes.insertions / data.changes.deletions counts
  • The data.project field
  • The data.applied_at timestamp
  • The data.validation section
  • The data.sandbox_cleanup section
  • The data.lifecycle.total_duration, total_cost, decisions_made, child_plans fields
  • The timing section
  • The messages array

Code Location

  • src/cleveragents/cli/commands/plan.py:
    • lifecycle_apply_plan() function, lines 2270–2272
    • _lifecycle_apply_with_id() function, lines 1119–1121

Steps to Reproduce

agents plan use local/some-action my-project
agents plan execute <PLAN_ID>
agents plan apply --yes --format json <PLAN_ID>
# Observe: output is plan state dict, not spec envelope

Impact

Any tooling or scripting that parses agents plan apply --format json output will fail because the expected command, status, data.artifacts, data.changes, data.lifecycle fields are absent.

Fix Suggestion

Introduce an _apply_output_dict(plan, started_at, duration_ms) helper analogous to _execute_output_dict() that builds the spec-required envelope, and call it from both lifecycle_apply_plan and _lifecycle_apply_with_id for non-rich formats.


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

## Bug Report **Feature Area:** Plan execution and apply phase **Command:** `agents plan apply --format json` / `agents plan apply --format yaml` ### What Was Tested The JSON/YAML output format of `agents plan apply` when using `--format json` or `--format yaml`. ### Expected Behavior (from spec §agents plan apply) The spec defines a structured output envelope for `agents plan apply --format json`: ```json { "command": "plan apply", "status": "ok", "exit_code": 0, "data": { "plan_id": "01HXM8C2ZK4Q7C2B3F2R4VYV6J", "artifacts": 6, "changes": { "insertions": 42, "deletions": 9 }, "project": "local/api-service", "applied_at": "2026-02-08T13:04:00Z", "validation": { ... }, "sandbox_cleanup": { ... }, "lifecycle": { "phase": "apply", "state": "applied", "total_duration": "00:06:14", "total_cost": "$0.0847", "decisions_made": 8, "child_plans": 2 } }, "timing": { "started": "...", "duration_ms": 1250 }, "messages": ["Changes applied"] } ``` ### Actual Behavior (from code analysis) **File:** `src/cleveragents/cli/commands/plan.py`, lines 2270–2272 and 1119–1121 Both the `lifecycle_apply_plan` command and the `_lifecycle_apply_with_id` helper use `_plan_spec_dict(plan)` for non-rich output: ```python # lifecycle_apply_plan (line 2270-2272) if fmt != OutputFormat.RICH.value: data = _plan_spec_dict(plan) console.print(format_output(data, fmt)) # _lifecycle_apply_with_id (line 1119-1121) if fmt != OutputFormat.RICH.value: data = _plan_spec_dict(plan) console.print(format_output(data, fmt)) ``` `_plan_spec_dict(plan)` returns the plan's internal state fields (`plan_id`, `phase`, `processing_state`, `project_links`, `arguments`, etc.) — **not** the spec-required apply output envelope with `command`, `status`, `exit_code`, `data`, `timing`, and `messages` keys. The actual JSON output looks like: ```json { "plan_id": "01HXM8C2ZK4Q7C2B3F2R4VYV6J", "namespaced_name": "local/my-action", "phase": "apply", "processing_state": "applied", "state": "applied", "project_links": [...], ... } ``` This is missing: - The `command: "plan apply"` envelope key - The `status: "ok"` / `exit_code: 0` fields - The `data.artifacts` count - The `data.changes.insertions` / `data.changes.deletions` counts - The `data.project` field - The `data.applied_at` timestamp - The `data.validation` section - The `data.sandbox_cleanup` section - The `data.lifecycle.total_duration`, `total_cost`, `decisions_made`, `child_plans` fields - The `timing` section - The `messages` array ### Code Location - `src/cleveragents/cli/commands/plan.py`: - `lifecycle_apply_plan()` function, lines 2270–2272 - `_lifecycle_apply_with_id()` function, lines 1119–1121 ### Steps to Reproduce ```bash agents plan use local/some-action my-project agents plan execute <PLAN_ID> agents plan apply --yes --format json <PLAN_ID> # Observe: output is plan state dict, not spec envelope ``` ### Impact Any tooling or scripting that parses `agents plan apply --format json` output will fail because the expected `command`, `status`, `data.artifacts`, `data.changes`, `data.lifecycle` fields are absent. ### Fix Suggestion Introduce an `_apply_output_dict(plan, started_at, duration_ms)` helper analogous to `_execute_output_dict()` that builds the spec-required envelope, and call it from both `lifecycle_apply_plan` and `_lifecycle_apply_with_id` for non-rich formats. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Medium — spec compliance bug identified by UAT testing
  • Story Points: 3 (M) — targeted fix to align implementation with spec
  • MoSCoW: Must Have — spec compliance is required for correct system behavior

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

Issue triaged by project owner: - **State**: Verified - **Priority**: Medium — spec compliance bug identified by UAT testing - **Story Points**: 3 (M) — targeted fix to align implementation with spec - **MoSCoW**: Must Have — spec compliance is required for correct system behavior --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner
HAL9000 added this to the v3.5.0 milestone 2026-04-09 03:06:13 +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#4715
No description provided.