✨ Feature: add agent repository page and APIs#3289
Conversation
Introduce Agent Repository backend APIs, database/service support, frontend views, client services, and tests. Migrate Agent Space navigation and permissions to /agent-repository with updated SQL and localization.
Introduce Agent Repository backend APIs, database/service support, frontend views, client services, and tests. Migrate Agent Space navigation and permissions to /agent-repository with updated SQL and localization.
🔍 Code Review Comments1. [安全/漏洞] options API 缺少权限过滤 2. [逻辑漏洞] CSV group_ids 子串误匹配 3. [代码规范] f-string 日志格式 |
YehongPan
left a comment
There was a problem hiding this comment.
Code Review
- [安全/漏洞]
list_agent_repository_options_api返回的 options 数据(categories/icons/tags)未做权限过滤,所有登录用户均可获取完整预设列表,应确认是否符合设计意图。 - [逻辑漏洞]
_build_group_ids_overlap_condition使用LIKE '%,gid,%'匹配 CSV 格式的 group_ids,当 group_id 是另一个 group_id 的子串时(如 id=1 匹配 id=11),会产生误匹配。应改用 PostgreSQL 数组类型或 JSON 数组。 - [代码规范]
agent_repository_app.py中多处使用logger.error(f"...")的 f-string 日志格式,应改为logger.error("...", exc_info=True)以保留异常堆栈信息。
|
Agent repository is a large feature addition (27 files, +5497/-1054). The architectural split of agent templates into a dedicated repository layer needs careful review of the migration path for existing agents. Please confirm backward compatibility with existing agent configurations. |
Introduce Agent Repository backend APIs, database/service support, frontend views, client services, and tests. Migrate Agent Space navigation and permissions to /agent-repository with updated SQL and localization.
Introduce Agent Repository backend APIs, database/service support, frontend views, client services, and tests. Migrate Agent Space navigation and permissions to /agent-repository with updated SQL and localization.
Introduce Agent Repository backend APIs, database/service support, frontend views, client services, and tests. Migrate Agent Space navigation and permissions to /agent-repository with updated SQL and localization.
WMC001
left a comment
There was a problem hiding this comment.
Bug 1 (HIGH): Status enum values changed — breaking API change
backend/database/agent_repository_db.py lines 266-269 — status constants were renamed from uppercase to lowercase:
# Before
STATUS_NOT_SHARED = "NOT_SHARED"
STATUS_PENDING_REVIEW = "PENDING_REVIEW"
STATUS_REJECTED = "REJECTED"
STATUS_SHARED = "SHARED"
# After
STATUS_NOT_SHARED = "not_shared"
STATUS_PENDING_REVIEW = "pending_review"
STATUS_REJECTED = "rejected"
STATUS_SHARED = "shared"Any existing integrations that check or send these status strings (e.g., status == "NOT_SHARED") will silently break. This needs a migration strategy or backward-compatible aliasing.
WMC001
left a comment
There was a problem hiding this comment.
Bug 2 (MEDIUM): Missing logger in agent_repository_app.py
backend/apps/agent_repository_app.py — import logging and logger = logging.getLogger(...) were removed. The app no longer logs errors for unexpected exceptions. Ensure logging is added back or confirm this is intentional.
WMC001
left a comment
There was a problem hiding this comment.
Bug 4 (MEDIUM): AgentImportWizard removed from MineAgentsView without replacement
frontend/app/[locale]/agent-space/components/MineAgentsView.tsx — the AgentImportWizard modal was deleted. Users can no longer import agents from the agent-space page. Either re-add the wizard or confirm the import flow is handled elsewhere.
WMC001
left a comment
There was a problem hiding this comment.
Bug 3 (MEDIUM): source_version_no renamed to version_no — field name change
Multiple places in agent_repository_service.py and agent_repository_db.py — source_version_no was renamed to version_no. Any external callers (frontend, other services) that reference source_version_no in API payloads or responses will break. Verify all API contracts and frontend code are updated to use the new field name.
WMC001
left a comment
There was a problem hiding this comment.
Bug 5 (LOW): category_id defaults to 0 in request model
backend/consts/model.py — AgentRepositoryListingCreateRequest.category_id defaults to 0, but the validation in _validate_card_fields checks if category_id is None or not isinstance(category_id, int). A category_id of 0 passes the isinstance check, which may allow invalid zero-value category IDs to reach the database.
WMC001
left a comment
There was a problem hiding this comment.
Bug 6 (CRITICAL): SQL migration missing columns — inserts/updates will crash
docker/sql/v2.2.1_0605_add_ag_agent_repository_t.sql — the migration creates the table but is missing three columns that all Python code writes to: submitted_by, icon, and downloads. Compare against docker/init.sql and db_models.py which define all three.
Any tenant running this migration on an existing database will get column "submitted_by" does not exist errors on every insert and update. Add the missing column definitions:
, submitted_by VARCHAR(100)
, icon VARCHAR(100)
, downloads INTEGER DEFAULT 0
WMC001
left a comment
There was a problem hiding this comment.
Bug 7 (CRITICAL): Duplicate TypeScript interface declaration
frontend/types/agentRepository.ts — AgentRepositoryListingCreatePayload is declared twice. TypeScript will emit a compile error on the duplicate identifier. Remove the second declaration.
WMC001
left a comment
There was a problem hiding this comment.
Bug 8 (MEDIUM): submitted_by gets overwritten on every re-share
backend/database/agent_repository_db.py — submitted_by is not in _UPSERT_IMMUTABLE_FIELDS, so it gets overwritten on every upsert. The field should be set only when the listing first enters pending_review and preserved on subsequent re-shares. Add "submitted_by" to _UPSERT_IMMUTABLE_FIELDS to preserve the original submitter's email.
WMC001
left a comment
There was a problem hiding this comment.
Bug 9 (MEDIUM): group_ids column referenced but may not exist
backend/database/agent_repository_db.py — _build_group_ids_overlap_condition references AgentInfo.group_ids, but there is no migration in this PR adding that column to ag_tenant_agent_t. For non-ADMIN users, every call to list_my_editable_agents_impl will crash with column ag_tenant_agent_t.group_ids does not exist. Either add a migration or add a defensive fallback.















Introduce Agent Repository backend APIs, database/service support, frontend views, client services, and tests. Migrate Agent Space navigation and permissions to /agent-repository with updated SQL and localization.