Skip to content

fix(agent): sync provider filter with model support#16710

Merged
0xfullex merged 9 commits into
mainfrom
zhangjiadi225/fix-agent-model-filter-v2
Jul 6, 2026
Merged

fix(agent): sync provider filter with model support#16710
0xfullex merged 9 commits into
mainfrom
zhangjiadi225/fix-agent-model-filter-v2

Conversation

@zhangjiadi225

Copy link
Copy Markdown
Collaborator

🚨 Branch strategy — read before opening this PR

The v2 refactor has merged into main, so main is the default branch for active development (v1 and v2 code currently coexist there — expect large, breaking changes).

  • Active development (features, refactors, optimizations, fixes for the current codebase) → target main (the default base).
  • v1 maintenance (hotfixes and subsequent v1 releases) → branch from and target v1, not main.

A v1 fix does not auto-carry to main: if the same bug exists on main, open a separate forward-port PR targeting main. Before touching subsystems being replaced, read docs/references/data/ and watch for @deprecated markers — they flag code being deleted.

What this PR does

Before this PR:

The provider settings Agent filter only showed providers with an Anthropic Messages endpoint, even though Claude Code agents can use gateway-routable chat providers.

After this PR:

The Agent filter uses the same shared provider support predicate as the agent model picker. Gateway-routable chat providers remain visible, while Gemini providers stay excluded because the runtime rejects them.

Fixes # N/A

Why we need it and why it was done in this way

The settings page should match the actual agent runtime and model picker behavior so users are not steered back to an obsolete Anthropic-only mental model.

The following tradeoffs were made:

Kept the support predicate intentionally small and aligned with the current runtime constraint: Gemini providers remain unsupported; other chat providers can route through the local API Gateway when needed.

The following alternatives were considered:

Keeping the settings filter Anthropic-only was rejected because it conflicts with current runtime routing. Duplicating the filter logic in the settings page was rejected in favor of a shared provider predicate.

Links to places where the discussion took place: N/A

Breaking changes

If this PR introduces breaking changes, please describe the changes and the impact on users.

N/A

Special notes for your reviewer

Targeted checks run:

  • pnpm exec vitest run --project renderer src/renderer/pages/settings/ProviderSettings/__tests__/ProviderList.test.tsx src/renderer/hooks/agent/__tests__/useAgentModelFilter.test.ts
  • pnpm i18n:check
  • pnpm lint
  • pnpm format

Intentionally not run by user override:

  • pnpm build:check
  • full test suites such as pnpm test

Checklist

This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.

  • Branch: This PR targets the correct branch — main for active development, v1 for v1 maintenance fixes
  • PR: The PR description is expressive enough and will help future contributors
  • Code: Write code that humans can understand and Keep it simple
  • Refactor: You have left the code cleaner than you found it (Boy Scout Rule)
  • Upgrade: Impact of this change on upgrade flows was considered and addressed if required
  • Documentation: A user-guide update was considered and is present (link) or not required. Check this only when the PR introduces or changes a user-facing feature or behavior.
  • Self-review: I have reviewed my own code (e.g., via /gh-pr-review, gh pr diff, or GitHub UI) before requesting review from others

Release note

Agent-supported provider filtering now includes gateway-routable chat providers instead of only Anthropic endpoint providers. Gemini providers remain excluded.

@zhangjiadi225 zhangjiadi225 marked this pull request as ready for review July 3, 2026 08:29
@zhangjiadi225 zhangjiadi225 requested review from a team, AtomsH4 and eeee0717 July 3, 2026 08:29

@eeee0717 eeee0717 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed head aff32d4.

No substantive issues found. The agent provider filter and provider-list filter now share the same runtime-support predicate, Gemini remains excluded, and the PR includes a targeted provider-list regression test. GitHub CI relevant checks are passing; general-test is skipped.

@AtomsH4 AtomsH4 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This review was translated automatically.

Blocker

None.

Warning

  • src/renderer/hooks/agent/useAgentModelFilter.ts:42 - Agent model filtering allows all non-Gemini providers approved by isAgentSupportedProvider(), but Claude Code runtime will still reject cherryai::qwen.
    Failure path: CherryAI default provider/model is an enabled chat model; after the model selector allows it per the filter, Claude Code runtime goes through the gateway, and src/main/ai/runtime/claudeCode/agentSessionWarmup.ts:198 will throw CherryAI managed default model is not available through the API gateway via isManagedCherryAiDefaultModel().
    Minimal fix: Make the Agent model filter share the same support determination logic with the runtime, at minimum excluding the managed CherryAI default model, and add a useAgentModelFilter test case covering cherryai::qwen.

Notice

None.

Focused Tests

  • Sub-agent ran: pnpm exec vitest run --project renderer src/renderer/pages/settings/ProviderSettings/__tests__/ProviderList.test.tsx src/renderer/hooks/agent/__tests__/useAgentModelFilter.test.ts, 2 files / 15 tests passed.

Original Content

Blocker

无。

Warning

  • src/renderer/hooks/agent/useAgentModelFilter.ts:42 - Agent 模型过滤会放行所有 isAgentSupportedProvider() 认可的非 Gemini provider,但 Claude Code runtime 仍会拒绝 cherryai::qwen
    Failure path: CherryAI 默认 provider/model 是 enabled chat model;模型选择器按该 filter 放行后,Claude Code runtime 走 gateway,src/main/ai/runtime/claudeCode/agentSessionWarmup.ts:198 会通过 isManagedCherryAiDefaultModel() 抛出 CherryAI managed default model is not available through the API gateway
    Minimal fix: 让 Agent 模型过滤器与 runtime 共用同一支持判定,至少排除 managed CherryAI default model,并补一个 useAgentModelFilter 用例覆盖 cherryai::qwen

Notice

无。

Focused Tests

  • 子 agent ran: pnpm exec vitest run --project renderer src/renderer/pages/settings/ProviderSettings/__tests__/ProviderList.test.tsx src/renderer/hooks/agent/__tests__/useAgentModelFilter.test.ts,2 files / 15 tests passed。

Signed-off-by: jd <59188306+zhangjiadi225@users.noreply.github.com>
@zhangjiadi225

Copy link
Copy Markdown
Collaborator Author

Addressed in fda79f5.

  • Agent model filtering now uses a shared runtime-support predicate that rejects non-chat models, unsupported providers, and the managed CherryAI default model.
  • Added a regression test covering cherryai::qwen in useAgentModelFilter.

Validation:

  • pnpm exec vitest run --project renderer src/renderer/pages/settings/ProviderSettings/__tests__/ProviderList.test.tsx src/renderer/hooks/agent/__tests__/useAgentModelFilter.test.ts
  • pnpm lint
  • pnpm format

@zhangjiadi225 zhangjiadi225 requested a review from AtomsH4 July 3, 2026 11:39
@kangfenmao kangfenmao added the ready-to-merge This PR has sufficient reviewer approvals but is awaiting code owner approval. label Jul 3, 2026
@0xfullex 0xfullex removed the ready-to-merge This PR has sufficient reviewer approvals but is awaiting code owner approval. label Jul 3, 2026
zhangjiadi225 and others added 2 commits July 3, 2026 21:20
…nt-model-filter-v2

Signed-off-by: jd <59188306+zhangjiadi225@users.noreply.github.com>

# Conflicts:
#	src/renderer/hooks/agent/__tests__/useAgentModelFilter.test.ts
#	src/renderer/hooks/agent/useAgentModelFilter.ts

@AtomsH4 AtomsH4 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This review was translated automatically.

Reviewed current head e958f8fe.

Blocker: None.
Warning: None.
Notice: None.

The previous issue has been fixed: useAgentModelFilter now calls the shared isAgentRuntimeSupportedModel(); this logic filters non-chat models, Gemini provider, and CherryAI managed default models matched by isManagedCherryAiDefaultModel(providerId, rawModelId). New tests have covered that cherryai::qwen should not appear in the Claude Code agent model selector.

Focused Tests: Attempted to run src/renderer/pages/settings/ProviderSettings/__tests__/ProviderList.test.tsx and src/renderer/hooks/agent/__tests__/useAgentModelFilter.test.ts, but the local temporary worktree + main workspace dependency symlink environment failed at the Vitest worker entry resolution stage, and the test body was not executed. PR CI currently shows basic-checks passed, render-test still pending.


Original Content

已复核当前 head e958f8fe

Blocker:无。
Warning:无。
Notice:无。

此前问题已修复:useAgentModelFilter 现在调用共享的 isAgentRuntimeSupportedModel();该逻辑会过滤非 chat 模型、Gemini provider,以及 isManagedCherryAiDefaultModel(providerId, rawModelId) 命中的 CherryAI managed default model。新增测试已覆盖 cherryai::qwen 不应出现在 Claude Code agent 模型选择器中。

Focused Tests:尝试运行 src/renderer/pages/settings/ProviderSettings/__tests__/ProviderList.test.tsxsrc/renderer/hooks/agent/__tests__/useAgentModelFilter.test.ts,但本地临时 worktree + 主工作区依赖软链环境在 Vitest worker 入口解析阶段失败,测试体未执行。PR CI 当前 basic-checks 已通过,render-test 仍 pending。

…nt-model-filter-v2

Signed-off-by: jd <59188306+zhangjiadi225@users.noreply.github.com>
Signed-off-by: jd <59188306+zhangjiadi225@users.noreply.github.com>
@zhangjiadi225 zhangjiadi225 added the ready-to-merge This PR has sufficient reviewer approvals but is awaiting code owner approval. label Jul 6, 2026
@0xfullex 0xfullex merged commit cdf679e into main Jul 6, 2026
7 checks passed
@0xfullex 0xfullex deleted the zhangjiadi225/fix-agent-model-filter-v2 branch July 6, 2026 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge This PR has sufficient reviewer approvals but is awaiting code owner approval.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants