Human gates in an agentic loop: why Plan should unlock side effects
Keep coding agents read-safe until a person approves the plan. Here's a simple way to think about modes, gates and review. Most debates about AI coding agents ask how smart the model is. The more useful question for a t
Keep coding agents read-safe until a person approves the plan. Here's a simple way to think about modes, gates and review.
Most debates about AI coding agents ask how smart the model is. The more useful question for a team that ships to production is simpler: when is the agent allowed to change things?
An agent that can read your repo, edit files, run shell commands, open a browser and call external tools is powerful. It is also a process with side effects. The same way we don't give a new hire production write access on day one, we shouldn't give an agent write tools before anyone has agreed on what it is about to do.
This post explains one pattern that helps: split the agent's work into modes, keep the early modes read-safe, and let an approved plan be the thing that unlocks writes.
The problem with "free-fire" agents
The default setup for many coding assistants is one big loop: you type a request, the agent reads some files, decides on an approach, edits code, maybe runs tests, and hands you a diff. Understanding, deciding and executing all happen inside one turn.
That feels fast, but it creates three problems:
- Scope drifts silently. The agent's idea of the task can differ from yours, and you only find out after it has touched twelve files.
- Review happens too late. By the time a human sees anything, the work is already a large diff. Reviewing a big diff is slower and less careful than reviewing a short plan.
- Side effects are not just code. Shell commands, migrations, browser actions and tool calls can change state outside the repo. A bad edit can be reverted; some of these cannot.
The fix is not "use a weaker agent". The fix is to put a gate in the loop.
Think in modes, not prompts
A useful mental model is to give the agent a small set of modes, each with its own tool budget. JuegoTech's JaiCode uses four, and they map well to how engineers already work:
- Ask: understand. Read-safe search, code navigation, research and exploration. No project writes. This is where mapping a brownfield codebase starts.
- Plan: decide. Research the repo, clarify scope, and lock a structured plan. A human approves it before anything is built.
- Debug: diagnose. Gather evidence first, then make targeted fixes once the diagnosis is solid.
- Build: execute. Edits, documents, shell, browser, MCP tools and checkpoints, available once the plan is unlocked.
The important part is not the names. It is that the tool list changes with the mode. In Ask and Plan, the agent literally cannot write to the project. Exploring is cheap and safe, so you can let it explore freely.
The plan is the unlock key
Here is the core idea: write access is not a setting you toggle. It is something a specific, approved plan grants.
In practice that looks like this:
[Ask] read-only tools ──► understanding, notes, open questions
│
[Plan] read-only tools ──► structured plan: scope, files, steps, risks
│
▼
HUMAN GATE: approve / edit / reject the plan
│
[Build] write tools enabled, scoped to the approved plan
│
[Review] automated review of the diff ──► human disposition: pass / fix / escalate
A good plan is short enough that a tech lead can read it in a couple of minutes. It names the files likely to change, the approach, what is explicitly out of scope, and how the change will be checked. Approving it is a real decision, not a rubber stamp.
Why this works:
- You review intent, not output. Catching a wrong approach in a ten-line plan is much cheaper than catching it in a 400-line diff.
- The blast radius is agreed up front. If Build starts touching files the plan didn't mention, that's a signal, not a surprise.
- It produces a record. Plan, approval and diff together explain why a change happened, which matters a lot in audit-minded teams.
Gates on both sides of Build
A plan gate alone is not enough. The other side of Build needs a gate too.
In the JaiCode model, Agent Review runs against the diff and produces findings and a verdict before merge. Then a person (on JuegoTech engagements, the Forward Deployment Engineer and the client lead) decides: pass, fix or escalate. The principle is stated plainly: no silent generative merges.
So the loop has two human checkpoints:
- Before side effects: is this the right thing to do?
- Before merge: was it done correctly?
Everything between those two points can be as automated as you like.
Scope what the agent can even see
Modes control which tools are available. A second control is where those tools can reach. Path grants and run policies let you say, for example, "this agent may read services/billing/** and run the test command, but may not read secrets/ or call deploy scripts."
This matters most in regulated domains, where "the agent only saw what it needed" is something you may have to show, not just claim. Running agents locally against your own checkout, instead of in a vendor sandbox you can't inspect, keeps that work visible.
How to try this on your team, with any tooling
You don't need a particular product to start working this way. A few habits get you most of the benefit:
- Start every non-trivial task in a read-only session. Ask the agent to map the relevant code and list open questions. Don't let it edit yet.
- Make "write a plan" a required step. A short markdown plan with scope, files, steps, risks and a test approach. Keep it in the PR description.
- Approve the plan explicitly. One reviewer, one comment: "approved" or "change X". Only then switch the agent to a mode that can write.
- Compare the diff to the plan. Files outside the plan's scope get questioned by default.
- Review before merge, every time. Automated review findings are input. A person still signs off.
- Limit reach. Use whatever path or permission controls your setup offers to keep agents away from secrets and deploy paths.
What this is not
This pattern isn't about distrusting models or slowing teams down. Assistants alone speed up typing. They don't encode a delivery process. Gates are what turn fast generative output into something a team can actually ship, review and explain later.
If you want to see how JuegoTech structures this end to end, with Ask / Plan / Debug / Build modes, Agent Review on the diff, multi-model BYOK and local-first execution, the JaiCode overview lays it out.
The short version: let agents explore freely, make them propose clearly, and let only an approved plan unlock side effects.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.