Skip to content

Agent jobs cancelled by engine.concurrency.cancel-in-progress are reported as missing_terminal_safe_output failures (regression since v0.91.x) #69050

Closed

Description

@MattSkala

Summary

When an agent job gets cancelled because a newer run took its engine.concurrency group (cancel-in-progress: true), the conclusion job still opens a [aw] <Workflow> finished without a terminal safe output failure issue. This is the normal superseded-run case, and v0.89.21 handled it quietly. After we upgraded to v0.91.12, each superseded run opens a failure issue.

Setup

engine:
  id: copilot
  concurrency:
    group: "my-agent-${{ github.event.workflow_run.pull_requests[0].number || github.event.pull_request.number || github.event.workflow_run.head_branch }}"
    cancel-in-progress: true

The workflow runs on workflow_run (build workflows completing on a PR).

What happened

  1. Run A starts for PR #N, commit 1. Its agent job starts and Copilot begins working.
  2. A new commit is pushed to PR #N. Run B's agent job joins the same engine.concurrency group and cancels run A's agent job about 20 seconds after the Copilot CLI starts. At that point the agent has emitted no safe output.
  3. Run A's agent job concludes as cancelled.
  4. The agent job's "Ingest agent output" step (collect_ndjson_output.cjs) finds no terminal safe output. It calls buildEmptyOutputOutcome() and adds a synthetic item: {"type":"report_incomplete","reason":"missing_terminal_safe_output","driverExitCode":0, ...}.
  5. The conclusion job's handle_agent_failure.cjs logs Agent conclusion: cancelled. It sees the synthetic report_incomplete, sets hasReportIncomplete = true, fails the step, and creates the failure issue.

Relevant conclusion-job log:

GH_AW_AGENT_CONCLUSION: cancelled
Agent conclusion: cancelled
Checking for existing issue with precise failure metadata for title: "[aw] … finished without a terminal safe output"
No existing issue found, creating a new one

The issue body also misleads: Driver exit code: 0, Last tool call status: succeeded. The CLI was still running (assistant.turn_start for turn 1 is the last session event) and was killed by the cancellation. It never exited 0.

Expected

A cancelled agent conclusion should not lead to a missing_terminal_safe_output / report_incomplete failure issue, and certainly not when the cancellation came from cancel-in-progress. A newer run supersedes the cancelled one, so no failure occurred.

Regression

Suggested fix

Either of these would work:

  • In handle_agent_failure.cjs, ignore a report_incomplete item whose reason === "missing_terminal_safe_output" (or any collector-synthesized one) when agentConclusion === "cancelled".
  • Skip the synthetic outcome in the collector when the job is being cancelled. This is harder, because the ingest step runs inside the cancelled job, so doing it in the conclusion job is more reliable.

A regression test should cover: agent conclusion cancelled, the collector-synthesized missing_terminal_safe_output item, and no failure issue created.

Environment

  • gh-aw v0.91.12 (compiler and gh-aw-actions/setup); previously v0.89.21 without this issue
  • Engine: copilot (CLI 1.0.96)
  • Trigger: workflow_run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions