Sub topic 15
Choosing a Mode: A Decision Checklist
This chapter assumes you know the risk categories (read, write, execute, network, destructive), the allow, ask, and deny decisions, and the difference between prompts and sandboxes. It turns those into a repeatable way to pick a mode.
Start from what can go wrong
Pick a mode by asking what the worst outcome is and whether you could undo it. The task's size matters less than that. A large refactor in a clean git branch is easy to undo. A small command against a production database is not.
Work through these questions in order:
- Is the work reversible? Is everything the agent can touch under version control, or otherwise backed up? Files are recoverable. Deployed changes, sent messages, and deleted remote data are not.
- Is a sandbox in place? A container, virtual machine, or restricted workspace limits damage even if the agent is tricked or wrong. Prompts do not.
- Is the input trusted? Code you wrote is trusted. Third-party repositories, web pages, issue text, and tool output are untrusted and can carry prompt injection.
- What can the agent reach? Check for credentials, network access, production hosts, and external tool servers.
- Will you actually read the prompts? If you will approve without reading, the prompt gives you no protection.
Match the answers to a mode
| Situation | Suggested mode | Reason |
|---|---|---|
| Unfamiliar or untrusted repository | Read-only | You can inspect it with no side effects. |
| Normal work in your own project | Ask for execute and network, allow edits | Edits are reversible with git. Commands are where the risk is. |
| Repetitive task with a known command set | Ask by default, plus narrow allow rules | Fewer prompts, so each remaining prompt gets read. |
| Throwaway task in a sandbox with no secrets | Fully autonomous | The sandbox bounds the damage. |
| CI or scripted run | Explicit allow list, no prompts, sandboxed | No human is present, so rules and the sandbox are the only controls. |
The following function encodes the same logic. It is a teaching sketch, not a product feature.
def choose_mode(reversible: bool, sandboxed: bool, trusted_input: bool,
has_secrets: bool) -> str:
if not trusted_input and not sandboxed:
return "read-only"
if sandboxed and reversible and not has_secrets:
return "autonomous"
if reversible:
return "ask-for-execute"
return "ask-for-everything"
print(choose_mode(True, True, True, False)) # autonomous
print(choose_mode(True, False, False, False)) # read-only
print(choose_mode(False, False, True, True)) # ask-for-everythingTighten with rules, not just modes
A mode sets the default. Rules adjust it for specific actions. Keep deny rules for actions you never want, such as force pushes or curl *. Add allow rules only for exact, harmless commands. Remember that prefix patterns can match compound commands, so pair them with a chaining check.
Re-check when conditions change
Your answers can change mid-task. If the agent starts reading web pages, the input is no longer fully trusted. If you add an external tool server, the reachable surface grows. Drop back to a stricter mode when either happens, and review the diff and logs before you commit.
Exercise
You are asked to fix a bug in an open-source repository you just cloned. Your machine holds cloud credentials, and no sandbox is set up. Which mode do you start in, and what one change would let you move to a looser mode?
Show answer
Start in read-only (or ask-for-everything), because the repository is untrusted input and the machine holds credentials with no sandbox. Running the agent inside a container or virtual machine with no credentials would bound the damage. With that in place, you could allow edits and ask only for execute and network actions.