Bug: agents plan correct --mode=revert CLI output omits re-execution metadata (phase_transition_target, checkpoint_restored, actor_state_ref, user_intervention_decision_id) #10246

Open
opened 2026-04-17 10:34:07 +00:00 by HAL9000 · 0 comments
Owner

Metadata

  • Commit Message: fix(plan-correct): expose revert re-execution metadata fields in CLI output
  • Branch: fix/plan-correct-revert-output-metadata

Background and Context

The agents plan correct --mode=revert command is specified (v3.2.0 §Correction Flow, Revert Mode) to signal re-execution from the targeted decision point. The service layer (CorrectionService.execute_revert()) correctly computes and returns four re-execution metadata fields in CorrectionResult:

  • phase_transition_target — signals that the plan should re-enter Strategize phase ("strategize")
  • checkpoint_restored — whether sandbox checkpoint was restored (bool)
  • actor_state_ref — LangGraph actor checkpoint reference for reasoning rollback
  • user_intervention_decision_id — ULID of the user_intervention decision

However, the CLI handler (correct_decision function in src/cleveragents/cli/commands/plan.py, ~line 3698) only includes correction_id, status, mode, new_decisions, and reverted_decisions in its JSON output envelope. The four re-execution metadata fields are silently discarded.

This means callers of agents plan correct --mode=revert --format json cannot determine:

  1. Whether a phase transition to Strategize was signalled
  2. Whether a sandbox checkpoint was restored
  3. What actor state reference to use for reasoning rollback
  4. What user_intervention decision ID was created

TDD Testing Issue: #10236

Current Behavior

$ agents plan correct DEC-001 --mode=revert --format json
{
  "correction_id": "01HXYZ...",
  "status": "applied",
  "mode": "revert",
  "new_decisions": [],
  "reverted_decisions": ["DEC-001", "DEC-002"]
}

The phase_transition_target, checkpoint_restored, actor_state_ref, and user_intervention_decision_id fields are absent from the output.

Expected Behavior

Per spec v3.2.0 §Correction Flow (Revert Mode), the JSON output should include all re-execution metadata:

{
  "correction_id": "01HXYZ...",
  "status": "applied",
  "mode": "revert",
  "new_decisions": [],
  "reverted_decisions": ["DEC-001", "DEC-002"],
  "phase_transition_target": "strategize",
  "checkpoint_restored": false,
  "actor_state_ref": "",
  "user_intervention_decision_id": "01HABC..."
}

Acceptance Criteria

  • agents plan correct --mode=revert --format json output includes phase_transition_target field
  • agents plan correct --mode=revert --format json output includes checkpoint_restored field
  • agents plan correct --mode=revert --format json output includes actor_state_ref field
  • agents plan correct --mode=revert --format json output includes user_intervention_decision_id field
  • Rich output (--format rich) displays phase_transition_target when non-empty
  • All existing tests continue to pass
  • Coverage >= 97%

Supporting Information

  • Spec: v3.2.0 §Correction Flow (Revert Mode) — "Phase transition: signals that the plan should re-enter the Strategize phase from the corrected decision point"
  • CLI source: src/cleveragents/cli/commands/plan.py correct_decision function ~line 3698 — JSON dict only has 5 keys, missing the 4 re-execution fields
  • Service source: src/cleveragents/application/services/correction_service.py execute_revert() ~line 518 — correctly sets phase_transition_target="strategize", checkpoint_restored, actor_state_ref, user_intervention_decision_id
  • Model source: src/cleveragents/domain/models/core/correction.py CorrectionResult — all 4 fields defined with proper defaults
  • TDD Testing Issue: #10236

Subtasks

  • Update correct_decision in src/cleveragents/cli/commands/plan.py to include phase_transition_target, checkpoint_restored, actor_state_ref, user_intervention_decision_id in JSON output dict
  • Update rich output rendering to display phase_transition_target when non-empty (e.g., "Phase transition → strategize")
  • Add/update Behave scenarios in features/plan_correct_tree_wiring.feature or a new feature file to assert the new fields appear in output
  • Implement step definitions for new assertions
  • Verify the @tdd_expected_fail scenario in #10236 now passes (remove @tdd_expected_fail tag)
  • Verify coverage >= 97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional details.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
  • The TDD testing issue #10236 is resolved (its @tdd_expected_fail scenario now passes).

Automated by CleverAgents Bot
Supervisor: UAT Test Pool | Agent: uat-test-pool-supervisor

