Skip to content

GH-600 · Domain 2: Implement tool use and environment interaction · 22% of the exam

Task 2.4: Operate agents with safe execution paths and robust error handling

Handling errors and retries, rolling back an agent's changes, escalating to people, and tracing every agent action back to a person and a session.

Study it

  • Error handling, retries, rollbacks and escalation paths for agents

    Partly covered by: Message Queues

  • Traceability: agent commits, session logs and hooks

    Partly covered by: Tracing a Request

Sample questions

Try each one before opening the answer. Every option is explained, with the GitHub documentation page that proves it.

Question 1 · choose 1

A security team's preToolUse command hook runs a script that queries an internal policy service. They want to know what happens to the guarded tool call when the script misbehaves. Which description matches the documented behavior?

  1. AAny hook failure, including a timeout, denies the call, so the policy can never be bypassed
  2. BA crash or non-zero exit denies the tool call, while a timeout lets it continue
  3. CAny hook failure is logged and skipped, so the tool call always continues
  4. DAn exit code of 2 lets the call run if the hook printed permissionDecision allow
Show the answer and why
  • AAny hook failure, including a timeout, denies the call, so the policy can never be bypassed

    Incorrect

    Timeouts are fail-open for every event, including preToolUse and admin-deployed policy hooks.

  • BA crash or non-zero exit denies the tool call, while a timeout lets it continue

    Correct

    preToolUse command hooks fail closed on errors and exit 2, but timeouts always fail open.

  • CAny hook failure is logged and skipped, so the tool call always continues

    Incorrect

    That is how most events behave; preToolUse is the exception and fails closed on errors.

  • DAn exit code of 2 lets the call run if the hook printed permissionDecision allow

    Incorrect

    Exit 2 always denies, even when stdout reports allow.

For most hook events, failures and timeouts are logged and skipped. preToolUse command hooks are the exception: exit 2, a crash or any other non-zero exit denies the tool call, even if stdout says allow. Timeouts are always fail-open, including for preToolUse and admin-deployed policy hooks, so a slow hook doesn't silently block work; set timeoutSec to suit the check. HTTP preToolUse hooks differ: a network error, timeout or non-2xx response falls through to the normal permission flow.

Question 2 · choose 1

In Copilot CLI, a developer lets Copilot refactor five files, then hand-edits two of them. Unhappy with the refactor, they open the rewind picker and choose Conversation + files at the prompt that started it. What happens to the files?

  1. AAll five files are restored, overwriting the hand edits
  2. BNothing is restored unless the folder is a Git repository with uncommitted changes
  3. COnly the conversation rewinds; files are restored in a separate /undo files step
  4. DThe three untouched files are restored and the two hand-edited ones are skipped
Show the answer and why
  • AAll five files are restored, overwriting the hand edits

    Incorrect

    Rewind deliberately skips files you edited afterwards, so your own work isn't overwritten.

  • BNothing is restored unless the folder is a Git repository with uncommitted changes

    Incorrect

    Rewind works in any directory, including folders that aren't Git repositories.

  • COnly the conversation rewinds; files are restored in a separate /undo files step

    Incorrect

    Choosing Conversation + files restores files in the same step, after a per-file preview.

  • DThe three untouched files are restored and the two hand-edited ones are skipped

    Correct

    Copilot restores only files it changed and skips any whose contents no longer match what it last wrote.

Pressing Esc twice while idle, or using /undo or /rewind, opens the rewind picker. Conversation + files restores the files Copilot changed to their state before the selected prompt, skips files whose contents no longer match what Copilot last wrote, and removes later history. Rewind works outside Git repositories but can't be undone, and isn't available for remote-backed sessions.

Question 3 · choose 1

A hook that runs a linter keeps timing out in Copilot CLI. What is the default timeout, and how is it changed?

  1. A5 seconds, changed with maxRuntime
  2. B60 seconds, changed with --hook-timeout
  3. CNo timeout; hooks run until they finish
  4. D30 seconds, changed with timeoutSec
