How do you stop an agent that makes mistakes, stalls or goes beyond its brief?
25 posts
Playbook
Practitioners use multi-layered security hooks, human-in-the-loop approvals, and sandboxing to restrict agent autonomy and prevent operational errors.
- Implement multi-layer security gates
Establish a three-layer defense consisting of rules, a stronger-model arbiter, and a human . This can include using 71 deny rules for git and gh alongside six regex hooks to catch phrases that rules miss . 23
- Execute external command blocking
Move dangerous command blocking outside the model using a PreToolUse hook, which can match 37 dangerous commands . 1
- Restrict file access through settings
Enable blockReadsOutsideWorkingDirectories and blockWritesOutsideWorkingDirectories in Claude Code to prevent agents from accessing files outside the project directory . 4
- Use time-limited, single-use authorizations
Generate a single-use, time-limited authorization bound to a command digest when a user types /yes . 3
- Route low-confidence requests to humans
Use models that output probabilities to identify low-confidence requests for human intervention while allowing high-confidence requests to run automatically . 10
- Ensure durability via database commits
Save every agent step to a database before the agent moves on, with one save representing one commit, to allow resumes from the last commit after a crash . 7
Choosing between approaches
While agents can be given autonomy through locked agreements enforced by existing software 8, a crashed gate must default to denying everything 2.
Not covered yet
The material does not cover specific thresholds for determining what constitutes a 'dangerous' command beyond the 37 examples provided 1.
Posts
- Block dangerous commands outside the model: 37 PreToolUse hook rules after four incidentsRunning several Claude Code sessions in parallel in a home lab, the author still had incidents after writing rules into memory, so blocking moved outside the model.

- Pass hooks with --settings under claude -p and make a crashed gate deny everythingThe author built a three-layer gate for a group of autonomous Claude Code agents: rules, a stronger-model arbiter, then a human.

- Three defenses for an unrestricted agent: deny rules, regex hooks, one-time approvalsAfter running Claude Code with --dangerously-skip-permissions and watching the agent get around his controls four times, the author built three layers.

- Lock Claude Code to your project with blockReadsOutsideWorkingDirectoriesDaniel San recommends enabling the blockReadsOutsideWorkingDirectories setting in Claude Code to stop the agent from reading files outside the current working directory.

- Pace AI agents to human speeds to avoid breaking your operationSteve Yegge argues that pacing AI outputs to human speeds prevents operational chaos, citing his experience where uncontrolled agents overwhelmed players, admins, and infrastructure in a small game studio.
- Prompt Claude to grant session permission to bypass auto mode refusalsSimon Willison found that Claude's auto mode occasionally refuses to run experiments.
- Save every agent step to a database so a crashed run resumes from the last commitMario Zechner describes how pi-durable keeps runs durable: every step of an agent run is saved to a database before the agent moves on, and one save is one commit.

- Lock in one customer-approved agreement and let the agent execute payments on its ownEmil Chetty, who leads data and AI product at Wise, proposes that the customer approves a whole task once, forming a locked agreement.

- Diagnose hosted agent timeouts with five Azure network checksThe Microsoft Foundry Blog outlines a diagnostic workflow for teams facing timeout errors when running hosted agents in private virtual networks.

- Manage long-running agent sessions with checkpoint filesMotiv31 handles long agent runs by having the model write its current state, tasks, and next steps to a checkpoint file before the context window fills.
- Let Okta decide whose access an agent uses, and AgentCore turn it into short-lived tokens
- Turn on Auto-review so a second agent checks the main agent's actions
- Train Laya on 30 support tools locally and send low-confidence requests to a person
15 more posts to see