github / github/copilot-cli

[Bug] Subagents executing long tool-call sequences in a single turn fail prompt caching and compound token consumption

未关闭
#4,829 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

triage
主要语言
Shell
星标
11.2k
派生
1.9k
平均合并
14 小时 16 分钟
30 天内合并 PR
6

描述

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:

  1. Prompt Caching is defeated: The dynamic append of intermediate tool results changes the prompt prefix and prevents effective provider-side KV prompt caching.
  2. 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.
  3. 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.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 task tool 背后的子代理 harness 入口开始,检查在漫长的 Turn 0 工具调用序列中 write_agent 消息是如何排队的。在 Windows 11/PowerShell 上复现 750-call 行为,然后验证 harness 是否会让出执行权或压缩上下文,以及 stop_agent 风格的取消是否能够中断正在运行的子代理。

由索引模型根据 Issue 内容生成。

评估

技术栈
powershell, shell
领域
ai, cli, performance
Issue 类型
缺陷
难度
5/5
预计耗时
一周以上
活跃度
活跃
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。