Refactor Plan errors

Errors in the refactor plan feature fall into two categories: failures during workflow execution (orchestrating the three subagents and synthesizing their output) and failures during report formatting (converting the raw result into a human-readable report).

Common error signatures

Errors most commonly appear in these forms:

Where errors originate

How to diagnose

  1. Read the traceback call stack top-to-bottom. Identify whether the raise site is in refactor_plan.py (workflow/subagent layer) or refactor_plan_report.py (formatting layer). That tells you which half of the pipeline failed.

  2. Check the exception type at the raise site.

    • A KeyError in format_refactor_plan_report() means result is missing a key the formatter expects — inspect the dict returned by execute() to see what sections are present.
    • A TypeError in format_refactor_plan_report() often means result or input_data is None, which points back to execute() returning an empty or failed WorkflowResult.
    • An OSError or FileNotFoundError in execute() means the path passed to the workflow does not exist or is not readable.
  3. Inspect the result dict before formatting. If you can reproduce the failure, print or log the value of result after execute() returns and before passing it to format_refactor_plan_report(). The three expected top-level sections are Summary, Refactoring, and Suggestions — a missing section identifies which subagent (debt-scanner, impact-analyzer, or plan-generator) did not complete successfully.

  4. Verify the path argument. The _TASK_PROMPT_TEMPLATE requires a {path} value. If main() is the entry point, confirm the path argument was supplied and points to a readable file or directory.

Source files

Tags: refactor, tech-debt, complexity