Skip to content

Record the last agent action in failure diagnostics - #75763

Merged
pelikhan merged 5 commits into
mainfrom
copilot/aw-top-10-diagnose-failure-output
Nov 8, 2026
Merged

pelikhan merged 5 commits into
mainfrom
copilot/aw-top-10-diagnose-failure-output

Conversation

Copilot AI commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Runs that end without a terminal safe output or crash in the driver can produce notices with too little context. This change adds the last agent action to the diagnostic while retaining classified failure causes, driver exit details, and same-workflow issue reuse.

  • Diagnostics: Report the last action as a payload-free summary, such as assistant response recorded or tool call failed.
  • Failure context: Cover missing terminal output and driver crashes with classified stderr summaries and exit codes; keep raw payloads out of notices.
  • Regression coverage: Assert the missing-output cause, reuse of an existing workflow issue, and crash exit/stderr details.

Example:

Failure classification: driver_crash
Driver exit code: 139
Last agent action: tool call started (completion not recorded)
Last driver stderr summary: Driver execution failed (unhandled JavaScript exception)

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI changed the title [WIP] Extend failure classifier for better diagnostics Record the last agent action in failure diagnostics Nov 7, 2026
Copilot AI requested a review from gh-aw-bot November 7, 2026 23:33
@pelikhan

pelikhan commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

@copilot must be redacted

@pelikhan
pelikhan marked this pull request as ready for review November 7, 2026 23:46
Copilot AI adaptive review requested due to automatic review settings November 7, 2026 23:46
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Generated by Ponytail Reviewer for #75763

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · routed: gpt56 max · ~1 AIC · ⌖ ~2 AIC · ⊞ 6.3K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

Design Decision Gate 🏗️

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Design Decision Gate 🏗️ · routed: gpt56 max · ~1 AIC · ⌖ ~2 AIC · ⊞ 7.7K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from PR Specification Reviewer · gpt56 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.7K · ◷

Generated by PR Specification Reviewer for #75763

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot must be redacted

Added a regression test confirming assistant-message content mentioning @copilot is omitted from diagnostics. Commit: 4ae77f2e.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-11-07T23:52:00Z
review_event: COMMENT
top_themes: [stale last-action diagnostics for non-content-filter refusals]
files_reviewed: [actions/setup/js/empty_output_outcome.cjs, actions/setup/js/empty_output_outcome.test.cjs, actions/setup/js/handle_agent_failure.test.cjs]
comment_count: 1

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diagnostic enhancement is mostly sound and keeps payloads out of notices. One correctness gap remains: non-content-filter assistant refusals do not update the new last-action field, so the reported action can be stale when a refusal is the terminal event.

Finding

Refusal diagnostics

Record a fixed refusal summary for every assistant.refusal, while preserving the specialized content-filter diagnostic.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again

@@ -259,9 +260,13 @@ function buildEmptyOutputOutcome(errors, rootDir = "/tmp/gh-aw", session) {
if (event.type === "assistant.refusal" && data.reason === "content_filter" && context.agentId === undefined && !context.parentToolUseId) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This leaves non-content-filter assistant refusals unrecorded, so a run that ends on a refusal can be reported with an earlier action and misleading diagnostics.

💡 Record every refusal without exposing payloads

Handle assistant.refusal separately from the content-filter diagnostic and set a fixed summary such as assistant refusal recorded for all refusal reasons (while retaining the existing content-filter message only for the matching reason). This keeps the new last-action field truthful for provider refusals and subagent-independent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 64bd5d1: every top-level assistant refusal now records assistant refusal recorded, while content-filter classification remains limited to the content-filter reason. Added regression coverage for an ordinary refusal.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this change does: It adds a payload-free summary of the last agent action to empty-output diagnostics. It also extends regression checks for assistant responses, classified driver stderr, and failure-notice reuse.

Should fix:

  1. Tool actions are reported twice (actions/setup/js/empty_output_outcome.cjs:L430)

    • What this is: lastAgentAction is useful when an assistant response follows a tool, because lastToolCallStatus then describes an earlier tool.
    • Problem: If the final event is a tool, the new value is just tool call ${lastToolCallStatus}, so the notice prints the same fact as both Last tool call status and Last agent action. The new failure test explicitly asserts both lines.
    • Fix: Omit the generic action line when the last action is a tool call and use the existing tool-status line; retain the state for ordering against later assistant events.
    • If we skip it: Tool-ended failures keep redundant diagnostic text and two formats for one fact.

Verdict: fix 1 first.
Lean: -1 lines possible.

Generated by ✂️ Ponytail Reviewer for #75763 · codex · routed: gpt56 max · ~3 AIC · ⌖ ~1 AIC · ⊞ 118
Comment /ponytail to run again

]
: []),
`Last tool call status: ${lastToolCallStatus}`,
`Last agent action: ${lastAgentAction}`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should fix: avoid duplicate tool-action output. When the run ends with a tool event, lastAgentAction is derived from lastToolCallStatus, so this emits both Last tool call status: failed and Last agent action: tool call failed (the new assertion at actions/setup/js/handle_agent_failure.test.cjs:2370-2371 demonstrates it). Keep the state needed to detect a later assistant message, but omit the generic action line when it is a tool call and use the existing status line; otherwise every tool-ended failure carries redundant output and another format to maintain.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 64bd5d1: tool events continue updating internal last-action state, but their public summary uses only Last tool call status to avoid duplicate output. A later top-level assistant action still replaces that state.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Ordinary provider refusals are ignored by last-action tracking, causing affected runs to report a stale prior action or "not recorded" instead of the refusal.

