Skip to content

[copilot] Compiler: Upload GITHUB_AW_OUTPUT as workflow artifact "aw_output.txt" #126

@pelikhan

Description

@pelikhan

Summary

Update the compiler so that the generated agentic job includes an additional step to upload the GITHUB_AW_OUTPUT file as a workflow artifact named "aw_output.txt".

Motivation

Currently, the agentic output file (GITHUB_AW_OUTPUT) is created and populated during workflow execution, and its contents are set as a workflow output. However, the file itself is not persisted as an artifact, making it harder to debug agentic runs or retrieve the raw output payload for post-processing.

Persisting this file as an artifact will make it easier to:

  • Download and inspect the agent's raw output for debugging.
  • Enable offline analysis or replay of agentic outputs.
  • Provide reproducibility for integration tests or end-to-end evaluations.

Implementation Details

  • Update the compiler logic in pkg/workflow/compiler.go, specifically within generateMainJobSteps, so that after the output collection step, an additional workflow step is generated to upload the ${{ env.GITHUB_AW_OUTPUT }} file as an artifact named aw_output.txt.
  • The upload step should use actions/upload-artifact@v4.
  • The step should be robust to the file being absent (e.g., use if: always() and handle missing file with if-no-files-found: warn).
  • Ensure this upload happens after the output file is finalized but before the job completes.

Relevant Code

  • pkg/workflow/compiler.go:
    • generateMainJobSteps (main step generation)
    • generateOutputFileSetup (creates the output file)
    • generateOutputCollectionStep (reads and sets the output)
// Example snippet to add:
yaml.WriteString("      - name: Upload agentic output file\n")
yaml.WriteString("        if: always()\n")
yaml.WriteString("        uses: actions/upload-artifact@v4\n")
yaml.WriteString("        with:\n")
yaml.WriteString("          name: aw_output.txt\n")
yaml.WriteString("          path: ${{ env.GITHUB_AW_OUTPUT }}\n")
yaml.WriteString("          if-no-files-found: warn\n")

Acceptance Criteria

  • All generated agentic jobs upload the GITHUB_AW_OUTPUT file as an artifact named "aw_output.txt".
  • The workflow does not fail if the output file is missing.
  • Tests in pkg/workflow/agentic_output_test.go are updated (or new tests added) to verify this artifact upload step is present in the generated lock file.

References


Follow repo instructions and always run make agent-finish before pushing or committing changes.


Example relevant code context

File: pkg/workflow/compiler.go

// generateMainJobSteps generates the steps section for the main job
func (c *Compiler) generateMainJobSteps(yaml *strings.Builder, data *WorkflowData) {
    // ...
    // Existing steps: setup output, engine execution, output collection, etc.
    // Add after output collection step:
    yaml.WriteString("      - name: Upload agentic output file\n")
    yaml.WriteString("        if: always()\n")
    yaml.WriteString("        uses: actions/upload-artifact@v4\n")
    yaml.WriteString("        with:\n")
    yaml.WriteString("          name: aw_output.txt\n")
    yaml.WriteString("          path: ${{ env.GITHUB_AW_OUTPUT }}\n")
    yaml.WriteString("          if-no-files-found: warn\n")
    // ...
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions