Agents configure page throws 500: credential schema of a custom API tool provider is requested via the builtin tool-provider route (PluginNo

该报错通常发生在 Dify 新版 Agents 平台中,Agent 引用了自定义 API 工具提供商(custom API tool provider)后,打开 /agents//configure 配置页时触发。优先排查 Agent 的 configure 页在解析工具授权时,

快速结论:该报错通常发生在 Dify 新版 Agents 平台中,Agent 引用了自定义 API 工具提供商(custom API tool provider)后,打开 /agents/<agent_id>/configure 配置页时触发。优先排查 Agent 的 configure 页在解析工具授权时,是否把 provider_type: "api" 的工具错误地走成了 /builtin/ 凭据 schema 路由。

适用环境:Dify 1.16.0-rc1,Docker Compose 自托管部署;Issue 中记录的相关组件为 plugin-daemon 0.6.3-local、agent-backend 1.16.0-rc1。Issue 未提供 Python、CUDA、显卡等信息,不应额外假设。

最快修复方案:暂无确认的一步修复方案。Issue 将该问题定位为前端路由缺陷(缺少 api 类型提供商的凭据 schema 处理路径),因此没有现成的配置项或命令可以直接绕过。

注意事项:该问题仅影响 configure 页的加载与状态提示,“Chat and actual tool invocation work fine”,即聊天与实际工具调用可以正常使用。由于后端只为 builtin 提供商注册了 credential schema 路由,修复需要前后端配合,不能只靠前端单点改动。

问题场景

用户在 Dify 1.16.0-rc1 自托管环境中,先创建了一个使用 API Key header 鉴权的自定义 API 工具提供商(Tools → Custom → 导入 OpenAPI schema),测试调用成功。随后在新版 Agents 平台创建 Agent,并从该自定义提供商添加多个工具。此后每次打开该 Agent 的 configure 页(/agents/<agent_id>/configure)都会弹出 Internal Server Error,请求重试 3 次,同时 “Configuration” 菜单项持续显示警告标记。数据库中可以确认该提供商 ID 只存在于 tool_api_providers,tool_builtin_providers 表为空。

报错原文

GET /console/api/workspaces/current/tool-provider/builtin/730b5917-e9c5-43ae-9985-962361bc39fd/credential/schema/api-key  → 500
Referer: http://<dify-host>/agents/019f6a2d-d92a-7d0a-a92e-4fc65b12ec2c/configure

Exception on /console/api/workspaces/current/tool-provider/builtin/730b5917-e9c5-43ae-9985-962361bc39fd/credential/schema/api-key [GET]
Traceback (most recent call last):
  ...
  File "/app/api/controllers/console/workspace/tool_providers.py", line 851, in get
    BuiltinToolManageService.list_builtin_provider_credentials_schema(
  ...
  File "/app/api/core/plugin/impl/base.py", line 389, in _handle_plugin_daemon_error
    raise PluginNotFoundError(description=message)
core.plugin.impl.exc.PluginNotFoundError: req_id: 72be2f3cef PluginNotFoundError: plugin not found

原因分析

根据 Issue 与维护者回复的分析,Agents 配置页在解析工具授权时无条件使用了 builtin 提供商的凭据 schema 路由,没有针对 api 类型提供商的分支:

  • 前端 web/service/tools.ts 中的 fetchBuiltInToolCredentialSchema() 固定拼出包含 /builtin/ 的 URL,且不存在面向 API 提供商的等价函数。
  • web/app/components/tools/setting/build-in/config-credentials.tsx 调用该函数时未检查 provider_type。
  • 后端只为 builtin 提供商注册了 GET /tool-provider/builtin/{provider}/credential/schema/{credential_type},API 提供商只有 POST /tool-provider/api/schema(返回凭据与参数),没有对应路由。

结果就是 api 容器拿着 tool_api_providers 中的 UUID 去插件守护进程查询一个不可能存在的插件(plugin_id=langgenius/<uuid>),最终抛出 PluginNotFoundError 并返回 500。Issue 还指出,Agent 草稿配置 config_snapshot 中的工具本身记录正确(provider_type: "api"),但 credential_type 为 unauthorized、credential_ref 为 null,这也是配置页持续显示警告标记的原因。

环境排查

  • 确认 Dify 版本是否为 1.16.0-rc1 或同系列版本。
  • 确认部署方式为 Docker Compose 自托管。
  • 确认 plugin-daemon 与 agent-backend 版本与 Dify 主版本匹配(Issue 中为 0.6.3-local / 1.16.0-rc1)。
  • 核对 tool_api_providers 与 tool_builtin_providers 两张表,确认出问题的提供商 ID 存在于前者而非后者。
  • 检查浏览器 Network 面板中失败请求的路径是否包含 /tool-provider/builtin/<uuid>/credential/schema/...,且该 UUID 属于自定义 API 提供商。
  • 检查 Agent 草稿配置 config_snapshot 中工具的 provider_type、credential_type、credential_ref 是否正确。

解决步骤

  1. 先确认问题范围:在浏览器开发者工具中查看 configure 页加载时失败的请求 URL,若其中 /builtin/ 后跟的是自定义 API 提供商的 UUID,即可对应到本 Issue。
  2. 通过数据库查询核对提供商归属:select id, name from tool_api_providers; 与 select id, provider from tool_builtin_providers;,确认该 UUID 不是 builtin 提供商。
  3. 确认聊天与实际工具调用是否仍然正常;若正常,说明问题集中在前端 configure 页的授权解析逻辑,不影响实际使用。
  4. 在包含修复的版本发布前,可优先尝试:在 configure 页触发请求时按 provider_type 区分处理,对 api 类型跳过 builtin 凭据 schema 拉取(因其使用标准化的 api_key header/query/none 鉴权),或改为调用 API 提供商对应的接口。此改动属于前端逻辑调整,Issue 未给出已验证补丁。
  5. 如果自行维护分支代码,需要同时检查 web/service/tools.ts、config-credentials.tsx、工作流工具节点中的 use-config.ts 与 auth.ts,确保这些位置都补齐 provider_type 判断。
  6. 更新到包含该修复的 Dify 版本后,清除浏览器缓存并重新打开 Agent configure 页验证。

验证方法

重新打开 /agents/<agent_id>/configure,确认不再出现 Internal Server Error 弹窗,Network 面板中不再向 /tool-provider/builtin/<custom-provider-id>/credential/schema/... 发起请求(或该请求返回非 500),且 “Configuration” 菜单项的警告标记消失。同时再次测试聊天与实际工具调用,确认功能未受改动影响。

参考来源

langgenius/dify #39169

GamsGo AI

AI 工具推荐

想把多个 AI 模型放在一个入口?

GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。

了解 GamsGo AI

推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。

这个方案解决了吗?

celebrityanime
celebrityanime
文章: 33435

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注