Domain 5 of 6 · Chapter 3 of 4

Detect and respond to multi-agent failures

Unlock the complete study guide.

Bundled into the existing Developing in Agentic AI Systems premium course — no separate purchase.

14-day money-back guarantee — no questions asked.

Included in this chapter:

  • What counts as a failure when the session ended cleanly
  • Attributing a failure to the layer that produced it
  • Stop hooks: corrective continuation and its guard rails
  • Rewriting what a finished worker returns
  • Three signals that can look like failures without being one
  • Making failure legible to automation
  • Degraded output: fixing the assignment, the instructions, or the environment
  • Targeted retries: replay the smallest unit that failed
  • Steering a live session, and when steering is not available
  • Stopping work, and what stopping deliberately does not undo
  • Rolling back editor changes with a checkpoint
  • Abandoning an in-progress merge of agent branches
  • Human-in-the-loop recovery on the agent's pull request
  • Reading a recovery scenario under exam conditions

Signal, correct move, and the thing that move does not accomplish

SituationThe signal you actually haveCorrect moveWhat it does not do
Session ended, work looks partial`sessionEnd` `reason` (under cloud agent: `complete` / `error` / `timeout`)Inspect the changed files and run the tests before acceptingThe reason value never reports whether the assignment was completed
Errors reaching one shared alert queue`errorOccurred` `errorContext` + `recoverable`Branch on the context so model, tool, system and user-input failures alert their own ownersIt does not stop the run — `errorOccurred` output is not processed
Worker repeats the same failing tool call`postToolUseFailure` `toolName`, `toolArgs`, `error`Return `additionalContext` (exit code `2` for a command hook) with operation-specific guidanceIt cannot prevent the call; `preToolUse` is the pre-execution decision point
Agent pull request shows no checks and awaits workflow approvalA pending workflow approval in the merge boxInspect the proposed changes before selecting **Approve and run workflows** in the merge boxEditing workflow triggers or reassigning the issue does not clear the approval gate
`@copilot` correction was ignoredNo eyes reaction, no 'Copilot started work' eventCheck commenter write access and that the pull request is open; if the pull request is assigned to Copilot, also check the assignmentMissing acknowledgement does not rule out a stall; if comment-triggered work remains stuck, try adding the same comment again
`UNKNOWN STEP` appears in the run logA log line the CLI could not tie to a stepRead the run or job details for the steps the job actually ranIt is not evidence that an undeclared step executed
Supervising script proceeds past a failed run`gh run watch` returning on completionAdd `--exit-status` so a failed run exits non-zero`--compact` and `--interval` change the display, not the exit status
SDK dashboard marks a worker green too early`subagent.selected` / `.started` / `.completed` / `.failed`Treat `subagent.completed` as success and handle `subagent.failed` explicitly`subagent.selected` and `.deselected` say nothing about the result
Workers keep returning mis-scoped changesRepeated incomplete or irrelevant diffsRewrite the assignment: problem, acceptance criteria, files to changeAdding more parallel workers does not correct the assignment boundary
Workers keep failing the project's CIFailing first-run checks on agent pushesDocument build, test and validation in `.github/copilot-instructions.md`Required status checks detect the failure after the push, they do not prevent it
Sessions spend their run installing dependenciesSlow or failed trial-and-error discoveryPreinstall in a `copilot-setup-steps` job on the default branchLeaving discovery to the agent keeps it slow and unreliable in every session
A blocked request is suspectedA firewall warning naming the address and the commandRead it in the pull request body (issue-triggered work, a new pull request) or in a comment (comment-triggered work, an existing pull request)Absence from the location that does not match the trigger does not show the request was not blocked
Worker finished with a piece missingA completion check inside a stop hookReturn `decision: block` with the correction as `reason` for another turnUnder cloud agent the extra turn still counts against the job's existing timeout
Corrective loop runs away`stop_hook_active` on the `agentStop` payloadIn an `agentStop` hook, allow the turn when the flag is true so the hook self-limitsWaiting for Copilot CLI's runaway guard is not a substitute for self-limiting the hook
Two hooks rewrite one worker response`modifiedResponse` on `subagentStop`Do both transformations in one hook and return a single rewriteRewrites do not compose; each hook sees the original and the last one wins
Running session is heading the wrong wayThe prompt box below the session logSubmit a follow-up; it is applied after the current tool call finishesSteering is unavailable for third-party coding agents
One job of many failedThe run's per-job conclusions`gh run rerun --failed` (downstream dependent jobs included)A full rerun replays workers that already produced results
Failure cause not visible in the logsThin first-attempt records`gh run rerun --debug` for a new attempt with debug loggingNo `gh run view` option can create records the attempt never emitted
Degraded run must stop, evidence must surviveA run still executing`gh run cancel` (with `--force` if needed)Deleting artifacts destroys evidence and stops nothing
Cloud session must stop, commits already pushed**Stop session** in the session log viewerStop it, then treat rollback as a separate actionStopping preserves the pushed commits; archiving only clears the list
An editor session took a wrong directionPer-request checkpointsRestore the checkpoint for that requestIt also removes the later requests from the conversation, and needs checkpoints enabled
Agent-branch integration cannot be resolvedAn in-progress merge with conflicts`Git: Abort Merge` to return to the pre-merge stateAccepting one side everywhere discards an agent's work, and marking conflicts resolved without editing them does not itself commit the file; completing the merge requires a separate commit
Sensitive work must be done by a humanAn open agent pull request with a review threadWork on the agent's branch and push to the same pull requestOpening a replacement pull request loses the existing review thread

