github / github/copilot-cli

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

未关闭
#4,646 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

triage
主要语言
Shell
星标
11.2k
派生
1.9k
平均合并
14 小时 16 分钟
30 天内合并 PR
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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,在自定义的 OpenRouter 兼容模型上使用 /compact 重现该故障,然后将其与一方模型进行比较。报告中没有指明源文件或测试,因此请从 /compact 入口跟踪压缩请求,并检查工具选择的处理逻辑。对于自定义模型,手动和自动压缩都能在不出现 CAPI 错误的情况下成功完成,即视为完成。

由索引模型根据 Issue 内容生成。

评估

领域
api, cli
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
活跃
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。