Prompt Rules Break by Turn 12: Reddit Author Enforces Agents With Lifecycle Hooks + Go Binary
Adorable-Cost-3249 · reddit · 2026-11-11
The author runs a single-agent workspace on Google Antigravity that simultaneously handles multi-repo coding and personal tasks (calendar, email, investment research). Initially they tried constraining behavior with ever-stricter rules in AGENTS.md, but weeks of real-world use revealed a clear pattern: prompt instructions work in turn 1 and silently stop working by turn 12.
Three failure modes of pure prompt rules
- Main thread gets stuck on "quick lookups": The main session runs 14 greps, edits two files, and kicks off go test directly, locking the entry thread for 5 minutes.
- Bookkeeping noise and state drift: Making the model manually maintain tasks.json/status docs burns tokens every turn and pollutes replies, while background sub-agents drift anyway once they finish.
- MEMORY.md context rot: An append-only memory file quickly becomes a graveyard of stale notes, injected into every new session each turn.
The fix: prompts as advice, lifecycle hooks as law
The author wrote a zero-dependency pure Go CLI (./bin/hq) wired into SessionStart/PreToolUse/Stop hooks:
- PreToolUse enforces "non-blocking foreground": While holding the main session lease, direct file edits and build/test commands are hard-denied (deny), forcing dispatch of background sub-agents or task threads in separate git worktrees; read-only queries (read/grep) are mechanically rate-limited to 3 per turn per session, after which they must move to the background.
- Stop hook for 0-token ledger sync: The model is forbidden from manually editing the task ledger; at Stop, a pure Go parser reads the conversation transcript (no LLM tokens spent), automatically reconciles sub-agents, worktrees, and scheduled tasks, and re-renders the status panel.
- Two-layer git boundary for privacy: The root repo holds only the CLI, skills, and hooks; personal data lives in a separate git-ignored local/ private repo, with a pre-commit regex scan for emails, phone numbers, SSNs, and other leaks.
Core takeaway: moving state and boundary checks out of prompts and into lifecycle hooks is the only way to stay stable long-term.
More from coding & agent
- Product idea: cloud Android VMs and home WiFi proxies to make agents look human — Darpinian · 2026-11-29
- Clairvoyance dev reveals 'staff model' agent architecture: one PM, named agents, per-agent inboxes — draginol · 2026-11-29
- Claude Opus Configures Karabiner Media Keys End-to-End, No Human Hands — cantrell · 2026-11-29
- Agentic GraphRAG unifies enterprise knowledge and agent memory in one traversable graph — vm324234 · 2026-11-29
- Coding agent blocked from npm rewrote the whole package from memory — and it worked — Panther1537 · 2026-11-29
- AI agents solve 909 open math problems in 2 days on 18-year-old's Left to Solve site — julianibarz · 2026-11-29