feat: allow specifying custom agent_id when creating experts - #121
Open
miaowmint wants to merge 5 commits into
Open
feat: allow specifying custom agent_id when creating experts#121miaowmint wants to merge 5 commits into
miaowmint wants to merge 5 commits into
Conversation
Collaborator
|
这个是否考虑加一个对输入id的规范校验? |
- API: add agent_id field to AgentCreateBody, FromExpertBody, and pass to create specs - CLI: add --agent-id option to 'octop agent create' and 'octop agent from-expert' - Market creation: add agent_id to SkillHubMarketAgentCreateOptions - Dashboard: add agent_id input field in CreateFromExpertDrawer form - i18n: add English and Chinese translations for agent_id field The agent_id is optional. When omitted, a random ID is auto-generated as before. When provided, it must be unique or AGENT_BUSY error is returned.
Previously, clicking 'Install' on a market expert card immediately created the agent with a random ID. Now a modal dialog is shown first, allowing the user to optionally specify a custom agent ID before creation. - ExpertMarketTab: replace direct createMarketExpert() calls with handleOpenCreateModal(), add Modal with Form for agent_id input - expertMarket.ts: add CreateMarketExpertBody type import - i18n: add marketCreateModalTitle and marketCreateModalHint keys
- Backend: Pydantic field_validator checks format (starts with alphanumeric, only letters/numbers/hyphens/underscores, 1-64 chars, auto-trim) - Frontend: Ant Design form rule with pattern + length validation - i18n: Chinese and English error messages for invalid/toolong cases
Move setCreateModalOpen(false) after createMarketExpert() completes so the confirmLoading spinner actually shows during creation. Also clean up pendingExpert after completion.
miaowmint
force-pushed
the
feature/custom-agent-id
branch
from
August 1, 2026 05:53
3595190 to
237c560
Compare
Contributor
Author
加了,顺便给从市场安装专家的时候也改了,不直接安装,加了个自定义ID的输入框 |
Wrap long lines for --agent-id option decorators and from_expert function signature to satisfy project line-length limit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
允许用户在通过 API、CLI 和 Dashboard 创建 Expert(专家)/ Agent(智能体)时,自定义指定 Agent ID。
AgentCreateSpec和AgentManager.create()本身已经支持传入agent_id参数,但此前该能力并未对 API、CLI 用户以及 Dashboard 前端开放。本次修改将这一能力贯穿至所有入口,并增加了统一的输入校验。变更内容
后端(Python)
src/octop/api/routers/agents.pyAgentCreateBody添加agent_id字段,并使用 Pydantic 进行校验(正则、长度、去除首尾空格)src/octop/api/routers/experts.pyFromExpertBody添加agent_id字段,使用相同校验规则,并在创建流程中透传src/octop/cli/commands/agent.pycreate和from-expert命令新增--agent-id参数src/octop/infra/agents/experts/market_creation.pySkillHubMarketAgentCreateOptions添加agent_id字段,并传递至创建配置前端(TypeScript)
dashboard/src/.../CreateFromExpertDrawer.tsxdashboard/src/.../ExpertMarketTab.tsxdashboard/src/api/modules/expertMarket.tsCreateMarketExpertBody添加agent_id字段dashboard/src/locales/en.jsondashboard/src/locales/zh.json校验规则
^[a-zA-Z0-9][a-zA-Z0-9_-]*$AgentManager.create()返回AGENT_BUSY错误使用入口
POST /api/agents{"agent_id": "my-id"}POST /api/agents/from-expert/{id}{"agent_id": "my-id"}POST /api/experts/hub/{slug}/install{"agent_id": "my-id"}octop agent create--agent-id my-idoctop agent from-expert--agent-id my-idSummary
Allow users to specify a custom ID when creating experts/agents via API, CLI, and dashboard UI.
The
AgentCreateSpecandAgentManager.create()already support a user-providedagent_idparameter. However, this parameter was not exposed to API consumers, CLI users, or the dashboard frontend. This PR wires it through all layers and adds input validation.Changes
Backend (Python)
src/octop/api/routers/agents.pyagent_idfield toAgentCreateBodywith Pydantic validator (regex, length, trim)src/octop/api/routers/experts.pyagent_idfield toFromExpertBodywith same validator; pass through in create flowssrc/octop/cli/commands/agent.py--agent-idoption tocreateandfrom-expertcommandssrc/octop/infra/agents/experts/market_creation.pyagent_idtoSkillHubMarketAgentCreateOptionsand pass to create specFrontend (TypeScript)
dashboard/src/.../CreateFromExpertDrawer.tsxdashboard/src/.../ExpertMarketTab.tsxdashboard/src/api/modules/expertMarket.tsagent_idtoCreateMarketExpertBodytypedashboard/src/locales/en.jsondashboard/src/locales/zh.jsonValidation Rules
^[a-zA-Z0-9][a-zA-Z0-9_-]*$AGENT_BUSYerror fromAgentManager.create()Entry Points
POST /api/agents{"agent_id": "my-id"}in bodyPOST /api/agents/from-expert/{id}{"agent_id": "my-id"}in bodyPOST /api/experts/hub/{slug}/install{"agent_id": "my-id"}in bodyoctop agent create--agent-id my-idoctop agent from-expert--agent-id my-id