cleanup.mdmarkdown12345## MANDATORY: 1. FIND DOCUMENTED TODOs and FIXMEsYou SHALL use the `grep` tool piped with `head` to find the first `10` documented TODOs and FIXMEs in the repository.Command: grep -r -n -E "TODO|FIXME" . | head -n 10
cleanup.mdmarkdown12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152The outputs are in the following format.```shell[file]:[line]:[content]```You SHALL READ around each [line] in [file] and EXTRACT the [content] from all the found TODOs and FIXMEs, filtering out the ones cannot be applied apply with the restrictions of the platform, operating system, and required tools, then convert into a JSON object of the following format, using [incomplete_item_list] as the mnemonic:```json[ { "type": "todo", "id": "TODO_1", "file": [todo_1_file], "line": [todo_1_line], "content": [todo_1_content] }, { "type": "todo", "id": "TODO_2", "file": [todo_2_file], "line": [todo_2_line], "content": [todo_2_content] }, { "type": "fixme", "id": "FIXME_1", "file": [fixme_1_file], "line": [fixme_1_line], "content": [fixme_1_content] }, { "type": "fixme", "id": "FIXME_2", "file": [fixme_2_file], "line": [fixme_2_line], "content": [fixme_2_content] }]```You SHALL NOTE a JSON object with and empty "items" array as [completed_item_list]:```json[]```You SHALL NOTE a JSON object with and empty "items" array as [postponed_item_list]:```json[]```
3.4用提示词强制贯彻协议
这里的协议直接写在提示词里——没有任何隐藏技巧,而是用清晰的命令一遍遍强调,直到模型完全照做。下面这段展示了 main agent 如何在循环开始时拉起 cleanup-evaluator:
cleanup.mdmarkdown12345678910111213## MANDATORY: 2. SPAWN A CLEANUP-EVALUATOR TO EVALUATE INCOMPLETE TODOs and FIXMEsYou MUST spawn a cleanup-evaluator subagent to evaluate the gap between the incomplete TODOs and FIXMEs and the existing situation.You SHALL ALWAYS send the cleanup-evaluator with a JSON object of the following format:```json{ "incomplete_items": [incomplete_item_list], "completed_items": [completed_item_list], "postponed_items": [postponed_item_list]}```
cleanup-evaluator 一侧也必须执行协议:
cleanup-evaluator.mdmarkdown1234567891011## MANDATORY: PARSE THE RECEIVED JSON OBJECTYOU WILL RECEIVE a JSON object of the following format:```json{ "incomplete_items": [incomplete_item_list], "completed_items": [completed_item_list], "postponed_items": [postponed_item_list]}```
当 cleanup-evaluator 完成评估后,它会按照协议准备回给 main agent 的响应。这个例子里,next_action 只有两种:拉起 cleanup-executor,或者宣布 "mission complete"。
cleanup-evaluator.mdmarkdown12345678910111213141516## MANDATORY: RESPOND TO THE MAIN AGENTYou SHALL RESPOND with the [reordered_incomplete_item_list], [completed_item_list], [postponed_item_list] to the main agent with the JSON object of the following format:```json{ "incomplete_items": [reordered_incomplete_item_list], "completed_items": [completed_item_list], "postponed_items": [postponed_item_list], "next_action": "spawn(cleanup-executor)|mission_complete"}```The `next_action` field SHALL BE `mission_complete` when NO ITEMS ARE LEFT in [reordered_incomplete_item_list].Otherwise, the `next_action` field SHALL BE `spawn(cleanup-executor)`.
回到 main agent,它会依据 cleanup-evaluator 的反馈拉起 cleanup-executor subagent,并把三个列表传过去:
cleanup.mdmarkdown123456789101112131415161718192021222324252627282930313233343536373839404142## MANDATORY: 3. UNDERSTAND THE CLEANUP-EVALUATOR'S RESPONSEThe cleanup-evaluator subagent is ALWAYS the core of the workflow.YOU MUST OBEY THE DECISION OF THE CLEANUP-EVALUATOR IN [next_action].You SHALL NEVER CHANGE THE DECISION OF THE CLEANUP-EVALUATOR in [next_action].The [next_action] COULD BE: `spawn(cleanup-executor)` | `mission_complete`:The [next_action_details] COULD BE:```json{ "type": "todo|fixme", "id": [next_item_id], "file": [next_item_file], "line": [next_item_line], "content": [next_item_content]}```OR```json{ "type": "mission_complete"}```The cleanup-evaluator subagent SHALL NEVER know if it is the last time to evaluate until the [next_action] of a spawned cleanup-evaluator turns out to be `mission_complete`.### MANDATORY: ALWAYS TRANSFER [incomplete_items], [completed_items], [postponed_items] FROM THE CLEANUP-EVALUATOR'S RESPONSE TO THE NEXT SUBAGENTYOU MUST transfer the [incomplete_items], [completed_items], [postponed_items] from the cleanup-evaluator's response to the next subagent with the JSON object of the following format:```json{ "incomplete_items": [incomplete_item_list], "completed_items": [completed_item_list], "postponed_items": [postponed_item_list],}```
此时协议允许 main agent 拉起 cleanup-executor 来执行下一条 TODO/FIXME。不过我们还需要告诉 main agent 如何处理 cleanup-evaluator 之外的 subagent 的反馈:
cleanup.mdmarkdown1234567891011121314151617181920212223242526## MANDATORY: 4. UNDERSTAND THE RESPONSE FROM OTHER SUBAGENTSAll the subagents other than the cleanup-evaluator subagent SHALL ALWAYS respond with a JSON object of the following format:```json{ "incomplete_items": [next_incomplete_item_list], "completed_items": [next_completed_item_list], "postponed_items": [next_postponed_item_list], "next_action": "spawn(cleanup-evaluator)",}```### MANDATORY: ALWAYS READ Subagent’s Response to Decide Next ActionThe [next_action] is ALWAYS to spawn a cleanup-evaluator subagent.You MUST SEND the cleanup-evaluator a JSON object of the following format:```json{ "incomplete_items": [next_incomplete_item_list], "completed_items": [next_completed_item_list], "postponed_items": [next_postponed_item_list],}```
最后,让 main agent 知道何时应该收尾:
cleanup.mdmarkdown12345## MANDATORY: 5. HANDLING MISSION COMPLETEIf `next_action` in the response from the cleanup-evaluator subagent is `mission_complete`, then the mission is completed.You SHALL STOP ALL THE SUBAGENTS AND EXIT THE WORKFLOW.
到这里,我们已经用整套协议驱动的提示词搭好了第一个 agent 循环。
4试一试
当你把这个循环跑在 llama.cpp 项目上时,会发生以下情况:循环会精确处理 10 条 TODO 和 FIXME 后结束——无需宏大目标,只需一次专注的清理循环,就能让核心机制完整跑通。
试一试
5让循环 7x24 运作
要让循环全天候运行,重点是持续供给“饲料”,而不仅仅是持续时间。循环靠把 A 持续变成 B 活下去:把一种产出不断转换成另一种。假如 A 是点子、B 是程序(或修复、测试、发布),那么想要 7x24 地运转,就需要源源不断的点子。现实里,我们不可能拥有无限点子。更实际的做法是:让循环承担足够大、值得托付的工作,为你腾出思考时间。当 agent 在完成 A→B(例如编译、测试、打包、部署)时,你就能利用空档决定下一个 A。像 TODO/FIXME 扫描器或 issue 跟踪器这样的“饲料器”可以提供候选项,但无法代替你的判断。循环负责落实有意义的任务,你负责策展输入,这就是维持 7x24 节奏的正确姿势。