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

Đang mở
#4,829 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
powershell, shell
Lĩnh vực
ai, cli, performance

Hướng nghiên cứu

Bắt đầu từ các điểm vào của harness dành cho subagent phía sau task tool và kiểm tra cách các thông báo write_agent được đưa vào hàng đợi trong các chuỗi tool-call Turn 0 kéo dài. Tái hiện hành vi 750 lần gọi trên Windows 11/PowerShell, sau đó xác minh rằng harness nhường quyền hoặc nén context, và rằng một thao tác hủy kiểu stop_agent có thể ngắt một subagent đang chạy.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

triage
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.

Ngôn ngữ chính
Shell
Star
11.2k
Fork
1.9k
Merge trung bình
14 giờ 16 phút
Pull request đã merge (30 ngày)
6

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của github/copilot-cli

Tất cả issue của github/copilot-cli

Issue tương tự

Thêm issue về Shell/Bash

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.