Summary
Within a single orchestration iteration, the coordinator's planning artifacts (planning.prompt.txt and planning.response.txt) are overwritten when the post-execution continuation call invokes plan_with_routing(). This means the initial planning prompt/response that created the plan is lost, replaced by the post-execution decision prompt/response.
Root Cause
ExecutionPersistence::write_planning_phase() (persistence.rs:510-522) always writes to fixed filenames:
fs::write(iter_path.join("planning.prompt.txt"), prompt).await?;
fs::write(iter_path.join("planning.response.txt"), response).await?;
plan_with_routing() calls write_planning_phase() every time it runs (orchestrator.rs:1362-1367 and orchestrator.rs:1404-1411). In the normal flow, plan_with_routing() is called at least twice per iteration:
- Initial planning — coordinator receives the user query and produces a
StepsPlan (or Direct/Clarification). This writes planning.prompt.txt and planning.response.txt.
- Post-execution decision (
orchestrator.rs:3583-3591) — after workers finish, the coordinator is called again with a continuation prompt to decide what to do with results (respond directly, replan, or clarify). This overwrites the same files.
The post-execution call passes Some(&post_execute_ctx) which builds a continuation prompt via build_continuation_wrapper(), so the overwritten content is the continuation prompt, not the original plan-creation prompt.
Evidence
From a production run (019e84d0-58f4-7d31-8522-7ded1d971ffa), the persisted planning.prompt.txt begins with:
ITERATION 1 of 2 (FINAL ATTEMPT)
Goal: Review available incident/channel context...
Outcome: 1 of 1 tasks succeeded.
COMPLETED TASKS:
This is the continuation prompt, not the initial planning prompt. The initial planning prompt that produced the plan is lost.
Impact
- Debugging: Cannot reconstruct what the coordinator saw when it originally created the plan. Only the post-execution decision prompt survives.
- Replanning: Same issue compounds — each replan cycle overwrites the previous planning artifacts for that iteration.
- The
plan.json artifact is fine (written separately by write_plan()), so the plan content survives, but the prompt/response that produced it does not.
Suggested Fix
Number planning phases within an iteration, e.g.:
iteration-1/planning.0.prompt.txt # initial plan creation
iteration-1/planning.0.response.txt
iteration-1/planning.1.prompt.txt # post-execution decision
iteration-1/planning.1.response.txt
This could be a simple counter on ExecutionPersistence that increments each time write_planning_phase() is called, resetting on start_new_iteration().
Summary
Within a single orchestration iteration, the coordinator's planning artifacts (
planning.prompt.txtandplanning.response.txt) are overwritten when the post-execution continuation call invokesplan_with_routing(). This means the initial planning prompt/response that created the plan is lost, replaced by the post-execution decision prompt/response.Root Cause
ExecutionPersistence::write_planning_phase()(persistence.rs:510-522) always writes to fixed filenames:plan_with_routing()callswrite_planning_phase()every time it runs (orchestrator.rs:1362-1367andorchestrator.rs:1404-1411). In the normal flow,plan_with_routing()is called at least twice per iteration:StepsPlan(orDirect/Clarification). This writesplanning.prompt.txtandplanning.response.txt.orchestrator.rs:3583-3591) — after workers finish, the coordinator is called again with a continuation prompt to decide what to do with results (respond directly, replan, or clarify). This overwrites the same files.The post-execution call passes
Some(&post_execute_ctx)which builds a continuation prompt viabuild_continuation_wrapper(), so the overwritten content is the continuation prompt, not the original plan-creation prompt.Evidence
From a production run (
019e84d0-58f4-7d31-8522-7ded1d971ffa), the persistedplanning.prompt.txtbegins with:This is the continuation prompt, not the initial planning prompt. The initial planning prompt that produced the plan is lost.
Impact
plan.jsonartifact is fine (written separately bywrite_plan()), so the plan content survives, but the prompt/response that produced it does not.Suggested Fix
Number planning phases within an iteration, e.g.:
This could be a simple counter on
ExecutionPersistencethat increments each timewrite_planning_phase()is called, resetting onstart_new_iteration().