Skip to content

feat: group all concatenations in "Create prompt with built-in context" into a single section#23588

Merged
pelikhan merged 1 commit intomainfrom
copilot/update-compiler-concatenations
Mar 30, 2026
Merged

feat: group all concatenations in "Create prompt with built-in context" into a single section#23588
pelikhan merged 1 commit intomainfrom
copilot/update-compiler-concatenations

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 30, 2026

Summary

Updates the compiler to group all concatenations in the "Create prompt with built-in context" step into as few heredoc blocks as possible, minimizing the number of lines that change in compiled lock file diffs when a workflow's prompt changes.

Problem

Each cat << 'DELIMITER'...DELIMITER heredoc block contributes two lines containing the hash-based delimiter. Since the delimiter is derived from the workflow's frontmatter hash, it changes whenever the user edits their workflow. With many separate blocks, a small prompt change could cause dozens of delimiter lines to appear in the diff — noise that makes code review harder.

Before (4 blocks for a workflow with </system> + 2 runtime-import macros):

cat << 'GH_AW_PROMPT_abc_EOF'
</system>
GH_AW_PROMPT_abc_EOF
cat << 'GH_AW_PROMPT_abc_EOF'
{{#runtime-import shared/reporting.md}}
GH_AW_PROMPT_abc_EOF
cat << 'GH_AW_PROMPT_abc_EOF'
{{#runtime-import auto-triage-issues.md}}
GH_AW_PROMPT_abc_EOF

After (1 block for all of the above):

cat << 'GH_AW_PROMPT_abc_EOF'
</system>
{{#runtime-import shared/reporting.md}}
{{#runtime-import auto-triage-issues.md}}
GH_AW_PROMPT_abc_EOF

Changes

  • pkg/workflow/unified_prompt_step.go: Refactored generateUnifiedPromptCreationStep:

    • Defer the <system> opening tag: write it as the first line of the first inline section's heredoc (when the first section is inline), rather than always as its own standalone block
    • Merge </system> into the already-open heredoc (if any after inline built-in sections), or start a new heredoc that stays open for user content — so </system> and all user prompt content land in the same block
    • Keep one heredoc open across all user prompt chunks and runtime-import macros instead of creating a separate block per chunk
  • Test updates in unified_prompt_creation_test.go and xml_comments_test.go to reflect the new consolidated structure

  • Golden file regeneration in testdata/wasm_golden/

  • Lock file recompilation: all 178 .lock.yml files updated (net ~900 lines removed)

Copilot AI requested a review from pelikhan March 30, 2026 20:58
@pelikhan pelikhan marked this pull request as ready for review March 30, 2026 20:58
Copilot AI review requested due to automatic review settings March 30, 2026 20:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors unified prompt generation to keep heredoc blocks open across adjacent prompt content (including runtime-import macros) so compiled .lock.yml diffs contain far fewer hash-delimiter lines when prompts change.

Changes:

  • Refactored generateUnifiedPromptCreationStep to defer <system> opening and merge </system> + user prompt content into fewer heredoc blocks.
  • Updated unit tests and regenerated wasm golden fixtures to match the new consolidated output structure.
  • Recompiled workflow lock files to reflect the new heredoc grouping.

Reviewed changes

Copilot reviewed 183 out of 183 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/workflow/unified_prompt_step.go Consolidates prompt concatenation into fewer heredoc blocks by deferring <system> and keeping a single heredoc open across user chunks/macros.
pkg/workflow/unified_prompt_creation_test.go Updates delimiter-count expectations to reflect the new merged heredoc structure.
pkg/workflow/xml_comments_test.go Adjusts long-workflow assertions after heredoc consolidation changes.
pkg/workflow/testdata/wasm_golden/TestWasmGolden_CompileFixtures/with-imports.golden Updates golden output showing runtime-import lines merged into the </system> heredoc block.
pkg/workflow/testdata/wasm_golden/TestWasmGolden_CompileFixtures/basic-copilot.golden Updates golden output showing user prompt merged into the </system> heredoc block.
.github/workflows/*.lock.yml (178 files) Regenerated compiled workflow lock files to reduce delimiter-line churn by consolidating heredoc blocks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +391 to +398
// Long workflow (with imports) should be inlined into a single consolidated heredoc block.
// The compiler groups all user prompt chunks into the same heredoc to minimise the number
// of delimiter lines that change in the diff when content changes.
// Verify this by checking that the long workflow's run section is larger than the normal
// workflow's (which uses a compact runtime-import macro instead of inlining the full text).
if len(lockString) <= len(normalLockString) {
t.Errorf("Expected long workflow lock file to be larger than normal (normal=%d bytes, long=%d bytes)", len(normalLockString), len(lockString))
}
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new assertion compares len(lockString) vs len(normalLockString), which doesn’t actually verify the intended heredoc consolidation behavior (and the preceding comment about a “single consolidated heredoc block” is misleading since the lock file still contains multiple heredocs for built-in inline sections like GitHub context). Consider asserting on the number/placement of cat << 'GH_AW_PROMPT_…_EOF' blocks in the long workflow’s prompt creation step (e.g., that </system> and subsequent user/runtime-import content are emitted in a single heredoc) rather than relying on file size differences.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown
Contributor

Hey @Copilot 👋 — great work on this compiler optimization! Consolidating all the cat << 'DELIMITER' heredoc blocks in the "Create prompt with built-in context" step into as few blocks as possible is a clean and well-reasoned improvement — it directly reduces noisy diff churn in .lock.yml files whenever a workflow's prompt changes.

This PR is well-aligned with the project's guidelines and quality standards: it's focused on a single compiler concern, ships with updated tests in unified_prompt_creation_test.go and xml_comments_test.go, includes comprehensive golden file and lock file regeneration, and has a thorough description explaining the problem and the approach.

✅ The PR looks ready for maintainer review. No further changes needed from a contribution-guidelines standpoint.

Generated by Contribution Check ·

@github-actions github-actions bot added the lgtm label Mar 30, 2026
@pelikhan pelikhan merged commit 47aa280 into main Mar 30, 2026
159 checks passed
@pelikhan pelikhan deleted the copilot/update-compiler-concatenations branch March 30, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants