Skip to content

Sort environment variables alphabetically in unified prompt step#10361

Merged
pelikhan merged 3 commits intomainfrom
copilot/sort-environment-variable-names
Jan 16, 2026
Merged

Sort environment variables alphabetically in unified prompt step#10361
pelikhan merged 3 commits intomainfrom
copilot/sort-environment-variable-names

Conversation

Copy link
Contributor

Copilot AI commented Jan 16, 2026

Environment variables in the "Append context instructions to prompt" step were appearing in non-deterministic order due to Go map iteration.

Changes

  • pkg/workflow/unified_prompt_step.go: Sort environment variable keys alphabetically before output

    • Collect keys into slice, sort with sort.Strings(), iterate in order
    • Ensures consistent ordering: GH_AW_GITHUB_ACTOR, GH_AW_GITHUB_EVENT_*, etc.
  • pkg/workflow/unified_prompt_step_test.go: Add TestGenerateUnifiedPromptStep_EnvVarsSorted to verify sorting

  • 109 workflow lock files: Recompiled with sorted environment variables

Example

- name: Append context instructions to prompt
  env:
    GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
    GH_AW_GITHUB_ACTOR: ${{ github.actor }}
    GH_AW_GITHUB_EVENT_COMMENT_ID: ${{ github.event.comment.id }}
    GH_AW_GITHUB_EVENT_DISCUSSION_NUMBER: ${{ github.event.discussion.number }}
    GH_AW_GITHUB_EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }}
    # ... (sorted alphabetically)
Original prompt

The environment variable names in "Append context instructions to prompt" need to be sorted.

 - name: Append context instructions to prompt
        env:
          GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
          GH_AW_GITHUB_REPOSITORY: ${{ github.repository }}
          GH_AW_GITHUB_RUN_ID: ${{ github.run_id }}
          GH_AW_GITHUB_WORKSPACE: ${{ github.workspace }}
          GH_AW_GITHUB_ACTOR: ${{ github.actor }}
          GH_AW_GITHUB_EVENT_COMMENT_ID: ${{ github.event.comment.id }}
          GH_AW_GITHUB_EVENT_DISCUSSION_NUMBER: ${{ github.event.discussion.number }}
          GH_AW_GITHUB_EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }}
          GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER: ${{ github.event.pull_re

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 16, 2026 19:30
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Sort environment variable names in context instructions Sort environment variables alphabetically in unified prompt step Jan 16, 2026
Copilot AI requested a review from pelikhan January 16, 2026 19:47
@pelikhan pelikhan marked this pull request as ready for review January 16, 2026 20:05
@pelikhan pelikhan merged commit 63ddd44 into main Jan 16, 2026
@pelikhan pelikhan deleted the copilot/sort-environment-variable-names branch January 16, 2026 20:05
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.

2 participants