Skip to content

fix(providers): guard deleting provider referenced by active default model - #602

Open
angri450 wants to merge 1 commit into
TencentCloud:developfrom
angri450:feature/provider-delete-guard
Open

angri450 wants to merge 1 commit into
TencentCloud:developfrom
angri450:feature/provider-delete-guard

Conversation

@angri450

@angri450 angri450 commented Sep 7, 2026

Copy link
Copy Markdown

问题

删除 provider 时只检查了 agent 引用(find_agents_using_provider),漏了 settings 表的全局默认模型 active_model。当 active_model 指向被删的 provider 时(没有 agent 显式 pin 它),删除后所有对话回合的默认模型解析失败——用户无提示地看到"模型调用多次重试后仍失败"。

修复

admin_delete_provider 里补一道检查:settings_repo.get_active_model() 引用了该 provider 则拒绝删除(PROVIDER_REFERENCED,details 带 active_model 引用),提示先切换默认模型。

验证

  • 单测 3 场景:删除 active_model 引用的 provider 被拒(带提示)、删除未引用 provider 放行、active_model 未设置放行
  • 实测:删除当前 active_model 引用的 provider → HTTP 409 + 提供商正在使用中,无法删除 + details 带 active_model: 主对话模型/deepseek-v4-flash

…model

Deleting a provider that settings.active_model points at left a dead ref:
every subsequent turn failed to resolve the default model with no hint
(agents report 'model call failed after retries'). Guard it the same way
as agent refs - reject with PROVIDER_REFERENCED and tell the admin to
switch the default model first.
Copilot AI lite review requested due to automatic review settings September 7, 2026 16:20

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants