Skip to content

fix(orchestrator): deduplicate '## Plan' heading in PR body#6

Open
Maxtanh-Meta wants to merge 1 commit into
logosc:mainfrom
Maxtanh-Meta:navi/fix/duplicate-plan-heading
Open

fix(orchestrator): deduplicate '## Plan' heading in PR body#6
Maxtanh-Meta wants to merge 1 commit into
logosc:mainfrom
Maxtanh-Meta:navi/fix/duplicate-plan-heading

Conversation

@Maxtanh-Meta

Copy link
Copy Markdown

Problem

buildPRBody unconditionally prepends a ## Plan heading before inserting job.PlanText. However, the planning agent's output often already starts with its own ## Plan heading (since the prompt says "any structure you like"). This produces PR descriptions with a duplicate ## Plan heading — the first one containing all the plan content, and the second one empty right before ## Validation.

Example: https://github.com/Maxtanh-Meta/one-minute-games/pull/39

Fix

Check if PlanText already starts with ## Plan before adding one. If the agent included the heading, we skip ours; if not, we add it as before.

Test

Added TestBuildPRBodyNoDuplicatePlanHeading covering both cases (agent includes heading vs. doesn't).

buildPRBody unconditionally prepended '## Plan' before job.PlanText,
but the planning agent often includes its own '## Plan' heading in the
markdown output. This resulted in duplicate headings in PR descriptions.

Now checks if PlanText already starts with '## Plan' before adding one.
@Maxtanh-Meta

Copy link
Copy Markdown
Author

Code Review (via Codex)

Overall: Approve with minor suggestion

Main Concern

strings.HasPrefix(planText, "## Plan") is a loose prefix match — it also matches headings like ## Planning, ## Planet scale concerns, etc. Those would incorrectly skip adding the canonical ## Plan heading, producing a PR body missing its expected top-level section.

Suggested fix: tighten the check to an exact heading boundary:

if !strings.HasPrefix(planText, "## Plan\n") && planText != "## Plan" {
    b.WriteString("## Plan\n\n")
}

Additional Notes

  • Whitespace-only PlanText: A value like " \n" still passes the != "" guard and would emit an empty ## Plan section. Since TrimSpace is already computed, consider skipping the section when trimmed text is empty.
  • Test looseness: strings.Count(body, "## Plan") counts substrings inside ## Planning too. Prefer checking exact heading lines.
  • Suggested test case: Add a case for "## Planning\n..." to verify the canonical heading is still added.

Verdict

The fix is correct for the common case and the tests cover the main regression well. Just needs the prefix match tightened. 👍

Maxtanh-Meta added a commit to Maxtanh-Meta/symphony-go that referenced this pull request May 19, 2026
fix(orchestrator): use worktree repo path for plan reviewer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant