UAT: agents plan tree --format json output missing spec envelope and nested tree structure #5040

Closed
opened 2026-04-09 00:50:11 +00:00 by HAL9000 · 1 comment
Owner

Bug Report

Feature Area: Plan Lifecycle — agents plan tree

Summary

agents plan tree <PLAN_ID> --format json returns a flat list of tree node dicts instead of the spec-required JSON envelope with a nested tree structure, summary, child_plans, and decision_ids sections.

Expected Behavior (from spec)

Per docs/specification.md §agents plan tree, the JSON output must be:

{
  "command": "plan tree",
  "status": "ok",
  "exit_code": 0,
  "data": {
    "plan_id": "01HXM8C2ZK4Q7C2B3F2R4VYV6J",
    "tree": {
      "type": "prompt_definition",
      "description": "Increase test coverage to 85%",
      "children": [
        { "type": "invariant_enforced", "description": "..." },
        { "type": "strategy_choice", "description": "...", "confidence": 0.82 },
        {
          "type": "subplan_parallel_spawn",
          "description": "...",
          "children": [
            { "type": "subplan_spawn", "description": "...", "plan_id": "01HXM9F1A" }
          ]
        }
      ]
    },
    "summary": {
      "nodes": 9,
      "depth": 3,
      "child_plans": "2+",
      "invariants": 2,
      "superseded": 0
    },
    "child_plans": [
      { "id": "01HXM9F1A", "phase": "execute", "state": "processing" }
    ],
    "decision_ids": {
      "root": "01HXM9A0B1Q2W3R5G8Z0P4Q1X8",
      "strategy": "01HXM9A1C2Q7W3R5G8Z0P4Q1X9"
    }
  },
  "timing": { "started": "2026-02-08T12:58:00Z", "duration_ms": 85 },
  "messages": ["Decision tree rendered"]
}

Key aspects of the spec's JSON tree structure:

  • data.tree is a nested structure (root node with children arrays)
  • Each node has type, description, and optionally confidence and plan_id
  • data.summary provides aggregate statistics
  • data.child_plans lists spawned child plans with their current status
  • data.decision_ids provides a named map of key decision IDs for correction

Actual Behavior

In src/cleveragents/cli/commands/plan.py, the tree_decisions_cmd command (lines 3994–4121) calls build_decision_tree() which returns a list of node dicts, then passes it directly to format_output. This produces:

  1. No top-level envelope: No command, status, exit_code, timing, messages fields — just a bare JSON array
  2. Different node structure: Nodes have decision_id, type, sequence, question, chosen, confidence, superseded, children — not the spec's type, description, confidence, plan_id
  3. No data.summary section: Missing node count, depth, child_plans count, invariants count, superseded count
  4. No data.child_plans section: Missing child plan status information
  5. No data.decision_ids section: Missing the named map of key decision IDs for correction

The spec's tree node uses description (the chosen option text) while the implementation uses question and chosen as separate fields. The spec's type field matches, but the spec uses human-readable type names while the implementation uses the raw enum value.

Code Location

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

  • tree_decisions_cmd function (lines 3994–4121)
  • build_decision_tree function (lines 3918–3991)

Impact

Programmatic consumers of agents plan tree --format json receive a non-spec-compliant response. The missing decision_ids section is particularly impactful as it's the primary way users discover decision IDs for use with agents plan correct.


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

## Bug Report **Feature Area:** Plan Lifecycle — `agents plan tree` ### Summary `agents plan tree <PLAN_ID> --format json` returns a flat list of tree node dicts instead of the spec-required JSON envelope with a nested tree structure, summary, child_plans, and decision_ids sections. ### Expected Behavior (from spec) Per `docs/specification.md` §agents plan tree, the JSON output must be: ```json { "command": "plan tree", "status": "ok", "exit_code": 0, "data": { "plan_id": "01HXM8C2ZK4Q7C2B3F2R4VYV6J", "tree": { "type": "prompt_definition", "description": "Increase test coverage to 85%", "children": [ { "type": "invariant_enforced", "description": "..." }, { "type": "strategy_choice", "description": "...", "confidence": 0.82 }, { "type": "subplan_parallel_spawn", "description": "...", "children": [ { "type": "subplan_spawn", "description": "...", "plan_id": "01HXM9F1A" } ] } ] }, "summary": { "nodes": 9, "depth": 3, "child_plans": "2+", "invariants": 2, "superseded": 0 }, "child_plans": [ { "id": "01HXM9F1A", "phase": "execute", "state": "processing" } ], "decision_ids": { "root": "01HXM9A0B1Q2W3R5G8Z0P4Q1X8", "strategy": "01HXM9A1C2Q7W3R5G8Z0P4Q1X9" } }, "timing": { "started": "2026-02-08T12:58:00Z", "duration_ms": 85 }, "messages": ["Decision tree rendered"] } ``` Key aspects of the spec's JSON tree structure: - `data.tree` is a **nested** structure (root node with `children` arrays) - Each node has `type`, `description`, and optionally `confidence` and `plan_id` - `data.summary` provides aggregate statistics - `data.child_plans` lists spawned child plans with their current status - `data.decision_ids` provides a named map of key decision IDs for correction ### Actual Behavior In `src/cleveragents/cli/commands/plan.py`, the `tree_decisions_cmd` command (lines 3994–4121) calls `build_decision_tree()` which returns a list of node dicts, then passes it directly to `format_output`. This produces: 1. **No top-level envelope**: No `command`, `status`, `exit_code`, `timing`, `messages` fields — just a bare JSON array 2. **Different node structure**: Nodes have `decision_id`, `type`, `sequence`, `question`, `chosen`, `confidence`, `superseded`, `children` — not the spec's `type`, `description`, `confidence`, `plan_id` 3. **No `data.summary` section**: Missing node count, depth, child_plans count, invariants count, superseded count 4. **No `data.child_plans` section**: Missing child plan status information 5. **No `data.decision_ids` section**: Missing the named map of key decision IDs for correction The spec's tree node uses `description` (the chosen option text) while the implementation uses `question` and `chosen` as separate fields. The spec's `type` field matches, but the spec uses human-readable type names while the implementation uses the raw enum value. ### Code Location `src/cleveragents/cli/commands/plan.py`: - `tree_decisions_cmd` function (lines 3994–4121) - `build_decision_tree` function (lines 3918–3991) ### Impact Programmatic consumers of `agents plan tree --format json` receive a non-spec-compliant response. The missing `decision_ids` section is particularly impactful as it's the primary way users discover decision IDs for use with `agents plan correct`. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
Author
Owner

Closing as duplicate of #4974 — both issues report the same problem: agents plan tree --format json output missing spec-required envelope.


Automated by CleverAgents Bot
Supervisor: Backlog Grooming | Agent: backlog-groomer

Closing as duplicate of #4974 — both issues report the same problem: `agents plan tree --format json` output missing spec-required envelope. --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: backlog-groomer
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#5040
No description provided.