Background compaction can lose a completed parallel GPT tool result and cause HTTP 400
Nessuno ha ancora preso questa issue.
- Lingua principale
- Shell
- Stelle
- 11.2k
- Fork
- 1.9k
- Merge medio
- 14h 16m
- PR unite (30g)
- 6
Descrizione
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:
-
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 -
Give the agent a task that first reads one large structured context file, then performs a parallel batch of file reads/searches.
-
Allow every tool call in the parallel batch to finish successfully.
-
Let automatic background compaction run before the next model continuation.
-
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: 922000andmaxOutputTokens: 128000; the selected 1M context tier was active. - The failing continuation reports
premiumRequests: 0andtotalApiDurationMs: 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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia tracciando CompactionProcessor attraverso la continuazione di model.call_start e la cronologia chat.json persistita, usando gli eventi tool.execution_start e tool.execution_complete per confrontare l’ordine delle chiamate e dei risultati paralleli. Riproduci il problema con il comando autopilot a contesto lungo fornito e verifica che la compattazione conservi ogni coppia completata chiamata di funzione/risultato di funzione prima della continuazione, oppure ricostruisca o ritenti in modo sicuro una richiesta incoerente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- node.js
- Ambito
- api, cli
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Attiva
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 52/100