Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions actions/setup/js/handle_agent_failure.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -876,10 +876,10 @@ async function main() {
// Check if agent succeeded but produced no safe outputs
let hasMissingSafeOutputs = false;
let hasOnlyNoopOutputs = false;
if (agentConclusion === "success") {
const { loadAgentOutput } = require("./load_agent_output.cjs");
const agentOutputResult = loadAgentOutput();
const { loadAgentOutput } = require("./load_agent_output.cjs");
const agentOutputResult = loadAgentOutput();

Comment on lines +879 to 881
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

loadAgentOutput() is now called unconditionally, even when agentConclusion is neither "success" nor "failure" (e.g. timed_out/skipped/cancelled). This introduces unnecessary file I/O and extra log noise in those cases. Consider only requiring/loading agent output when it will actually be used (e.g. inside the agentConclusion === "success" || agentConclusion === "failure" branch).

Suggested change
const { loadAgentOutput } = require("./load_agent_output.cjs");
const agentOutputResult = loadAgentOutput();
let agentOutputResult;
if (agentConclusion === "success" || agentConclusion === "failure") {
const { loadAgentOutput } = require("./load_agent_output.cjs");
agentOutputResult = loadAgentOutput();
}

Copilot uses AI. Check for mistakes.
if (agentConclusion === "success") {
if (!agentOutputResult.success || !agentOutputResult.items || agentOutputResult.items.length === 0) {
hasMissingSafeOutputs = true;
core.info("Agent succeeded but produced no safe outputs");
Expand All @@ -891,6 +891,18 @@ async function main() {
core.info("Agent succeeded with only noop outputs - this is not a failure");
}
}
} else if (agentConclusion === "failure") {
// The agent may have called noop successfully but the AI model server subsequently
// returned a transient error (e.g. "Response was interrupted due to a server error"),
// causing exit code 1. In that case we should not report a failure issue since the
// agent completed its intended work.
if (agentOutputResult.success && agentOutputResult.items && agentOutputResult.items.length > 0) {
const nonNoopItems = agentOutputResult.items.filter(item => item.type !== "noop");
if (nonNoopItems.length === 0) {
hasOnlyNoopOutputs = true;
core.info("Agent failed with exit code 1 but produced only noop outputs - treating as successful no-action (transient AI model error)");
}
}
}

Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

The new behavior for agentConclusion === "failure" with only noop outputs is not covered by existing unit tests for this module. Please add a test case that exercises this branch and asserts that failure handling/issue creation is skipped when the loaded agent output contains only noop items.

Suggested change
// If the agent produced only noop outputs, treat this as a successful no-action scenario
// and skip all failure handling / issue creation even if the job conclusion was "failure".
if (hasOnlyNoopOutputs) {
core.info("Agent produced only noop outputs - skipping failure handling and issue creation.");
return;
}

Copilot uses AI. Check for mistakes.
// Only proceed if the agent job actually failed OR timed out OR there are assignment errors OR
Expand Down
Loading