Repository navigation
Record the last agent action in failure diagnostics - #75763
Conversation
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
|
@copilot must be redacted |
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
|
✅ Ponytail Reviewer completed successfully!
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: 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.
|
|
✅ 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: 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.
|
|
✅ PR Specification Reviewer completed successfully! PR Specification ReviewerOutcome: 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.
|
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Added a regression test confirming assistant-message content mentioning |
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
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) { | |||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
-
Tool actions are reported twice (
actions/setup/js/empty_output_outcome.cjs:L430)- What this is:
lastAgentActionis useful when an assistant response follows a tool, becauselastToolCallStatusthen 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 bothLast tool call statusandLast 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.
- What this is:
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}`, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
🟡 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)
| 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"; |
There was a problem hiding this comment.
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.messagebranch 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 recordedis asserted. Thetool call startedexample 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_failuretest now asserts the stderr summary, which is the intended regression check.
Verification Limits
npm cifailed 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") { |
There was a problem hiding this comment.
[/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.
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
[/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.
There was a problem hiding this comment.
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.
|
Copilot assignment requested for the following outstanding work:
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-head: 4ae77f2 |
…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>
|
🎉 This pull request is included in a new release. Release: |

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.
assistant response recordedortool call failed.Example: