Skip to content

Instrument Copilot execution step to persist stderr and exit code on failure#42876

Closed
pelikhan with Copilot wants to merge 3 commits into
mainfrom
copilot/deep-report-instrument-copilot-cli
Closed

Instrument Copilot execution step to persist stderr and exit code on failure#42876
pelikhan with Copilot wants to merge 3 commits into
mainfrom
copilot/deep-report-instrument-copilot-cli

Conversation

Copilot AI commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Deep-report analysis found the dominant Copilot failure mode was 0-turn/0-token exits from Execute GitHub Copilot CLI with no stderr captured in artifacts, making failures non-diagnosable. This change instruments the generated Copilot execution step to always emit failure diagnostics into the existing log artifact path.

  • Failure diagnostics in generated Copilot run step

    • Wraps the existing Copilot command in a failure-aware shell envelope.
    • Captures stderr to /tmp/gh-aw/sandbox/agent/logs/copilot-cli-exec.stderr.log while preserving stderr in live job logs.
    • Captures non-zero exit status to /tmp/gh-aw/sandbox/agent/logs/copilot-cli-exec.exitcode.
    • Re-exits with the original Copilot exit code to preserve current failure semantics.
    • Cleans stale diagnostic files at start; removes stderr artifact on success to keep artifacts failure-focused.
  • Execution-step contract updates

    • Updates Copilot execution-step tests to assert presence of stderr/exit-code capture behavior.
    • Refreshes impacted Copilot workflow golden outputs to reflect generated YAML changes.
mkdir -p /tmp/gh-aw/sandbox/agent/logs/
rm -f /tmp/gh-aw/sandbox/agent/logs/copilot-cli-exec.stderr.log /tmp/gh-aw/sandbox/agent/logs/copilot-cli-exec.exitcode
set +e
(
  # existing Copilot command
) 2> >(tee -a /tmp/gh-aw/sandbox/agent/logs/copilot-cli-exec.stderr.log >&2)
GH_AW_COPILOT_EXEC_EXIT_CODE=$?
set -e
if [ "$GH_AW_COPILOT_EXEC_EXIT_CODE" -ne 0 ]; then
  printf '%s\n' "$GH_AW_COPILOT_EXEC_EXIT_CODE" > /tmp/gh-aw/sandbox/agent/logs/copilot-cli-exec.exitcode
fi
exit "$GH_AW_COPILOT_EXEC_EXIT_CODE"

Copilot AI and others added 2 commits July 2, 2026 02:49
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] Instrument copilot CLI exec step to emit stderr and exit code Instrument Copilot execution step to persist stderr and exit code on failure Jul 2, 2026
Copilot AI requested a review from pelikhan July 2, 2026 02:53
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

🤖 PR Triage — Run §28572743533

Field Value
Category feature
Risk 🟡 Medium
Score 64 / 100
Breakdown Impact: 30 · Urgency: 20 · Quality: 14
Action fast_track

Adds stderr/exit-code persistence on Copilot execution failure — high-value debugging capability across 7 files. Recommend expedited human review once undrafted.

Generated by 🔧 PR Triage Agent · 64.3 AIC · ⌖ 9.84 AIC · ⊞ 1.6K ·

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.

[deep-report] Instrument copilot CLI exec step to emit stderr + exit code into run artifacts

2 participants