diff --git a/tasks/orchestrate.py b/tasks/orchestrate.py index f181ba6..5d1446a 100644 --- a/tasks/orchestrate.py +++ b/tasks/orchestrate.py @@ -296,11 +296,22 @@ def run_recipe( logger.info(f"Generated plan with {len(plan.steps)} steps") - # Save plan for debugging + # Save plan as S-expression (content-addressed by plan_id hash) PLAN_CACHE_DIR.mkdir(parents=True, exist_ok=True) - plan_path = PLAN_CACHE_DIR / f"{plan.plan_id}.json" - with open(plan_path, "w") as f: - f.write(plan.to_json()) + plan_sexp_path = PLAN_CACHE_DIR / f"{plan.plan_id}.sexp" + if hasattr(plan, 'to_sexp_string'): + with open(plan_sexp_path, "w") as f: + f.write(plan.to_sexp_string()) + else: + # Fallback to JSON for legacy plans + plan_json_path = PLAN_CACHE_DIR / f"{plan.plan_id}.json" + with open(plan_json_path, "w") as f: + f.write(plan.to_json()) + + # Also save a reference by run_id for easy lookup + run_plan_path = PLAN_CACHE_DIR / f"{run_id}.sexp" + if plan_sexp_path.exists(): + run_plan_path.write_text(plan_sexp_path.read_text()) # Phase 3: Execute logger.info("Phase 3: Executing plan...")