H
Howardism
Plate IIAgent Systems機器翻譯 · machine-translated過時翻譯 · stale translationENHOWARDISM

Agent 迴圈模式

PublishedMay 6, 2026FiledConceptDomainAgent SystemsTagsAgent EngineeringHarnessAutomationReading7 minSourceAI-synthesised

`/loop`(由 cron 排程)與 Ralph Wiggum(消化待辦清單)迴圈,作為下一代 agent 原語;AFK 執行、平行扇出,以及「迴圈就是未來」

Agent 迴圈模式插圖

資料來源#

摘要#

迴圈是會重複執行提示的 agent 程序,直到佇列清空或達到停止條件。到 2026 年年中,三種逐漸匯流的實作顯示,迴圈正成為與單次工作階段同等地位的原語:Anthropic 的 /loop 斜線指令(以 cron 排程、重複執行)、Anthropic 的 routines(伺服器端的 /loop),以及 Matt Pocock 的 Ralph Wiggum loop(在 while 中以 bash 加上 claude --permission-mode accept-edits 執行)。Boris Cherny 稱迴圈是「未來」;Matt Pocock 將其作為端到端工作流程的 AFK 骨幹。

兩類迴圈#

由 cron 排程的迴圈(/loop、routines)#

Claude CodeCowork 中使用。機制是:agent 透過工具呼叫 cron,將工作排程到未來某個時間;到了指定時間,該工作會帶著執行任務的指示重新進入 agent。排程可以重複執行(每分鐘、每 5 分鐘、每天)。

Boris Cherny 回報的用途:

  • 照看 PR — 修復 CI、自動 rebase
  • 維持 CI 健康 — 修復不穩定的測試
  • 每 30 分鐘彙整 Twitter 回饋
  • 「任何時候都有幾十個迴圈在執行」
  • 夜間:「幾千個 agents」進行更深入的工作

Routines 是伺服器上的同一種原語,因此即使關閉筆電也能持續運作。

消化待辦清單的迴圈(Ralph Wiggum loop)#

Matt Pocock 等人使用。機制是:shell script 以固定提示執行 agent;提示要求 agent 從待辦清單挑選下一個任務並完成;script 隨後重新啟動。待辦清單是由 markdown issue 檔案(或 GitHub issues)組成的目錄。

Pocock 的 once.sh 骨架:

issues=$(cat issues/*.md)
recent_commits=$(git log -5 --oneline)
prompt=$(cat prompt.md)
claude --permission-mode accept-edits "$prompt" --context "$issues" "$recent_commits"

「迴圈」包裝器只會反覆執行 once.sh,直到 agent 輸出 sentinel(no more tasks)或 harness 停止它。

提示會強制採用 AFK-only task selection — 只有標記為 AFK 的任務(相對於 human-in-loop)才符合資格。

迴圈為何重要#

  1. 將規劃成本攤銷到多次執行。 一次謹慎的規劃工作階段(例如透過 Design Concept Grilling)建立 Kanban 待辦清單(見 Vertical Slice Tracer Bullets);迴圈能在不需進一步人工輸入的情況下消化它。
  2. 數小時的任務變得可處理。 迴圈不是使用一個巨大的 context window,而是將工作切分成許多全新的工作階段,每次都維持在 Context Window Smart Zone 內。
  3. 平行化。 獨立的待辦項目會在不同的 sandbox 中同時執行。Pocock 的 Sandcastle library 透過 Docker containers 中每個 issue 專用的 git worktree 實現這點;之後由 merger agent 進行協調。
  4. 閒置運算。 Boris 的夜間配置是在便宜的閒置時段運行千 agent 迴圈——這些工作不值得人類花一晚處理,卻能以 agent 成本產生價值。

AFK 與 human-in-loop 任務#

Matt Pocock 的關鍵區分:

  • AFK tasks — 實作、重構、測試腳手架、文件維護、CI 修復。agent 不需逐步核准也能成功;驗證是自動的(測試、型別、linters)。
  • Human-in-loop tasks — 對齊、設計選擇、優先順序、QA。這些沒有機械式驗證;需要品味與默會脈絡。

迴圈適用於 AFK 類別。試圖讓 human-in-loop 工作進入迴圈會產生偏移——agent 會做出看似合理卻錯誤的決定,並逐步累積這些錯誤。

驗證是上限#

Pocock 更強的主張是:回饋迴圈的品質,決定迴圈能做到什麼的上限。 沒有好的測試、型別與 linters,迴圈就是「盲目寫程式」。這與 Agent Harness Engineering 對機械式強制的論點相同——只是迴圈更鮮明地暴露了成本,因為沒有人工捕捉偏移。

與模型軌跡的連結#

Boris Cherny 回報,Opus 4.7 會在沒有提示的情況下自發開始迴圈:

「我會告訴它:『去抓取這個資料查詢。』然後它會說:『嘿,我注意到資料會隨時間變化。我會開始一個迴圈,每 30 分鐘給你一份報告。』」

這符合 Harness Shrinkage as Models Improve——過去需要由 harness 注入的能力,會變成模型的自然行為。迴圈原語仍然存在,但使用者不再需要親自呼叫它。

相關連結#

開放問題#

  • 當模型自行排程迴圈(4.7 行為)時,誰擁有預算?Boris 的回答是「模型自己決定」——但這會把成本紀律推入模型的訓練,而不是 harness。
  • 如果模型夠聰明,迴圈是否仍需要 Kanban 待辦清單,還是模型會從原始目標中選擇自己的下一個任務?
  • 迴圈輸出的審查現在是 Matt Pocock 自承的瓶頸——「我們只需要準備好進行更多 code review。」

資料來源#

§ end
About this piece

Articles in this journal are synthesised by AI agents from a curated wiki and are refreshed automatically as new concepts arrive. Topics, framing, and editorial direction are curated by Howardism.

Cited by 31
Related articles
  • Agent Harness Engineering

    Patterns for scaffolding long-running LLM agents: environment design, progressive context disclosure, mechanical archit…

  • Harness Shrinkage as Models Improve

    Prompt scaffolding shrinks each model release; Cat Wu's pruning discipline; Boris Cherny "100 lines of code a year from…

  • Claude Code

    Anthropic's agentic coding product; created by Boris Cherny late 2024; TypeScript/React on Bun (itself Claude-rewritten…

  • Loop Engineering

    Replacing yourself as the agent's prompter by designing the system that prompts it: a recursive-goal loop built from fi…

  • Verification as the New Bottleneck

    Fiona Fung: coding is no longer the bottleneck — verification, review, maintenance are; shift-left; TDD loses its tax;…