coding agent 的 5 個回合 vs 1 次 command_run:完整例子

Yohji Sakamoto
·
·
IPFS
·
同一套 inspect、patch、build、test、lint 流程,普通 agent 要 5 次 LLM 回合;Tura 用一次 Macro 工作流程完成。

先說明:我是開源專案 Tura 的維護者。

給開發 coding agent 的人一個很簡單的想法:不要讓模型在可預測的每一步都重新醒來。

一般工具呼叫會變成 5 個 LLM 回合:

Turn 1 — 檢查
rg -n "TODO|command_run|handler" crates/
rg --files crates/runtime/src crates/tools/src

Turn 2 — 套用 patch

  • // old command handler logic

  • // patched command handler logic

Turn 3 — 建置
cargo build -p runtime

Turn 4 — 測試
cargo test -p runtime --lib

Turn 5 — lint
cargo clippy -p runtime --all-targets

真正的額外成本,不只是這些命令,而是模型醒來 5 次,並且每次都要重新讀取越來越長的對話。

Tura 提供一個叫 command_run 的 Macro 工具。Agent 可以一次送出同一個工作流程:

{
"name": "command_run",
"arguments": {
"commands": [
{ "step": 1, "command_type": "shell_command", "command_line": "rg -n "TODO|command_run|handler" crates/" },
{ "step": 1, "command_type": "shell_command", "command_line": "rg --files crates/runtime/src crates/tools/src" },
{ "step": 2, "command_type": "apply_patch", "command_line": "*** Begin Patch\n*** Update File: crates/tools/src/command_run/handler.rs\n@@\n- // old command handler logic\n+ // patched command handler logic\n*** End Patch" },
{ "step": 3, "command_type": "shell_command", "command_line": "cargo build -p runtime" },
{ "step": 4, "command_type": "shell_command", "command_line": "cargo test -p runtime --lib" },
{ "step": 4, "command_type": "shell_command", "command_line": "cargo clippy -p runtime --all-targets" }
]
}
}

建置、測試與 lint 都還是會執行,只是不需要在可預測的步驟之間再次呼叫 LLM。

在完整 DeepSWE 比較中,Balanced 比 Codex CLI 少 35.8% 回合、少 31.1% Token;Direct 少 69.1% 回合、少 77.5% Token。接近 80% 是這次 benchmark 的結果,不是每個任務的保證。

GitHub: github.com/Tura-AI/t...

Benchmark: turaai.net/benchmark

CC BY-NC-ND 4.0 授权

喜欢我的作品吗?别忘了给予支持与赞赏,让我知道在创作的路上有你陪伴,一起延续这份热忱!