mngr 透過自動化 Agent 測試流程,實現了自我迭代與端到端驗證
AI 語音朗讀 · Edge TTS
mngr 透過自動化 Agent 測試流程,實現了自我迭代與端到端驗證。
Imbue 開源了 CLI 工具「mngr」,旨在執行數百個並行 Agent,並透過實際案例展示如何利用該工具進行自我測試與優化。此流程不僅解決了編寫大量測試範例的繁瑣問題,更透過自動化機制確保教學腳本與端到端 (End to End) 測試的高度一致性。
核心機制與流程
「mngr」的運作邏輯是將教學腳本轉化為可驗證的測試程式碼,其核心步驟如下:
- 腳本拆解:將教學腳本切分為多個非空行區塊。
- 自動化生成:針對每個區塊推導出一個或多個「pytest」函數。
- Agent 協作:由 Agent 負責執行、除錯並修復這些「pytest」函數。
- 整合驗證:最終將所有測試結果進行整合,確保教學內容與實際執行行為同步。
開發與測試策略
為了減輕編寫超過 50 個測試範例的負擔,開發團隊採取了「以 AI 輔助開發」的策略:
- 內容生成:在檔案中撰寫註解(例如
# Managing snapshots),並要求編碼 Agent 自動填寫內容,開發者僅需審核並保留滿意的結果。 - 自動化轉換:一旦累積足夠的教學指令,即可透過「sync-tutorial-to-e2e-tests」指令,將其轉換為「pytest」函數。
- 測試規範:每個測試函數必須包含「e2e.write_tutorial_block」呼叫,確保測試內容與教學腳本完全對應,並強制要求驗證實際行為(而非僅檢查輸出結果)。
自動化測試的具體執行
在處理未匹配的測試與腳本時,系統遵循嚴格的執行邏輯:
- 優先處理舊測試:先比對現有的「pytest」函數與腳本區塊,若腳本已更新(如指令更名或參數變更),則更新測試邏輯以匹配新行為;若腳本區塊已移除,則刪除對應測試。
- 批次處理新測試:將剩餘未匹配的腳本區塊分組(每組 3-5 個),指派子 Agent 並行撰寫測試。
- 驗證原則:測試必須執行真實指令,並透過「e2e.run()」中的註解功能記錄操作意圖,確保測試不僅具備功能性,還具備可讀性與維護性。
技術反思與限制
該專案強調了自動化測試在 Agent 開發中的重要性,但也明確指出其邊界:
- 避免本地執行:由於這些是端到端 (End to End) 測試,執行成本較高,官方明確建議不要在本地運行,應交由 CI 系統進行驗證。
- 行為驗證:強調測試必須驗證「具體效果」(例如檢查 Agent 是否在正確目錄下運行),而非僅檢查表面輸出,這反映了對 Agent 系統可靠性的嚴格要求。
Yesterday we launched mngr, an open-source CLI for running 100s of parallel agents.
— Imbue (@imbue_ai) April 3, 2026
Today, we're releasing a detailed case study of how we're using mngr to run and improve itself, by testing its own demo script.
Here's how it works: pic.twitter.com/mKigmY1Lwp
Our setup:
— Imbue (@imbue_ai) April 3, 2026
— We start from a tutorial script, https://t.co/P5VsVBLRBs, and chunk it up into blocks of non-empty lines
— For each block, we derive one or more pytest functions
— An agent runs, debugs, and fixes each pytest function
— Finally, we integrate the outcome of all the… pic.twitter.com/ilpVHEDbRj
The tutorial script is seeded with a lot of content we wrote ourselves, but it's tiring to write 50+ examples. So we simply:
— Imbue (@imbue_ai) April 3, 2026
— Write some comments in the file, like # Managing snapshots
— Ask a coding agent to fill in the blank.
— Review and keep the ones that we like.
It's the…
Once we have a healthy amount of tutorial commands, we can ask a coding agent to convert it into pytest functions.
— Imbue (@imbue_ai) April 3, 2026
All of these are packaged into a slash command: sync-tutorial-to-e2e-testshttps://t.co/cyBC9CgFQx
