github / github/copilot-cli

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

Abierto
#4,829 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

triage
Lenguaje dominante
Shell
Estrellas
11.2k
Forks
1.9k
Merge medio
14 h 16 min
PR fusionados (30 d)
6

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza por los puntos de entrada del arnés de subagentes detrás de la task tool e inspecciona cómo se ponen en cola los mensajes write_agent durante secuencias largas de llamadas a herramientas de Turn 0. Reproduce el comportamiento de 750 llamadas en Windows 11/PowerShell y verifica después que el arnés cede o compacta el contexto, y que una cancelación al estilo de stop_agent puede interrumpir un subagente en ejecución.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
powershell, shell
Área
ai, cli, performance
Tipo de issue
Error
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Activo
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.