Skip to content

feat(acp-adapter): expose thinking effort levels in config options - #1988

Closed
cnctem wants to merge 3 commits into
MoonshotAI:mainfrom
cnctem:feat/acp-thinking-effort-levels
Closed

feat(acp-adapter): expose thinking effort levels in config options#1988
cnctem wants to merge 3 commits into
MoonshotAI:mainfrom
cnctem:feat/acp-thinking-effort-levels

Conversation

@cnctem

@cnctem cnctem commented Jul 21, 2026

Copy link
Copy Markdown

Related Issue

#1947

Problem

The ACP thinking config option currently exposes only a binary off/on toggle, even for models that support multiple thinking effort levels (low, medium, high, etc.). The VS Code extension's ThinkingButton component already supports per-model effort selection, but the ACP adapter does not, leaving editor integrations like Zed with a coarser control than the first-party UI.

What changed

This PR aligns the ACP adapter's thinking control with apps/vscode/webview-ui/src/components/ThinkingButton.tsx:

  • Effort dropdown: when a model advertises supportEfforts, the thinking option now renders ['off', ...efforts] (e.g. off / low / medium / high), matching ThinkingButton's effort mode.
  • Binary fallback: models without effort lists keep the existing off / on select, equivalent to ThinkingButton's switch mode.
  • Locked-on state: alwaysThinking models collapse to a single on entry, equivalent to ThinkingButton's always-on mode.
  • Capitalized labels: option labels use the same capitalization style as ThinkingButton (Off, On, Low, Medium, …).

Implementation details:

  • packages/acp-adapter/src/model-catalog.ts: expose supportEfforts on AcpModelEntry, sourced from the model alias config or Anthropic model profile inference.
  • packages/acp-adapter/src/config-options.ts: buildThinkingOption now renders an effort dropdown when supportEfforts is present, falling back to binary off/on otherwise.
  • packages/acp-adapter/src/session.ts: adapter-side thinking state is now tracked as an effort string instead of a boolean, and setThinking accepts effort strings with 'on' normalized to the model default.
  • packages/acp-adapter/src/server.ts: resolveCurrentThinkingEffort returns the actual effort string; setSessionConfigOption({ configId: 'thinking', value }) passes the effort through.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b60a97d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4d31ea1588

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 117 to +120
name: 'Thinking',
category: 'thought_level',
currentValue: 'on',
options: [{ value: 'on', name: 'Thinking On' }],
options: [{ value: 'on', name: 'On' }],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Show effort choices for always-on effort models

When a catalog row has both alwaysThinking and supportEfforts, this early return runs before the effort-dropdown branch, so ACP exposes only a single on choice. Such rows are real: effectiveModelAlias assigns always_thinking for profiles with canDisableThinking === false while still copying profile.efforts (packages/agent-core/src/config/model.ts:41-56), and managed/open-platform models can also be supports_thinking_type='only' with efforts. In those environments the new ACP surface still hides the low/medium/high/... selector for effort-capable models; the always-on case should omit only off, not collapse all efforts to on.

Useful? React with 👍 / 👎.

Comment on lines +126 to +127
const normalizedEffort =
currentEffort !== 'off' && efforts.includes(currentEffort) ? currentEffort : 'off';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Don't render carried thinking effort as off

When currentEffort is any non-off value that is not declared by the currently selected model, this reports currentValue: 'off' without actually disabling thinking. For example, after selecting max on one model and switching to a Kimi model whose supportEfforts are only ['low','high'], AcpSession.setModel preserves the non-off adapter state while agent-core normalizes unsupported Kimi efforts to the target model default (packages/agent-core/src/agent/config/thinking.ts:79-81); the ACP snapshot then tells the client thinking is off even though the session will run with thinking on. Prefer the target/default effort for non-off carried values, or refresh the adapter state from the session after the model switch.

Useful? React with 👍 / 👎.

@cnctem
cnctem force-pushed the feat/acp-thinking-effort-levels branch from 4d31ea1 to 135341a Compare July 21, 2026 03:20
@cnctem

cnctem commented Jul 21, 2026

Copy link
Copy Markdown
Author

针对 Review 的两点修改如下:

1. always-thinking + supportEfforts 现在展示 effort 选项

文件packages/acp-adapter/src/config-options.ts

// 修改前
if (alwaysThinking) {
  return { currentValue: 'on', options: [{ value: 'on', name: 'On' }] };
}

// 修改后
if (alwaysThinking) {
  if (efforts.length > 0) {
    // 有 effort 列表时展示全部 effort,只去掉 off
    return {
      currentValue: normalizedEffort,
      options: efforts.map((effort) => ({ value: effort, name: label(effort) })),
    };
  }
  // 没有 effort 列表时才展示单个 On
  return { currentValue: 'on', options: [{ value: 'on', name: 'On' }] };
}

匹配 ThinkingButtonalwaysOn 行为:options = alwaysOn ? efforts : ['off', ...efforts]

2. 模型切换后遗留的 effort 映射到默认 effort,不再显示为 off

文件packages/acp-adapter/src/config-options.tsbuildSessionConfigOptions

const efforts = currentModelEntry?.supportEfforts;
let normalizedEffort = currentThinkingEffort;
if (
  normalizedEffort === 'off' ||
  (efforts !== undefined &&
    efforts.length > 0 &&
    !efforts.includes(normalizedEffort))
) {
  normalizedEffort =
    normalizedEffort === 'off'
      ? 'off'
      : (currentModelEntry?.defaultThinkingEffort ?? 'on');
}
if (alwaysThinking && normalizedEffort === 'off') {
  normalizedEffort = currentModelEntry?.defaultThinkingEffort ?? 'on';
}

逻辑:

  • off 保持 off
  • 'on' 或任何不在当前模型 supportEfforts 里的非 off 值 → 当前模型的 defaultThinkingEffort
  • always-thinking 模型永远不会展示 off

对应新增测试

文件packages/acp-adapter/test/config-options.test.ts

  • shows effort choices without an off entry for always-thinking models with supportEfforts
  • falls back to the first effort for always-thinking models when the current effort is unsupported
  • maps a carried unsupported effort to the target model default effort

@cnctem
cnctem force-pushed the feat/acp-thinking-effort-levels branch from bc112c0 to 86c4a59 Compare July 21, 2026 03:32
@cnctem
cnctem force-pushed the feat/acp-thinking-effort-levels branch from 86c4a59 to 7d31a96 Compare July 21, 2026 05:05
@cnctem

cnctem commented Jul 21, 2026

Copy link
Copy Markdown
Author

#1992 已经实现该功能,故关闭

@cnctem cnctem closed this Jul 21, 2026
@cnctem
cnctem deleted the feat/acp-thinking-effort-levels branch July 21, 2026 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant