diff --git a/.agents/skills/lib_py/loop/runner.py b/.agents/skills/lib_py/loop/runner.py index 391313e..8de3938 100644 --- a/.agents/skills/lib_py/loop/runner.py +++ b/.agents/skills/lib_py/loop/runner.py @@ -1017,7 +1017,13 @@ class LoopRunner: if not p_file or not p_file.exists(): log_error("Final plan file not found.") return 1 - self.current_plan = p_file.read_text(encoding="utf-8", errors="replace") + plan_text = self._plan_text(p_file) + if plan_text is None: + # D13: the run paid for a planning phase and got nothing back. + # Falling through would silently demote it to self-planning. + log_error(f"the planner's report has no plan text: {p_file}") + return 1 + self.current_plan = plan_text # Interactive turns creator_type = self.resolve_agent_type(self.creator, state) @@ -1040,8 +1046,13 @@ class LoopRunner: return 1 ref_file = self.find_report(ref_jid) - if ref_file and ref_file.exists(): - self.current_plan = ref_file.read_text(encoding="utf-8", errors="replace") + refined = self._plan_text(ref_file) if ref_file else None + if refined is None: + # D14: overwriting with an empty report loses a plan that is + # still good, and Phase 2 would quietly switch prompts. + log_warn(f"the refine report has no plan text (job {ref_jid}); keeping the previous plan.") + else: + self.current_plan = refined log_success("Interactive planning completed. Plan finalized.") else: @@ -1265,8 +1276,14 @@ class LoopRunner: log_error("Failed to register plan refinement job.") return 1 ref_file = self.find_report(ref_jid) - if ref_file and ref_file.exists(): - self.current_plan = ref_file.read_text(encoding="utf-8", errors="replace") + refined = self._plan_text(ref_file) if ref_file else None + if refined is None: + log_warn(f"the refine report has no plan text (job {ref_jid}); keeping the previous plan.") + else: + self.current_plan = refined + # D13 stops a plan-mode run whose initial plan is empty and D14 + # never overwrites with an empty one, so current_plan is not + # empty here: this prompt cannot claim a plan it does not carry. correction_prompt = f"갱신된 다음 계획서에 입각하여 지적된 오류들을 수정하고 코드를 다시 구현해주세요. 계획서:\n{self.current_plan}\n피드백 상세:\n{feedback_aggregate}" else: log_info("Applying straight bugfixes based on reviewer feedback...")