/everything-copilot-cli:sub-agent-sandboxingfrom everything-copilot-cli
Adds runtime guardrails for delegated sub-agents: loop detection, circuit breakers, and escalating sandbox levels. Use when delegated tasks risk infinite retries or environment contamination.
Ships in everything-copilot-cli. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Sub-Agent Sandboxing protects the main workflow from delegated tasks that spiral, retry indefinitely, or make changes in the wrong environment. It complements file-scope controls by adding runtime guardrails around how a sub-agent is allowed to execute.
This pattern depends on Copilot CLI's delegated-agent workflow: separate task() execution lanes,
background lifecycle management, approval checkpoints, and the ability to route risky work into a
different checkout or environment before merging it back.
| Instead of sub-agent-sandboxing | Use |
|---|---|
| You only need a narrow writable path | scope-guard |
| You are designing tasks and contracts before execution starts | agentic-engineering |
| The task is read-only research | normal delegation or fleet-parallel |
Reviewer sub-agents must not modify the working tree.
When a reviewer edits files during review:
Enforce read-only mode in review briefs:
You are a reviewer. Your job is to evaluate the work, not change it.
Do not edit, create, or delete any files.
Return your findings as a report — do not apply fixes inline.
Orchestrator checks after a review pass:
# Confirm the reviewer left no staged or unstaged changes
git diff --name-only # no output expected
git diff --cached --name-only # no output expected
If git diff shows reviewer-authored changes:
When inline changes are genuinely needed (annotated suggestions):
These guardrails constrain one agent's execution. Fan-out width and nesting depth are a separate
boundary; verify them as described in
fleet-parallel.
Track repetition at the orchestrator boundary, not inside the agent prompt.
| Signal | Threshold | Response |
|---|---|---|
| Same tool + same arguments repeats | 3 times in a short window | Warn and inspect the prompt |
| Same tool + same arguments repeats | 5 times in a short window | Stop the sub-agent and escalate |
| Same tool appears regardless of args | 30 total calls | Treat as suspicious |
| Same tool appears regardless of args | 50 total calls | Hard-stop the run |
The exact window can vary by workflow. The important part is having a warning threshold and a hard stop threshold before retries become invisible token burn.
Do not let a failing lane hammer the same provider indefinitely.
| Trigger | Threshold | Response |
|---|---|---|
| Timeout / empty result / validation failure cluster | 5 failures within 60 seconds | Open the breaker for that lane |
| Breaker re-entry after cooldown | 1 probe call | Close only if the probe succeeds |
| Repeated open states | 2+ cycles | Escalate to a human or reroute once |
Use a single bounded reroute only when the task is idempotent and policy allows a different model or provider lane. Otherwise, keep the breaker open and surface the blocker.
Always release the probe flag, even on a non-retriable error. A probe call that fails with a non-retriable error (auth rejection, malformed request, permanent 4xx) must still clear the in-flight probe flag before returning. If the flag is only cleared on success or on retriable failure, the breaker can get stuck permanently open — every subsequent cooldown expiry sees the flag still set and never issues a new probe, so the lane never has a chance to recover even after the underlying issue is fixed.
Increase isolation as risk increases:
| Level | Environment | Use for |
|---|---|---|
| L1 Local | Current checkout with strict validation | Small, low-risk delegated edits |
| L2 Container | Disposable Docker/devcontainer environment | Tooling drift, dependency installs, risky generation |
| L3 Remote sandbox | Provisioned Kubernetes or equivalent isolated runtime | Untrusted tasks, high side-effect risk, destructive experiments |
If the safer environment is not available, stop and report that limitation rather than silently downgrading the isolation level.
An administrator may enforce a restrictive sandbox floor. Never try to lower or bypass that floor; if it excludes a required permission, report the failure explicitly. CLI v1.0.77 release notes document that this managed floor can be delivered through native macOS and Windows MDM settings.
CLI v1.0.79 documents allowDevToolAccess, enabled by default, so sandboxed builds can use
development-tool caches, config, registries, and installation locations without additional setup.
Set it to false for tighter isolation. The former allowDevToolCaches key is no longer read and
is silently ignored, so an existing false opt-out under that name reverts to the default (on).
The release notes do not define exact directories or access modes, so verify them in the installed
runtime. Because the default broadens the sandbox surface and can expose registry access, include
it in the supply-chain review described by
agent-supply-chain.
Treat sandbox ownership as a renewable lease, not as a permanent fact inferred from who created the resource:
Before dispatch, write down:
State the thresholds in the brief:
Loop policy:
- warn after 3 repeated identical tool calls
- stop after 5
- stop if one tool exceeds 50 calls total
Circuit breaker:
- open after 5 failed attempts in 60 seconds
- allow one probe after cooldown, otherwise keep the lane blocked
Use the lightest level that still makes rollback easy. If the task can damage the current checkout, move it to a worktree or higher-isolation environment first.
Treat credentials as part of the sandbox boundary, not as ambient defaults. Inside an OS sandbox,
git and gh authentication should be enabled only when genuinely needed, and on macOS keychain
access now defaults off for tighter isolation — re-enable it in /sandbox only for commands that
actually require it. This reinforces the same least-privilege rule as the rest of this skill:
start closed, then grant only the minimum extra access the delegated task needs.
Two Copilot CLI defaults pull in opposite directions, so state both in the brief (v1.0.92 and v1.0.100 release notes):
GITHUB_TOKEN unless it is
configured explicitly. A delegated script that "worked locally" may fail here — that is the
boundary working, not a bug to bypass.localhost, and outbound connections — including private-network addresses — are allowed unless
you restrict them. Turning off local network access in /sandbox blocks loopback only (since
v1.0.106); block outbound access or add host rules when the delegated task has no reason to
reach other machines.Since v1.0.102, sub-agents honor custom and MCP tool approvals instead of prompting again, so scope those approvals as narrowly as you scope the sandbox.
Since v1.0.106, nested sub-agents inherit and can use the MCP tools the session policy allows, so
those tools are available at every level of delegation, not only to the first sub-agent. A custom sub-agent with its own private MCP
connections no longer starts inherited servers that its resolved tool list excludes, so a narrow
tools list also limits which inherited servers it starts.
When you define sub-agents in code with the Copilot SDK (customAgents), three runtime rules
shape the boundary (github/copilot-sdk → docs/features/custom-agents.md):
skills list instead of assuming the parent's
instructions follow it.tools list is omitted or null, it gets every tool the session has — so set the list
explicitly, and give a reviewer view/grep/glob, not edit or bash.infer: false on agents that write, deploy, or spend, so
they run only when explicitly requested.These are SDK-level facts; check copilot help and your agent profile format before assuming the
same fields behave identically in .github/agents/ profiles.
Even successful sandboxed runs are only candidates. Review:
Apply allow and deny rules to each normalized real path, not to the submitted string. Check three
bypass vectors: a symlink from an allowed path into a denied path, ../ traversal, and a working
directory that is itself a symlink. Before accepting the run, resolve every changed path and verify
that none points outside the authorized worktree. Copilot's documented symlink enforcement has
been platform-specific, so verify Windows behavior separately rather than assuming parity.
Application-level path input validation is a different boundary; see
input-validation.
When the guardrail trips, return a useful blocker:
BLOCKER: sub-agent stopped by loop detection after repeated identical tool calls.
Last safe state: sandbox output preserved in worktree X.
Next action: rewrite the brief or switch to a higher-isolation lane.
Before retrying a stopped lane, capture the failure and name its class — a retry without a diagnosis usually repeats the same loop:
| Class | Typical signal | Check before retrying |
|---|---|---|
| Logic | tests still fail after the "fix" | isolate the failing test and re-derive the bug |
| State | file missing after a write, stale diff | cwd, branch, git status, the real file on disk |
| Environment | ECONNREFUSED, timeout, 429 | service health, port, retry spacing |
| Policy | denied tool, sandbox or permission block | which rule denied it, and whether the task needs it |
Record the last successful step, the last failed tool call, and the repeated pattern in the blocker,
so the next attempt starts from evidence instead of the same brief. Adapted from
affaan-m/ECC agent-introspection-debugging (MIT).
scope-guard limits where edits may happensub-agent-sandboxing limits how delegated execution behaves over timeagentic-engineering defines the task contract before dispatchusing-git-worktrees provides one practical isolation lane for L2/L3 style containmentgit diff is clean after any review passscope-guard — constrain writable scopeagentic-engineering — define explicit delegated task contractsfleet-parallel — coordinate multiple delegated lanes safelyusing-git-worktrees — isolate risky work in a separate checkoutorchestration/patterns/sub-agent-sandboxing — deeper orchestration pattern referenceWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
sub-agent, sandbox, guardrails, delegation, worktree-isolation
npx claudepluginhub drvoss/everything-copilot-cli --plugin everything-copilot-cli115 skills in this plugin
/actions-debuggingUse when a GitHub Actions workflow fails — diagnose the run log, identify the root cause, and apply a targeted fix/add-to-changelogUse when you've shipped a feature, fix, or breaking change and need to update CHANGELOG.md — follows Keep a Changelog format and syncs version numbers across package manifests./agent-governanceUse when designing or reviewing an AI agent system that needs policy-based access controls, intent classification, tool-level rate limiting, trust scoring for multi-agent workflows, or append-only audit trails.
/agentic-engineeringUse when designing or decomposing a task for agent execution — applies 15-minute task units, eval-first loops, and explicit input/output contracts so agents work reliably without implicit state/agent-owasp-checkUse when auditing an AI agent system against the OWASP Agentic Security Initiative Top 10 — checks tool access, prompt boundaries, memory handling, and operational safeguards across the agent pipeline./agent-supply-chainUse when auditing an AI agent plugin, skill bundle, or MCP tool package for supply chain integrity — generate deterministic SHA-256 manifests, detect modified or untracked files, flag unpinned dependencies, and gate promotion to production.
Other plugins' skills for the same job