Run Coding Agents Without Babysitting, and Reset Them When They Loop
A brief written like a ticket, a check the agent can run, a plan you approve before code, and fences set in configuration. When it goes wrong, name the pattern and change what it sees.
Key takeaways
- A check the agent can run is what lets you walk away from a session instead of watching it.
- Approving the plan before any code is the cheapest place to steer an agent.
- Ask for evidence such as pasted test output, never just the claim that tests pass.
- Permissions, hooks and sandboxes enforce limits; wording in a prompt does not.
- When an agent loops, stop it, ask what it tried, clear the session and restart with that summary.
Contents
FAQ
When should I let an agent run unattended?
Only when it has a runnable done-check, a scope fence, and nothing beyond a branch or sandbox is at risk. Otherwise approve the plan and review the diff.
What is reward hacking in coding agents?
Making the check pass instead of meeting the goal, for example by editing tests. Tell the agent to fix the code, not the tests, and read test diffs first.
Sources
Only you and the owner see your answer and rating. Send private feedback
Enjoyed it? Support fx-blog with a coffee.
Related posts
Your LLM Proxy Retries the Wrong Errors
What an LLM proxy has to decide on every failure: limits are per organization, which statuses to retry, why nothing is retried after the first streamed byte, and the headroom headers the API already sends.
Your LLM Demo Works. What Every Call Needs in Production
One timestamp in the system prompt and every call misses the cache. Pricing each call, making failures loud, logging per feature, and treating outside text as untrusted.
RAG That Works: Why Retrieval Matters More Than the Prompt
Most bad RAG answers are retrieval problems. How RAG works end to end, the three parts of the grounded prompt, how to measure retrieval alone, and when long context is enough.
Comments
Oldest firstNo comments yet. Start the conversation.
Part 2 put the auth service's conventions and review prompts in the repo and left the real work: hand the login rate limit to an agent, let it read, edit and run commands for an hour without watching every step, and know what to do when it goes in circles.
Claude Code's documentation names what makes that possible: give the agent "a check it can run: tests, a build, a screenshot to compare. It's the difference between a session you watch and one you walk away from." The guide adds the corollary: no check, no autonomy.
AI Practices for Engineers, in 6 parts:
The brief is a ticket
The login rate limit touches the auth handler, Redis and the tests, and nobody can list every step in advance: agent work. The five questions from part 1 become a ticket:
"Done when" is the line that lets you leave.
Approve the plan, then the diff
Steering a plan costs far less than steering a diff. For the rate limit, the plan is where you catch a wrong Redis key scheme before it spreads through the handler and the tests.
When agents built fx-blog, the blog you are reading, I made the same trade at a larger scale. I reviewed only the rendered UI, at every breakpoint. Everything else had to pass a gate with evidence and file hashes, judged by an independent reviewer.
Watch less, fence more
Wording in a prompt enforces nothing. Settings do: leave push, deploy and delete on ask; let a hook block writes to
migrations/; run autonomous work on a throwaway branch, never with production credentials; cap turns and retries.When it goes wrong, change what it sees
A Redis bug turns up, and the agent tries the same fix a third time. Correcting it harder makes it worse: the failed attempts in its context pull every next attempt toward them. Each failure has a name that points at the fix:
None of the fixes is "try again, but firmer". For the Redis loop: stop, ask what it tried and why each attempt failed, clear, and restart with that summary and a new angle, such as the Redis log.
Try it
The agent comes back with green output for
tests/auth/rate-limit.test.ts, and the sixth attempt returns 429. But the agent wrote those tests too. If the limit were broken, would they go red? And which decisions on this change should no agent make at all? Part 4, AI-Generated Code: Checks That Can Fail, breaks the code on purpose to find out.Read this with your AI