Implement guardrails and human-in-the-loop workflows
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:
- Four jobs a control can do: limit, block, gate, record
- Where Copilot cloud agent's authority ends
- Making the boundary enforceable at merge time
- Choosing which tools an agent can even see
- Controlling what the agent's execution environment holds
- Limiting outbound traffic from cloud agent
- Data-disclosure controls beyond the firewall
- Permission rules in Copilot CLI
- Built-in protections in Copilot CLI's shell and fetch tools
- Hooks as policy: enforcement, and how it fails
- Approval surfaces in VS Code
- Limiting what a VS Code agent can reach
- Environments: the human gate for production
- Reading a guardrail scenario under exam conditions
What each control does, where it is configured, and where its scope ends
| Control | Job | Where it is configured | What it actually stops | What it does not stop |
|---|---|---|---|---|
| Copilot instructions file | None: describes a limit | `.github/copilot-instructions.md` in the repository | Nothing: it supplies no enforced merge-time approval boundary and binds no other contributor | The agent, a hurried human, or any other contributor making the change; it only steers work that will be reviewed anyway |
| CODEOWNERS + Require review from Code Owners | Gate | CODEOWNERS file plus a ruleset | Merging a change to a claimed path without a designated owner's approval | The change being proposed, and any path not claimed by an owner entry |
| Ruleset requiring code scanning / Code Quality results | Block | Repository rulesets | Merging without the required security or quality results present | Execution during the run; the results arrive after the code exists |
| Custom-agent `tools` list | Limit | Custom agent configuration | The agent choosing a tool that is not on the list (empty list disables tools) | Anything when omitted or set to `["*"]`, which enables all available tools |
| Copilot CLI `--deny-tool` | Block | CLI invocation / permission rules | The matching call, taking precedence over `--allow-tool` and even `--allow-all` | Targets outside the literal pattern — `write(PATH)` supports no globs |
| `preToolUse` hook returning deny | Block | Hook files (CLI and cloud agent) or `settings.json` (CLI only) | The tool call, before any side effect, with a stated decision reason | Anything when the hook times out, or when an HTTP endpoint is unreachable — both fall through |
| `postToolUse` hook | Record | Same hook sources | Nothing: it runs after a successful operation | The destructive command it was added to catch |
| Policy hooks (machine-wide) | Block | Machine-wide CLI policy location | A denied tool call, with no opt-out through `disableAllHooks` from ordinary hook sources | Anything in Copilot cloud agent, which does not support policy hooks |
| VS Code tool selection (Configure Tools) | Limit | Editor settings | The agent choosing a capability that is not enabled | Execution of an enabled tool, which approval settings govern separately |
| `chat.tools.terminal.autoApprove` `false` entry | Gate | Editor settings | Silent automatic execution of the matching command | The command itself — a human can approve it; parsing is best-effort, not a security boundary |
| `chat.tools.edits.autoApprove` glob set to false | Gate | Editor settings | A matching sensitive-file edit being applied before someone approves it | Edits to paths no glob matches |
| `chat.agent.networkFilter` denied domains | Limit | Editor settings | Agent fetch and browser access to denied domains; denials beat the allow list | Actions performed on an allowed API domain — allowing is not read-only |
| Cloud-agent firewall URL / domain rule | Limit | Cloud agent firewall configuration | Egress from processes started by the agent's Bash tool in the Actions appliance | MCP servers, configured setup steps, and processes outside that appliance |
| Agents secrets vs Actions secrets | Limit | Repository or organization secret stores | Cloud agent reading Actions secrets and variables at all | Misuse of a value deliberately placed in the Agents store |
| Environment required reviewers (+ Prevent self-review) | Gate | Actions environment protection rules | The targeting job starting, and the initiator approving their own deployment | Deployment by an administrator, unless bypassing protection rules is disallowed |
| Environment deployment branch restrictions | Block | Actions environment protection rules | Runs from ineligible branches or tags deploying to the environment | An eligible branch carrying an unwanted change — that is what reviewers are for |
| Verified agent commits and linked session logs | Record | Automatic on cloud-agent commits | Nothing; it establishes origin, integrity and an auditable execution record | An incorrect or unsafe change — provenance is not review |
Decision tree
Cheat sheet
Unlock with Premium — includes all practice exams and the complete study guide.