Skip to content

orchestration: planning artifacts overwritten by post-execution coordinator call #183

Description

@teriyakichild

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:

  1. Initial planning — coordinator receives the user query and produces a StepsPlan (or Direct/Clarification). This writes planning.prompt.txt and planning.response.txt.
  2. 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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions