Skip to content

fix(acp): normalize model ids with /enabled /disabled status suffixes#3312

Open
whitelonng wants to merge 2 commits into
iOfficeAI:mainfrom
whitelonng:whitelonng/fix/acp-model-suffix
Open

fix(acp): normalize model ids with /enabled /disabled status suffixes#3312
whitelonng wants to merge 2 commits into
iOfficeAI:mainfrom
whitelonng:whitelonng/fix/acp-model-suffix

Conversation

@whitelonng

Copy link
Copy Markdown

Summary

  • Some ACP agents (e.g. CodeBuddy) report each model twice with a status suffix on the id (glm-5.1/enabled, glm-5.1/disabled) and label (GLM-5.1 (enabled)). These raw ids flowed untouched into the model selector, setModel requests, handshake-derived defaults and the persisted preferredModelId, causing duplicate dropdown entries and model switches that always fell back to the first model.
  • Adds normalizeAcpModelInfo / normalizeAcpModelId (packages/desktop/src/renderer/utils/model/normalizeAcpModelInfo.ts) which strips the suffixes and deduplicates by clean id, preferring the /enabled variant when both are present.
  • Applies the normalization at every point where ACP model info enters the renderer: getModel/setModel responses and acp_model_info stream events (useAcpModelInfo), handshake fallbacks (useAcpModelInfo, useDetectedAgents, useGuidAgentSelection, CreateTaskDialog, createConversationParams, teamCreateModelResolver), and saved preferredModelId reads — so already-polluted persisted data is also repaired on read.

Fixes #3297

Test plan

  • New unit tests in tests/unit/renderer/normalizeAcpModelInfo.test.ts covering suffix stripping (case-insensitive), dedup with /enabled preference, clean-list passthrough, vendor-prefixed ids (vendor/model-name untouched), and empty-label fallback
  • bunx vitest run — 1377 tests pass
  • bunx tsc --noEmit, bun run lint, bun run format, i18n checks pass
  • Manual: with a CodeBuddy ACP agent, verify the model dropdown shows each model once with a clean label, and switching to a non-default model sticks across subsequent turns

Some ACP agents (e.g. CodeBuddy) report each model twice with a status
suffix on the id ("glm-5.1/enabled", "glm-5.1/disabled") and label
("GLM-5.1 (enabled)"). The raw ids flowed untouched into the model
selector, setModel requests, handshake-derived defaults and the
persisted preferredModelId, causing duplicate dropdown entries and
model switches that always fell back to the first model.

Strip the suffixes and deduplicate by clean id (preferring the
/enabled variant) at every point where ACP model info enters the
renderer: getModel/setModel responses, acp_model_info stream events,
handshake fallbacks, and saved preferredModelId reads.

Fixes iOfficeAI#3297
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

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.

[Bug]: CodeBuddy 模型名称带 /enabled /disabled 后缀,导致模型栏出现重复条目且后续对话无法执行

1 participant