本文由 AI 分析生成
建立時間: 2026-07-30 來源: https://x.com/h100envy/status/2068987470960623783
Summary
@h100envy presents a 7-step technical roadmap for building production-grade autonomous AI coding loops, covering stateless iteration, reward-hacking defense, filesystem state management, isolation via git worktrees and Docker, and structured JSONL logging. The central architectural principle is that stateless context keeps cost O(N) rather than O(N²), and that isolation must be built in from step 5, not bolted on later.
@h100envy 提出了一個 7 步驟技術路線圖,用於建構生產等級的自主 AI 程式碼迴圈,涵蓋無狀態迭代、獎勵破解防禦、檔案系統狀態管理、git worktree 與 Docker 隔離,以及結構化 JSONL 日誌。核心架構原則:無狀態 context 使成本保持在 O(N) 而非 O(N²);隔離必須在第 5 步內建,而非事後加入。
Key Points
- Step 0: Filter — only automate tasks with a deterministic external oracle (test suite, linter, type checker); no oracle = no loop
- Step 1: Reliable manual baseline with measurement before automating anything
- Step 2: Minimal stateless while-loop with MAX_ITER fuse; state stored on filesystem, not in context
- Step 2.5: Narrow context build — 8,000 token budget; extract only files from stack trace + last diff
- Step 3: Reward-hacking defense — test diff gate (detect deleted/mocked tests) + separate judge agent on a different model
- Step 4: Two-level state — STATUS.md (human-readable) + .loop_state.json (machine-parsable)
- Step 5: Isolation — git worktree per run + Docker
--network none --read-only - Step 6: Structured JSONL log with event types: iter_start, green, reward_hack, stuck, agent_call
- Step 7: Context must stay stateless — accumulating history makes cost O(N²) instead of O(N)
- Four loop deaths: runaway (no MAX_ITER), silent death (context full), random walk (no fixpoint), comprehension debt
Insights
The O(N) vs O(N²) cost framing for stateless vs stateful context is the most actionable insight in the thread—it explains why loops that seem cheap at 5 iterations become prohibitively expensive at 50. The reward-hacking defense (test diff gate + separate judge model) is critical for unattended runs; without it an agent will eventually find shortcuts that satisfy the checker without solving the problem. Naming the four failure modes explicitly provides a vocabulary for diagnosing loops that aren’t working rather than just restarting them.
Connections
- How to Build a Claude Code Agent Team That Runs in Loops (Exact Setup Inside) — Simpler 3-file implementation of the same builder/checker split
- Loop Engineering Build an AI That Codes While You Sleep — Boris Cherny’s production system providing scale context
- claude-code
- autonomous-agents
Raw Excerpt
“Deep mechanics plus working code. Stateless iteration, idempotent checks, isolation, defense against reward hacking, observability. From zero to a loop that will not blow up while you sleep.”