1 open issue
What changed in this PR

This PR improves gh-aw failure diagnostics by reporting the last recorded agent action without exposing message or tool payloads.

Changes:

  • Track and report assistant responses, content-filter refusals, and tool activity.
  • Extend regression assertions for payload-free summaries and classified driver stderr.
  • Preserve coverage for missing-output causes and reuse of existing workflow issues.
File Description
actions/​setup/​js/​handle_agent_failure.test.cjs Assert last-action and classified stderr details in failure notices.
actions/​setup/​js/​empty_output_outcome.test.cjs Verify assistant-action reporting without exposing payloads.
actions/​setup/​js/​empty_output_outcome.cjs Track the last agent action and include it in diagnostic details.

Review effort: Balanced (auto)

Comment on lines +260 to +263
if (event.type === "assistant.refusal" && data.reason === "content_filter" && context.agentId === undefined && !context.parentToolUseId) {
contentFiltered = true;
diagnostics.add("The model response was blocked by content filtering; task completion could not be confirmed.");
lastAgentAction = "assistant refusal recorded";

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd. The core change is sound: the new Last agent action line renders correctly on the crash, outage, and tool-started paths, and the 20-line diagnostic cap does not truncate it. Requesting changes for one correctness gap and one coverage gap.

📋 Key Themes & Highlights

Key Themes

  • Nested-session guard missing: the assistant.message branch skips the subagent filter that the refusal branch applies, so a child agent response can be reported as the main agent last action.
  • Coverage gap: only assistant response recorded is asserted. The tool call started example from the PR description and the refusal value are untested.

Positive Highlights

  • ✅ Payload-free summaries: the new value strings contain no arguments, identifiers, or results.
  • ✅ The renamed handle_agent_failure test now asserts the stderr summary, which is the intended regression check.

Verification Limits

  • npm ci failed on a registry TLS error, so the vitest suites were not run. I exercised the changed module directly with Node against crash, outage, and tool-started fixtures instead.

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~5 AIC · ⌖ ~2 AIC · ⊞ 5.4K
Comment /matt to run again

contentFiltered = true;
diagnostics.add("The model response was blocked by content filtering; task completion could not be confirmed.");
lastAgentAction = "assistant refusal recorded";
} else if (event.type === "assistant.message") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/diagnosing-bugs] This branch lacks the nested-session guard that the refusal branch above uses (context.agentId === undefined && !context.parentToolUseId). A subagent assistant.message would overwrite lastAgentAction, so the "Last agent action" line can report a child agent response as the main agent last action. Apply the same guard here so only top-level events update it.

💡 Suggested change
} else if (event.type === "assistant.message" && context.agentId === undefined && !context.parentToolUseId) {

The tool.execution_* branches have the same gap, but changing them would also alter Last tool call status, so scope that change deliberately.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 64bd5d1: both assistant messages and refusals now update last-action tracking only for top-level events. Added coverage showing nested events do not replace the top-level action.

]);
const outcome = buildEmptyOutputOutcome([], rootDir);
expect(outcome.details).toContain("Last tool call status: succeeded");
expect(outcome.details).toContain("Last agent action: assistant response recorded");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] Only the assistant response recorded value is asserted. The tool call started (completion not recorded) value, which is the example in this PR description, and assistant refusal recorded have no coverage, so a regression in either would pass unnoticed. Add a case that ends with an unfinished tool call and assert the Last agent action line.