Decision tree

Recovering a multi-agent workflow: the order to askRecovering a multi-agent workflow: the order to askWork down the left column. Leave at the first question whose answer is yes.1. Does it match a documented look-alike?No checks, an ignored @copilot, or UNKNOWN STEP,with no error payload, failed job or tool error?yesCheck first. No checks → inspect changes, then Approveand run workflows. Ignored @copilot → write access, openPR, assignee if assigned. UNKNOWN STEP → a log limit.If still stuck, retry through the original trigger.no2. Is the session still running?A live cloud-agent session, or an executionthat has already ended?yesSteer it from the session log (Copilot only), or stop it:Stop session / gh run cancel. Stopping ends execution;commits already pushed are preserved.no3. Does the same defect recur across sessions?One bad run, or every worker returning thesame class of result?yesRepair upstream. Mis-scoped work → acceptance criteriaand files. CI failures → .github/copilot-instructions.md.Lost setup time → copilot-setup-steps.yml.no4. Must an editor or merge change be rolled back?Workspace edits or an in-progress merge thatmust return to a prior state?yesRoll back at the boundary the change reached: RestoreCheckpoint in VS Code, or Git: Abort Merge. Commitsalready pushed need a separate recovery action.noOtherwise: retry the smallest failed unit. gh run rerun --failed, adding --debug when the first attempt's records are too thin;unassign and reassign the issue for issue-started work, or submit the same comment again for comment-started work. Then confirmdelivery from the changed files and the test results — never from a completion message or a sessionEnd reason.

Cheat sheet

  • A sessionEnd event must be classified by its termination reason
  • errorOccurred supplies failure context and a recoverability signal
  • Use the watch command's exit-status option when automation must react to failure
  • UNKNOWN STEP can indicate a logging association limitation rather than a failed agent step
  • Agent completion must be checked against the actual change set and validation results
  • Missing CI activity after a cloud-agent push can be an approval wait
  • Route @copilot corrections through a user with write access on an open pull request
  • Incomplete or mis-scoped agent work calls for a clearer assignment
  • Repository instructions give agents a consistent build and validation procedure
  • Preinstall dependencies when repeated environment discovery degrades agent reliability
  • Use cloud-agent firewall warnings to diagnose a worker's blocked request
  • A stop hook can request another turn when a worker's result is incomplete
  • Stop-hook continuation must recognize an already-forced continuation
  • Multiple subagent response rewrites do not form a sequential processing pipeline
  • Choose the failed-job rerun when the whole workflow does not need replay
  • Enable debug logging on the rerun when the first attempt lacks diagnostic detail
  • Cancel the selected workflow run to stop an unwanted agent execution
  • Retry a stalled cloud-agent task through the trigger that started its work
  • postToolUseFailure can supply recovery guidance for the failed operation
  • Checkpoint rollback restores the workspace and removes subsequent conversation requests
  • Abort an unresolved merge when integration should return to its starting state
  • Human-in-the-loop recovery can continue directly on the agent's pull-request branch
  • Interpret SDK worker selection, execution, and failure as different lifecycle signals
  • Steer a running Copilot session through its log viewer without stopping it
  • Stopping a cloud session ends execution without undoing pushed commits

Unlock with Premium — includes all practice exams and the complete study guide.