Compaction fails with "CAPIError: 400 Tool choice must be auto" on custom models
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
Session compaction (manual /compact and automatic compaction at the context threshold) fails with:
Compaction failed. CAPIError: 400 Tool choice must be auto
whenever the session is running a custom model (e.g. ~z-ai/glm-latest registered through a custom OpenRouter-compatible provider). The compaction summary request appears to force a tool call, and CAPI rejects non-auto tool choice for custom models, so compaction can never succeed on them.
Switching the same session to a first-party model (e.g. GPT-5.6 Luna or Claude Sonnet 4.6) and running /compact succeeds, confirming the failure is tied to the custom model's tool-choice capability, not the session contents.
Affected version
GitHub Copilot CLI 1.0.80 (also confirmed still present in the 1.0.81-14 prerelease)
Steps to reproduce the behavior
- Register a custom model via an OpenRouter-compatible provider (e.g.
~z-ai/glm-latest) - Start a session on that model and work until auto-compaction triggers (or run
/compactmanually) - Observe:
Compaction failed. CAPIError: 400 Tool choice must be auto - Switch the session to a first-party model and run
/compact— it succeeds
Expected behavior
Compaction should succeed on custom models, e.g. by falling back to tool_choice: auto with a prompt-based summary when the selected model does not support forced tool choice.
Additional context
- Reproducible across multiple sessions and repositories whenever the session model is a custom one; first-party models (GPT/Claude/Gemini) compact fine.
- After the failed compaction the session keeps growing and eventually hits context/size failures, since auto-compaction can never complete on custom models.
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 riproducendo il problema con /compact su un modello personalizzato compatibile con OpenRouter, quindi confrontalo con un modello first-party. Nel report non sono indicati file sorgente né test, quindi segui la richiesta di compattazione dal punto di ingresso /compact e ispeziona la gestione della scelta dello strumento. Il lavoro sarà completo quando sia la compattazione manuale sia quella automatica verranno completate correttamente per i modelli personalizzati senza l’errore CAPI.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Ambito
- api, cli
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Attiva
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100