[Bug] Subagents executing long tool-call sequences in a single turn fail prompt caching and compound token consumption
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- powershell, shell
- 領域
- ai, cli, performance
研究方向
從 task tool 背後的子代理 harness 入口開始,檢查在漫長的 Turn 0 工具呼叫序列中 write_agent 訊息是如何排隊的。在 Windows 11/PowerShell 上重現 750-call 行為,然後驗證 harness 是否會讓出執行權或壓縮 context,以及 stop_agent 風格的取消是否能中斷正在執行的子代理。
由索引模型根據 Issue 內容生成。
描述
Environment
- GitHub Copilot CLI v1.0.83
- OS: Windows 11 / PowerShell
- Primary Model: Gemini 3.8 Flash
Problem Description
When executing autonomous subagents (such as custom agents via the task tool), the agent harness allows a subagent to run hundreds of tool calls within a single monolithic turn (Turn 0) without yielding or compacting context.
Because each tool execution (file edits, test outputs, build diagnostics) is appended sequentially to the conversation history of the active turn:
- Prompt Caching is defeated: The dynamic append of intermediate tool results changes the prompt prefix and prevents effective provider-side KV prompt caching.
- Exponential Token Compounding: Every subsequent tool call re-submits the entire growing history (75k-100k+ tokens) to the model. In our session, a single subagent ran ~750 tool calls in Turn 0, compounding to over 120 million tokens consumed in under 40 minutes on local test/edit loops.
- No Turn-Yielding / Throttling Mechanism: The agent does not yield control or checkpoint its context, and background interrupt signals (
write_agent) are queued rather than preempting execution.
Expected Behavior
- Subagent harnesses should enforce turn boundaries or context compaction/eviction after a reasonable threshold of consecutive tool calls (e.g. 15-20 tool calls) to preserve prompt caching and avoid runaway token compounding.
- An explicit cancellation/stop API (
stop_agent) should exist to immediately interrupt runaway background subagents.
Actual Behavior
The subagent executed 750+ tool calls in Turn 0 without yielding, burning >120M tokens on repeated compilation and test iterations, and could not be preemptively stopped via standard agent messaging.
- 主要語言
- Shell
- 星號
- 11.2k
- 分支
- 1.9k
- 平均合併
- 17 小時 6 分鐘
- 30 天內合併 PR
- 5
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
github/copilot-cli 的其他 Issue
-
area:sessions
難度 2/5 1-3 小時 新手友好度 72/100
github/copilot-cli#4996 ·
維護者通常 1 天內回覆
-
triage
難度 1/5 1 小時以內 新手友好度 88/100
github/copilot-cli#4963 · 1 則留言 ·
維護者通常 1 天內回覆
-
triage
難度 2/5 1-3 小時 新手友好度 75/100
github/copilot-cli#4932 ·
維護者通常 1 天內回覆
-
triage
難度 2/5 1-3 小時 新手友好度 78/100
github/copilot-cli#4909 ·
維護者通常 1 天內回覆
-
triage
難度 2/5 1-3 小時 新手友好度 76/100
github/copilot-cli#4906 ·
維護者通常 1 天內回覆
查看 github/copilot-cli 的全部 Issue
相似的 Issue
-
area:release bug
難度 2/5 1-3 小時 新手友好度 86/100
registrystack/registry-stack#1874 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 66/100
AppImage/appimage.github.io#9676 ·
維護者通常 1 天內回覆
-
automated issue report
難度 2/5 1-3 小時 新手友好度 68/100
a2aproject/A2A#2289 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
YunoHost-Apps/pixelfed_ynh#346 ·