Show the answer and why
  • A5 seconds, changed with maxRuntime

    Incorrect

    Five seconds is the suggested target run time, not the default timeout.

  • B60 seconds, changed with --hook-timeout

    Incorrect

    The default is 30 seconds, set per hook with timeoutSec.

  • CNo timeout; hooks run until they finish

    Incorrect

    Hooks have a default timeout of 30 seconds.

  • D30 seconds, changed with timeoutSec

    Correct

    The default timeout is 30 seconds; increase timeoutSec if needed.

Each hook entry can set timeoutSec, the maximum execution time in seconds, which defaults to 30. Hooks run synchronously and block the agent, so GitHub suggests keeping them under 5 seconds where possible.

Question 4 · choose 1

A developer presses Ctrl+C once while Copilot CLI is writing several files. What happens?

  1. AEvery file change made earlier in the turn is rolled back to how it was before the prompt
  2. BThe session exits right away
  3. CThe operation stops, the write in progress finishes, and the rest is abandoned
  4. DCopilot asks for confirmation first
Show the answer and why
  • AEvery file change made earlier in the turn is rolled back to how it was before the prompt

    Incorrect

    Cancelling doesn't roll back; use rewind for that.

  • BThe session exits right away

    Incorrect

    A second Ctrl+C within two seconds, with empty input, exits the session.

  • CThe operation stops, the write in progress finishes, and the rest is abandoned

    Correct

    Ctrl+C cancels immediately; a file write already in progress completes, and remaining changes are abandoned.

  • DCopilot asks for confirmation first

    Incorrect

    Unlike Esc, Ctrl+C cancels without a confirming second press.

A single Ctrl+C immediately cancels the active operation and clears queued prompts. A file write already in progress completes so files aren't corrupted, but remaining planned changes are abandoned. Pressing Ctrl+C again within two seconds with an empty input exits the session.

Question 5 · choose 1

A developer mentions @copilot on a pull request that was merged last week to ask for a follow-up fix, and nothing happens. Why?

  1. AThe developer needs admin rights
  2. BCopilot doesn't respond on merged or closed pull requests
  3. CThe comment must start with /copilot
  4. DCopilot answers follow-up requests only in the issue that started the work
Show the answer and why
  • AThe developer needs admin rights

    Incorrect

    Write access is enough on open pull requests.

  • BCopilot doesn't respond on merged or closed pull requests

    Correct

    Copilot only responds to mentions in open pull requests.

  • CThe comment must start with /copilot

    Incorrect

    Mentions use @copilot.

  • DCopilot answers follow-up requests only in the issue that started the work

    Incorrect

    Copilot responds to comments on open pull requests.

If you have write access and mention @copilot on a pull request assigned to Copilot, the comment is passed to cloud agent. Once a pull request is merged or closed, Copilot cloud agent doesn't respond to new mentions or comments; start a new task instead.

Question 6 · choose 1

In one Copilot CLI turn, a code generator changed 800 files. Later the developer rewinds to before that turn. What happens to those 800 files?

  1. AThey aren't restored, because changes beyond 500 files in a turn aren't captured
  2. BThey are all restored, after a per-file preview lists what will change in each one
  3. COnly the first 500 are restored
  4. DThey are restored only if each is under 10 MB
Show the answer and why
  • AThey aren't restored, because changes beyond 500 files in a turn aren't captured

    Correct

    If a single turn changes more than 500 files, its file changes aren't captured.

  • BThey are all restored, after a per-file preview lists what will change in each one

    Incorrect

    Changes from that turn weren't captured, so they can't be restored.

  • COnly the first 500 are restored

    Incorrect

    None of that turn's file changes are captured.

  • DThey are restored only if each is under 10 MB

    Incorrect

    The 500-file limit applies first; that turn wasn't captured.

Rewind can't restore everything: changes to files over 10 MB aren't captured, a turn that changes more than 500 files isn't captured, and sessions without file tracking or remote-backed sessions get only conversation rewind or none.

Practise domain 2 →Practise all domains →