github / github/copilot-cli

Background compaction can lose a completed parallel GPT tool result and cause HTTP 400

Ouverte
#4,572 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

area:context-memory area:models
Langage dominant
Shell
Étoiles
11.2k
Forks
1.9k
Merge moyen
14 h 16 min
PR mergées (30 j)
6

Description

Describe the bug

In Copilot CLI 1.0.80, a long-context gpt-5.6-sol autopilot session can fail immediately after automatic background compaction with:

CAPIError: 400 No tool output found for function call call_<redacted>.

The named tool did execute successfully. The JSONL event stream contains both tool.execution_start and tool.execution_complete with the exact same call ID and success: true. The persisted chat.json likewise contains matching FunctionCallContent.id and FunctionResultContent.callId entries.

The next model.call_start uses previousResponseId. The provider rejects it over ws:/responses, even though the request fingerprint reports equal counts (toolCallCount: 13, toolResultMessageCount: 13) and lastMessageRole: "tool".

This appears to be a compaction/continuation serialization bug, not a tool execution failure or context-window exhaustion.

Affected version

GitHub Copilot CLI 1.0.80

Also observed with:

  • Windows x64
  • Node.js v24.18.1 (bundled runtime)
  • Model: gpt-5.6-sol
  • Context tier: long_context
  • Reasoning effort: max
  • Transport: ws:/responses
  • isByok: false
  • Non-interactive --autopilot -s --output-format json
  • Read-only built-in tools (view, rg, glob, task_complete)

Steps to reproduce the behavior

The failure is intermittent, but this workload reproduces it repeatedly:

  1. Start a fresh non-interactive GPT session using this command shape:

    copilot --model gpt-5.6-sol --context long_context --reasoning-effort max --autopilot --available-tools=view,rg,glob,task_complete --allow-tool=view,rg,glob,task_complete -s --output-format json
    
  2. Give the agent a task that first reads one large structured context file, then performs a parallel batch of file reads/searches.

  3. Allow every tool call in the parallel batch to finish successfully.

  4. Let automatic background compaction run before the next model continuation.

  5. The next model call can fail with HTTP 400 claiming that one of the completed tool calls has no output.

A representative sanitized sequence:

tool.execution_start    call_A
tool.execution_start    call_B
... 7 parallel calls total ...
tool.execution_complete call_B success=true
... all 7 results complete ...
assistant.turn_end
CompactionProcessor: Background compaction completed successfully
CompactionProcessor: Compaction complete - replaced 4 messages with summary + 18 new messages, saved ~808134 tokens
model.call_start previousResponseId=<present>
model.call_failure 400 No tool output found for function call call_B

In that instance, the next model call started 61 ms after compaction completed, and the 400 arrived 166 ms after compaction completed.

Expected behavior

Background compaction must preserve every function-call/function-result pair atomically. A continuation should not be sent until the compacted state contains all completed tool outputs associated with the prior response.

If compacted history is inconsistent, the CLI should rebuild the request from intact local history or retry safely rather than send a payload the provider will reject.

Additional context

I analyzed 85 unique GPT review sessions collected between August 18 and August 22:

Session state Failed with missing tool output Succeeded
Compaction occurred 14 12
No compaction occurred 0 59

All 14 failures occurred 0.103-0.528 seconds after a successful compaction. No observed non-compacted session produced this error.

For compaction events followed by another call within two seconds:

Prior tool batch Failed Succeeded
Parallel (2-12 calls) 14 8
Single/no parallel batch 0 72

Additional observations:

  • The allegedly missing output was present and successful in all 14 event streams.
  • Missing-result sizes ranged from 148 to 37,089 characters, so this is not tied to one oversized result.
  • Tool completion order differed from call order in 12 of 14 failures, but two failures occurred even when the order matched.
  • A representative failure reports maxPromptTokens: 922000 and maxOutputTokens: 128000; the selected 1M context tier was active.
  • The failing continuation reports premiumRequests: 0 and totalApiDurationMs: 0, consistent with rejection before a model response.
  • The local compacted chat still contains both sides of the named call/result pair.

Related issues appear adjacent but do not report this exact sequence:

  • #2589 - truncation splitting tool call/result pairs (closed)
  • #4420 - parallel tool response correlation
  • #4500 - autopilot reserialization on nudge turns

I cannot attach the raw sessions because they contain private source content, but I can provide additional sanitized event ordering and request metadata if needed.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par suivre CompactionProcessor à travers la continuation de model.call_start et l’historique chat.json persisté, en utilisant les événements tool.execution_start et tool.execution_complete pour comparer l’ordre des appels et des résultats parallèles. Reproduisez le problème avec la commande autopilot à long contexte fournie et vérifiez que la compaction conserve chaque paire appel de fonction/résultat de fonction terminée avant la continuation, ou qu’elle reconstruise ou réessaie de manière sûre une requête incohérente.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
node.js
Domaine
api, cli
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Active
Clarté
Plutôt claire
Accessibilité débutants
52/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.