## Metadata - **Commit Message**: `fix(plan-correct): expose revert re-execution metadata fields in CLI output` - **Branch**: `fix/plan-correct-revert-output-metadata` ## Background and Context The `agents plan correct --mode=revert` command is specified (v3.2.0 §Correction Flow, Revert Mode) to signal re-execution from the targeted decision point. The service layer (`CorrectionService.execute_revert()`) correctly computes and returns four re-execution metadata fields in `CorrectionResult`: - `phase_transition_target` — signals that the plan should re-enter Strategize phase ("strategize") - `checkpoint_restored` — whether sandbox checkpoint was restored (bool) - `actor_state_ref` — LangGraph actor checkpoint reference for reasoning rollback - `user_intervention_decision_id` — ULID of the user_intervention decision However, the CLI handler (`correct_decision` function in `src/cleveragents/cli/commands/plan.py`, ~line 3698) only includes `correction_id`, `status`, `mode`, `new_decisions`, and `reverted_decisions` in its JSON output envelope. The four re-execution metadata fields are silently discarded. This means callers of `agents plan correct --mode=revert --format json` cannot determine: 1. Whether a phase transition to Strategize was signalled 2. Whether a sandbox checkpoint was restored 3. What actor state reference to use for reasoning rollback 4. What user_intervention decision ID was created **TDD Testing Issue**: #10236 ## Current Behavior ```bash $ agents plan correct DEC-001 --mode=revert --format json { "correction_id": "01HXYZ...", "status": "applied", "mode": "revert", "new_decisions": [], "reverted_decisions": ["DEC-001", "DEC-002"] } ``` The `phase_transition_target`, `checkpoint_restored`, `actor_state_ref`, and `user_intervention_decision_id` fields are absent from the output. ## Expected Behavior Per spec v3.2.0 §Correction Flow (Revert Mode), the JSON output should include all re-execution metadata: ```json { "correction_id": "01HXYZ...", "status": "applied", "mode": "revert", "new_decisions": [], "reverted_decisions": ["DEC-001", "DEC-002"], "phase_transition_target": "strategize", "checkpoint_restored": false, "actor_state_ref": "", "user_intervention_decision_id": "01HABC..." } ``` ## Acceptance Criteria - `agents plan correct --mode=revert --format json` output includes `phase_transition_target` field - `agents plan correct --mode=revert --format json` output includes `checkpoint_restored` field - `agents plan correct --mode=revert --format json` output includes `actor_state_ref` field - `agents plan correct --mode=revert --format json` output includes `user_intervention_decision_id` field - Rich output (`--format rich`) displays `phase_transition_target` when non-empty - All existing tests continue to pass - Coverage >= 97% ## Supporting Information - **Spec**: v3.2.0 §Correction Flow (Revert Mode) — "Phase transition: signals that the plan should re-enter the Strategize phase from the corrected decision point" - **CLI source**: `src/cleveragents/cli/commands/plan.py` `correct_decision` function ~line 3698 — JSON dict only has 5 keys, missing the 4 re-execution fields - **Service source**: `src/cleveragents/application/services/correction_service.py` `execute_revert()` ~line 518 — correctly sets `phase_transition_target="strategize"`, `checkpoint_restored`, `actor_state_ref`, `user_intervention_decision_id` - **Model source**: `src/cleveragents/domain/models/core/correction.py` `CorrectionResult` — all 4 fields defined with proper defaults - **TDD Testing Issue**: #10236 ## Subtasks - [ ] Update `correct_decision` in `src/cleveragents/cli/commands/plan.py` to include `phase_transition_target`, `checkpoint_restored`, `actor_state_ref`, `user_intervention_decision_id` in JSON output dict - [ ] Update rich output rendering to display `phase_transition_target` when non-empty (e.g., "Phase transition → strategize") - [ ] Add/update Behave scenarios in `features/plan_correct_tree_wiring.feature` or a new feature file to assert the new fields appear in output - [ ] Implement step definitions for new assertions - [ ] Verify the `@tdd_expected_fail` scenario in #10236 now passes (remove `@tdd_expected_fail` tag) - [ ] Verify coverage >= 97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional details. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. - The TDD testing issue #10236 is resolved (its `@tdd_expected_fail` scenario now passes). --- **Automated by CleverAgents Bot** Supervisor: UAT Test Pool | Agent: uat-test-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#10246
No description provided.