From 481487a64063531c81e8c134fb648f2298eb706f Mon Sep 17 00:00:00 2001 From: wsp Date: Fri, 21 Aug 2026 12:40:05 +0800 Subject: [PATCH] feat(agents): make custom agent name optional Allow custom agents to omit a display name and fall back to the stable Agent ID when creating the agent. Keep the ID required for model identification, configuration, and routing, while clarifying that the name is display-only across supported locales. --- .../agents/components/CreateAgentPage.tsx | 29 ++++--------------- .../src/locales/en-US/scenes/agents.json | 9 +++--- .../src/locales/zh-CN/scenes/agents.json | 9 +++--- .../src/locales/zh-TW/scenes/agents.json | 9 +++--- 4 files changed, 17 insertions(+), 39 deletions(-) diff --git a/src/web-ui/src/app/scenes/agents/components/CreateAgentPage.tsx b/src/web-ui/src/app/scenes/agents/components/CreateAgentPage.tsx index 6d88a3d16a..4dca13f1ad 100644 --- a/src/web-ui/src/app/scenes/agents/components/CreateAgentPage.tsx +++ b/src/web-ui/src/app/scenes/agents/components/CreateAgentPage.tsx @@ -102,7 +102,6 @@ const CreateAgentPage: React.FC = () => { const [agentId, setAgentId] = useState(''); const [agentIdError, setAgentIdError] = useState(null); const [name, setName] = useState(''); - const [nameError, setNameError] = useState(null); const [description, setDescription] = useState(''); const [prompt, setPrompt] = useState(''); const [readonly, setReadonly] = useState(defaultReadonlyForKind('mode')); @@ -211,7 +210,6 @@ const CreateAgentPage: React.FC = () => { setPendingTools(null); setUserContextPolicy(new Set(detail.userContextPolicy)); setAgentIdError(null); - setNameError(null); } catch (error) { if (cancelled) { return; @@ -242,16 +240,6 @@ const CreateAgentPage: React.FC = () => { [t], ); - const validateName = useCallback( - (value: string) => { - if (!value.trim()) { - return t('agentsOverview.form.nameRequired'); - } - return null; - }, - [t], - ); - const toggleContextSection = useCallback((section: UserContextSection) => { setUserContextPolicy((prev) => { const next = new Set(prev); @@ -372,10 +360,8 @@ const CreateAgentPage: React.FC = () => { const handleSubmit = useCallback(async () => { const nextAgentIdError = validateAgentId(agentId); - const nextNameError = validateName(name); setAgentIdError(nextAgentIdError); - setNameError(nextNameError); - if (nextAgentIdError || nextNameError) { + if (nextAgentIdError) { return; } if (!description.trim()) { @@ -400,11 +386,13 @@ const CreateAgentPage: React.FC = () => { setSubmitting(true); try { + const normalizedId = agentId.trim(); + const effectiveName = name.trim() || normalizedId; const payload = { kind, level: kind === 'subagent' ? level : 'user', - id: agentId.trim(), - name: name.trim(), + id: normalizedId, + name: effectiveName, description: description.trim(), prompt: prompt.trim(), readonly, @@ -460,7 +448,6 @@ const CreateAgentPage: React.FC = () => { t, userContextPolicy, validateAgentId, - validateName, workspacePath, ]); @@ -612,16 +599,10 @@ const CreateAgentPage: React.FC = () => { value={name} onChange={(event) => { setName(event.target.value); - setNameError(validateName(event.target.value)); }} - onBlur={() => setNameError(validateName(name))} placeholder={t('agentsOverview.form.namePlaceholder')} inputSize="small" - error={!!nameError} /> - {nameError ? ( - {nameError} - ) : null} diff --git a/src/web-ui/src/locales/en-US/scenes/agents.json b/src/web-ui/src/locales/en-US/scenes/agents.json index 01ac732d33..93ac2d8923 100644 --- a/src/web-ui/src/locales/en-US/scenes/agents.json +++ b/src/web-ui/src/locales/en-US/scenes/agents.json @@ -294,13 +294,12 @@ "kind": "Kind", "kindAgentTooltip": "After creating it, you can select it directly as a standalone mode from the conversation input's mode picker.", "kindSubagentTooltip": "After creating it, a primary agent can delegate subtasks to it. It is not available as a directly selectable mode.", - "id": "ID", - "idPlaceholder": "Stable identifier used in config and routing", + "id": "Agent ID", + "idPlaceholder": "Used by the model, config, and routing; cannot be changed after creation", "idRequired": "ID is required", "idFormat": "Must start with a letter and contain only letters, numbers, underscores, or hyphens", - "name": "Name", - "namePlaceholder": "Human-readable display name", - "nameRequired": "Name is required", + "name": "Name (optional)", + "namePlaceholder": "Used for display only; defaults to the Agent ID", "level": "Level", "modeUserOnly": "Custom modes are always user-level in the current release.", "description": "Description", diff --git a/src/web-ui/src/locales/zh-CN/scenes/agents.json b/src/web-ui/src/locales/zh-CN/scenes/agents.json index 43090f568b..34954ddc35 100644 --- a/src/web-ui/src/locales/zh-CN/scenes/agents.json +++ b/src/web-ui/src/locales/zh-CN/scenes/agents.json @@ -294,13 +294,12 @@ "kind": "类型", "kindAgentTooltip": "创建后可在对话输入框的模式选择器中作为独立模式直接选择。", "kindSubagentTooltip": "创建后主 Agent 可通过委派它完成子任务;不会作为可直接选择的模式。", - "id": "ID", - "idPlaceholder": "用于配置和路由的稳定标识符", + "id": "Agent ID", + "idPlaceholder": "用于模型识别、配置和路由,创建后不可修改", "idRequired": "ID 不能为空", "idFormat": "只能以字母开头,包含字母/数字/下划线/连字符", - "name": "名称", - "namePlaceholder": "界面展示名称", - "nameRequired": "名称不能为空", + "name": "名称(选填)", + "namePlaceholder": "仅用于展示,留空时使用 Agent ID", "level": "级别", "modeUserOnly": "当前版本中,自定义 mode 仅支持用户级。", "description": "描述", diff --git a/src/web-ui/src/locales/zh-TW/scenes/agents.json b/src/web-ui/src/locales/zh-TW/scenes/agents.json index c6021dc99e..0e9e0a4e3d 100644 --- a/src/web-ui/src/locales/zh-TW/scenes/agents.json +++ b/src/web-ui/src/locales/zh-TW/scenes/agents.json @@ -294,13 +294,12 @@ "kind": "類型", "kindAgentTooltip": "建立後可在對話輸入框的模式選擇器中作為獨立模式直接選擇。", "kindSubagentTooltip": "建立後主 Agent 可透過委派它完成子任務;不會作為可直接選擇的模式。", - "id": "ID", - "idPlaceholder": "用於設定和路由的穩定識別符", + "id": "Agent ID", + "idPlaceholder": "用於模型識別、設定和路由,建立後不可修改", "idRequired": "ID 不能為空", "idFormat": "只能以字母開頭,包含字母/數字/下劃線/連字符", - "name": "名稱", - "namePlaceholder": "介面顯示名稱", - "nameRequired": "名稱不能為空", + "name": "名稱(選填)", + "namePlaceholder": "僅用於顯示,留空時使用 Agent ID", "level": "級別", "modeUserOnly": "目前版本中,自定義 mode 僅支援用戶級。", "description": "描述",