github / github/copilot-cli

Compaction fails with "CAPIError: 400 Tool choice must be auto" on custom models

オープン
#4,646 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

triage
主要言語
Shell
スター
11.2k
フォーク
1.9k
平均マージ
14時間 16分
マージ済み PR(30日)
6

説明

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
  1. Register a custom model via an OpenRouter-compatible provider (e.g. ~z-ai/glm-latest)
  2. Start a session on that model and work until auto-compaction triggers (or run /compact manually)
  3. Observe: Compaction failed. CAPIError: 400 Tool choice must be auto
  4. 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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、OpenRouter互換のカスタムモデルで /compact を使って失敗を再現し、その後、ファーストパーティモデルと比較します。レポートにはソースファイルもテストも記載されていないため、/compact のエントリポイントからコンパクションリクエストをたどり、ツール選択の処理を調査してください。カスタムモデルで手動および自動のコンパクションがどちらもCAPIエラーなしで正常に完了すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

領域
api, cli
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。