Compaction fails with "CAPIError: 400 Tool choice must be auto" on custom models
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Shell
- Sterne
- 11.2k
- Forks
- 1.9k
- Ø Merge
- 14 Std. 16 Min.
- Gemergte PRs (30 T.)
- 6
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, den Fehler mit /compact auf einem benutzerdefinierten OpenRouter-kompatiblen Modell zu reproduzieren, und vergleiche ihn dann mit einem First-Party-Modell. Im Bericht wird weder eine Quelldatei noch ein Test genannt; verfolge daher die Kompaktierungsanfrage vom Einstiegspunkt /compact aus und untersuche die Behandlung der Tool-Auswahl. Als erledigt gilt die Aufgabe, wenn sowohl die manuelle als auch die automatische Kompaktierung für benutzerdefinierte Modelle ohne den CAPI-Fehler erfolgreich abgeschlossen werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Bereich
- api, cli
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Aktiv
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100