You have a GitHub repository that uses the GitHub Copilot coding agent and supports hooks stored under .github/hooks/*.json.
The repository contains a PowerShell script at scripts/escalate-to-human.ps1.
You need to ensure that a hook runs before any tool execution and invokes the escalation script.
Which hooks configuration should you use?
A)
{
"version": 1,
"hooks": {
"userPromptSubmitted": [
{
"type": "command",
"powershell": "./scripts/escalate-to-human.ps1",
"cwd": "./scripts",
"timeoutSec": 10
}
]
}
}
B)
{
"version": 1,
"hooks": {
"preToolUse": [
{
"type": "command",
"powershell": "./scripts/escalate-to-human.ps1",
"cwd": ".",
"timeoutSec": 10
}
]
}
}
C)
{
"version": 1,
"hooks": {
"sessionStart": [
{
"type": "command",
"powershell": "./scripts/escalate-to-human.ps1",
"cwd": ".github/hooks",
"timeoutSec": 10
}
]
}
}
D)
{
"version": 1,
"hooks": {
"postToolUse": [
{
"type": "command",
"powershell": "./scripts/escalate-to-human.ps1",
"cwd": ".github/hooks",
"timeoutSec": 10
}
]
}
}
The correct configuration is B because preToolUse is the lifecycle hook designed to execute before an agent invokes a tool. This makes it the appropriate interception point for controls such as human escalation, permission checks, policy validation, logging, or blocking potentially consequential operations. In this configuration, the escalation script is invoked immediately before tool execution, satisfying the requirement that the control occur before the agent performs the requested action.
The cwd: '.' setting is also appropriate for the command shown because ./scripts/escalate-to-human.ps1 is expressed relative to the repository root. Therefore, the script resolves to the repository's scripts directory as intended.
Option A uses userPromptSubmitted, which occurs when the user submits a prompt and therefore does not guarantee execution before every subsequent tool call. Option C uses sessionStart, which runs only when the agent session begins and is too early to act as a per-tool guardrail. Option D uses postToolUse, which executes only after the tool has already run and therefore cannot satisfy a pre-execution escalation requirement.
Study Guide Reference Topics: Implement Guardrails and Accountability; Copilot hooks; preToolUse; human-in-the-loop escalation; tool execution controls; policy enforcement.
Currently there are no comments in this discussion, be the first to comment!