Skip to content

Fix empty GITHUB_AW_AGENT_OUTPUT in safe output jobs#1864

Merged
pelikhan merged 5 commits intomainfrom
copilot/investigate-gh-aw-action-output
Oct 17, 2025
Merged

Fix empty GITHUB_AW_AGENT_OUTPUT in safe output jobs#1864
pelikhan merged 5 commits intomainfrom
copilot/investigate-gh-aw-action-output

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 17, 2025

Problem

Safe output jobs (create-issue, add-comment, create-pull-request, etc.) were failing silently because the GITHUB_AW_AGENT_OUTPUT environment variable was empty. This caused JavaScript scripts to exit early without processing agent output.

The issue was observed in workflow run #18596819745 where the create-issue job logged:

No GITHUB_AW_AGENT_OUTPUT environment variable found

Root Cause

GitHub Actions was masking the job output with the message:

##[warning]Skip output 'output' since it may contain secret.

Safe output jobs were attempting to read agent output using:

env:
  GITHUB_AW_AGENT_OUTPUT: ${{ needs.agent.outputs.output }}

This resulted in an empty value because GitHub Actions security features prevent outputs that might contain sensitive data from being passed between jobs.

Solution

Modified safe output jobs to download the agent_output.json artifact that's already uploaded by the agent job, following the same pattern used by custom safe-jobs:

Before:

- name: Create Output Issue
  env:
    GITHUB_AW_AGENT_OUTPUT: ${{ needs.agent.outputs.output }}  # Empty!

After:

- name: Download agent output artifact
  uses: actions/download-artifact@v5
  with:
    name: agent_output.json
    path: /tmp/gh-aw/safe-outputs/

- name: Setup agent output environment variable
  run: |
    echo "GITHUB_AW_AGENT_OUTPUT=/tmp/gh-aw/safe-outputs/agent_output.json" >> $GITHUB_ENV

- name: Create Output Issue
  env:
    GITHUB_AW_AGENT_OUTPUT: ${{ env.GITHUB_AW_AGENT_OUTPUT }}  # Points to file!

Changes

  • Modified buildGitHubScriptStep() in pkg/workflow/safe_output_helpers.go to add artifact download steps before GitHub Script execution
  • Created new buildAgentOutputDownloadSteps() helper function that generates the download and environment setup steps
  • Updated all safe output job tests to expect the new artifact download pattern
  • Recompiled all 64 workflows to include the artifact download steps

Impact

  • Fixes safe output jobs that rely on agent output (create-issue, add-comment, create-pull-request, etc.)
  • Ensures reliable access to agent output regardless of GitHub Actions output size limits or security masking
  • Maintains consistency with the existing safe-jobs pattern
  • No breaking changes to workflow syntax or user-facing behavior

Testing

  • ✅ All unit tests passing
  • ✅ All integration tests passing
  • ✅ Manual verification with test workflows
  • ✅ All 64 production workflows recompiled successfully
Original prompt

Investigate why GH_AW_ACTION_OUTPUT is empty in create-issue.

https://github.com/githubnext/gh-aw/actions/runs/18596819745


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits October 17, 2025 15:22
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Add artifact download steps to buildGitHubScriptStep
- Change from using job outputs to artifact-based approach
- Update GITHUB_AW_AGENT_OUTPUT to read from env instead of job outputs
- Update tests to reflect new artifact download behavior
- Recompile all workflows with new artifact download steps

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate empty GH_AW_ACTION_OUTPUT in create-issue Fix empty GITHUB_AW_AGENT_OUTPUT in safe output jobs Oct 17, 2025
Copilot AI requested a review from pelikhan October 17, 2025 15:34
@pelikhan pelikhan marked this pull request as ready for review October 17, 2025 16:27
@github-actions
Copy link
Copy Markdown
Contributor

Agentic Changeset Generator triggered by this pull request.

@pelikhan pelikhan merged commit 4a874cd into main Oct 17, 2025
4 checks passed
@pelikhan pelikhan deleted the copilot/investigate-gh-aw-action-output branch October 17, 2025 16:32
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