💡 Suggested test
it("reports an unfinished tool call as the last agent action", () => {
  writeEvents([{ type: "tool.execution_start", data: { toolCallId: "t", toolName: "bash", input: { command: "private-command" } } }]);
  const outcome = buildEmptyOutputOutcome([], rootDir);
  expect(outcome.details).toContain("Last agent action: tool call started (completion not recorded)");
  expect(outcome.details).not.toContain("private-command");
});

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added unfinished-tool regression coverage in 64bd5d1. It asserts the Last tool call status: started (completion not recorded) summary and payload redaction; the generic Last agent action line is intentionally omitted for tool events to avoid duplicating that status. The assistant refusal summary is also covered.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (actions/setup/js/empty_output_outcome.cjs:260): This leaves non-content-filter assistant refusals unrecorded, so a run that ends on a refusal can be reported with an earlier action and misleading diagnostics. - Record the last agent action in failure diagnostics #75763 (comment)
  3. Review (actions/setup/js/empty_output_outcome.cjs:430): Should fix: avoid duplicate tool-action output. When the run ends with a tool event, lastAgentAction is derived from lastToolCallStatus, so this emits both Last tool call status: failed and Last agent action: tool call failed (the new assertion at actions/setup/js/handle_agent_failure.test.cjs:2370-2371 demonstrates it). Keep the state needed to detect a later assistant message, but omit the generic action line when it is a tool call and use the existing status line; otherwise every tool-ended failure carries redundant output and another format to maintain. - Record the last agent action in failure diagnostics #75763 (comment)
  4. Review (actions/setup/js/empty_output_outcome.cjs:264): [/diagnosing-bugs] This branch lacks the nested-session guard that the refusal branch above uses (context.agentId === undefined && !context.parentToolUseId). A subagent assistant.message would overwrite lastAgentAction, so the "Last agent action" line can report a child agent response as the main agent last action. Apply the same guard here so only top-level events update it. - Record the last agent action in failure diagnostics #75763 (comment)
  5. Review (actions/setup/js/empty_output_outcome.test.cjs:523): [/tdd] Only the assistant response recorded value is asserted. The tool call started (completion not recorded) value, which is the example in this PR description, and assistant refusal recorded have no coverage, so a regression in either would pass unnoticed. Add a case that ends with an unfinished tool call and assert the Last agent action line. - Record the last agent action in failure diagnostics #75763 (comment)
  6. Fix failing check JS Tests (shard 5/8) (FAILURE): https://github.com/github/gh-aw/actions/runs/42427076259/job/128567612372.

Once you start work, post this work summary as a PR comment without the leading Copilot mention, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI.

Sous-chef requested-head: 4ae77f2
Sous-chef requested-work: 29768ddf402db00ee84ffe32752518ae4d65cb754cbb8160d8b258b6ad2bed89 60a2cd8c2f763591291c95b26be55830e7e0e3e43e238ac7e6fac1d5012a9dfb 78cff96338665a216aed174395db53962090e0167d19046c48b8353c0696ba8f 8546c92deff882de2c937f4e77c1473c817383e9acc18a7f61ef5b19407bf9e9 992c638f189bd6e135cdf7a687ad188615b0270ba2bb9965c0424ff02f430304
Sous-chef requested-state: 5449c77f00ce696b649364366cd21157d945ad58e5043e1df41bce4fff6748e6

Generated by 👨🍳 PR Sous Chef · pi · haiku45 · ~13 AIC · ⌖ ~19 AIC · ⊞ 1.2K · ◷
Comment /souschef to run again

Copilot AI commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

Copilot assignment requested for the following outstanding work:...

Sous-chef requested-head: 4ae77f2
Sous-chef requested-work: 29768ddf402db00ee84ffe32752518ae4d65cb754cbb8160d8b258b6ad2bed89 60a2cd8c2f763591291c95b26be55830e7e0e3e43e238ac7e6fac1d5012a9dfb 78cff96338665a216aed174395db53962090e0167d19046c48b8353c0696ba8f 8546c92deff882de2c937f4e77c1473c817383e9acc18a7f61ef5b19407bf9e9 992c638f189bd6e135cdf7a687ad188615b0270ba2bb9965c0424ff02f430304
Sous-chef requested-state: 5449c77f00ce696b649364366cd21157d945ad58e5043e1df41bce4fff6748e6
Work started: updating from main, addressing review feedback, and investigating the reported JS test failure.

Copilot AI and others added 2 commits November 8, 2026 00:52
…gnose-failure-output

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
@pelikhan
pelikhan merged commit ea7346e into main Nov 8, 2026
67 checks passed
@pelikhan
pelikhan deleted the copilot/aw-top-10-diagnose-failure-output branch November 8, 2026 03:17
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.2

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.

[AW Top 10] 05 Diagnose runs that fail without a terminal output

4 participants