能力选择器里系统预置 agent(通用助手/Deep Research/图片生成)重复出现
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 0
- Avg merge
- 1h 7m
- Merged PRs (30d)
- 969
Description
## 现象
用户在画布的能力选择器(chat 任务面板 @ 提及 agent 的下拉列表)里看到系统预置 agent 重复:
- "图片生成" 出现两次(一份描述"根据文字描述生成图片",一份描述直接是"图片生成")
- "通用助手" 出现两次(一份描述"通用对话与任务协助,新组织的默认可聊 agent",一份描述"通用助手")
- "Deep Research" 出现两次(缩写分别是 DR / DE,描述分别是"多轮深度检索与调研综述" / "Deep Research")
## 根因
`pg-capability-repository.ts` 的 `listByKind`/`listAll`/`findById` 把调用者自己 org 与平台组织
`org-platform` 的 `capability_listings` 行用 `OR` 合并返回——这个合并原本只为
design-delta `platform-owned-skills`(官方 skill 对所有 org 共享)设计,注释也写着
"今天平台组织下只有 skill 行",但没有在 SQL 层用 `kind='skill'` 机械限定。
与此同时,`backfill-{default-agents,deep-research-agent,image-gen-agent}.ts` 三个 backfill
脚本的候选组织查询没有排除 `org-platform`;而平台组织唯一成员 `svc-platform-templates` 的
`org_role` 是 `admin`(见 `ensure-platform-skill-catalog.ts`),于是被当成"缺系统 agent 的
普通组织",三个系统 agent 被误种进了平台组织。这份平台组织副本又被上面那条不限 kind 的 OR
合并进了每一个真实 org 的能力选择器,造成同名 agent 重复出现。
## 修复
- `pg-capability-repository.ts`:把平台组织合并限定为 `kind = 'skill'`,agent/MCP/其它 kind
只读调用者自己的 org。
- 三个 backfill 脚本:候选查询显式排除 `PLATFORM_ORG_ID`。
- 新增 `scripts/cleanup-platform-org-agent-duplicates.ts`:一次性清理已经误种进
`org-platform` 的三个系统 agent 及其 `agent_versions`/`capability_listings` 行(幂等,
手动执行,不接入自动 deploy 路径)。
Refs #(本 issue)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading pg-capability-repository.ts and the three backfill-{default-agents,deep-research-agent,image-gen-agent}.ts scripts to trace the organization queries and listing merge. Then inspect scripts/cleanup-platform-org-agent-duplicates.ts and run it manually as documented by the issue. Done means platform-owned skills still appear for organizations, system agents are excluded from org-platform backfills, and the three duplicate agents and related rows are removed idempotently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100