Skip to content

Commit 26b40e6

Browse files
authored
✨ Agent duplicate name handling logic improvement #1622
2 parents 67982d2 + ef19880 commit 26b40e6

File tree

14 files changed

+2687
-329
lines changed

14 files changed

+2687
-329
lines changed

backend/apps/agent_app.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ async def import_agent_api(request: AgentImportRequest, authorization: Optional[
134134
import an agent
135135
"""
136136
try:
137-
await import_agent_impl(request.agent_info, authorization)
137+
await import_agent_impl(
138+
request.agent_info,
139+
authorization,
140+
force_import=request.force_import
141+
)
138142
return {}
139143
except Exception as e:
140144
logger.error(f"Agent import error: {str(e)}")

backend/consts/model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ class ExportAndImportDataFormat(BaseModel):
341341

342342
class AgentImportRequest(BaseModel):
343343
agent_info: ExportAndImportDataFormat
344+
force_import: bool = False
344345

345346

346347
class ConvertStateRequest(BaseModel):

backend/prompts/utils/prompt_generate.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,49 @@ USER_PROMPT: |-
249249
{% else %}
250250
你没有可用的助手
251251
{% endif %}
252+
253+
254+
AGENT_NAME_REGENERATE_SYSTEM_PROMPT: |-
255+
### 你是【Agent变量名调整专家】
256+
你的工作是根据任务描述以及已有变量名,生成一个语义一致但不重复的 Python 变量名。
257+
258+
#### 约束
259+
1. 变量名只能包含字母、数字和下划线,并且以字母或下划线开头,以“_assistant”结尾,长度不超过 30 个字符。
260+
2. 避免与已有变量名重复,同时保持与原始名称相近的语义。
261+
3. 仅输出变量名本身,不要附加额外解释或标点。
262+
263+
264+
AGENT_NAME_REGENERATE_USER_PROMPT: |-
265+
### 任务描述
266+
{{ task_description }}
267+
268+
### 原始变量名
269+
{{ original_value }}
270+
271+
### 已有变量名
272+
{{ existing_values }}
273+
274+
请在满足约束的前提下,生成一个新的变量名,使其语义接近原始变量名但不与已有变量名重复。只输出变量名本身。
275+
276+
277+
AGENT_DISPLAY_NAME_REGENERATE_SYSTEM_PROMPT: |-
278+
### 你是【Agent展示名称调整专家】
279+
你的任务是结合业务背景和已有展示名称,生成一个语义一致但不重复的 Agent 展示名称。
280+
281+
#### 约束
282+
1. 展示名称需自然、易读,能够概括 Agent 的核心能力,以“助手”结尾,长度不超过 30 个字符。
283+
2. 不得包含具体工具名称或多余符号。
284+
3. 仅输出展示名称本身。
285+
286+
287+
AGENT_DISPLAY_NAME_REGENERATE_USER_PROMPT: |-
288+
### 任务描述
289+
{{ task_description }}
290+
291+
### 原始展示名称
292+
{{ original_value }}
293+
294+
### 已有展示名称
295+
{{ existing_values }}
296+
297+
请输出一个新的展示名称,语义接近原始名称但不与已存在的展示名称重复,并满足上述约束。只输出展示名称本身。

backend/prompts/utils/prompt_generate_en.yaml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,50 @@ USER_PROMPT: |-
251251
{{assistant_description}}
252252
{% else %}
253253
You have no available assistants
254-
{% endif %}
254+
{% endif %}
255+
256+
257+
AGENT_NAME_REGENERATE_SYSTEM_PROMPT: |-
258+
### You are an [Agent Variable Name Refinement Expert]
259+
Your job is to generate a Python-friendly variable name that keeps the same intent while avoiding duplicates.
260+
261+
#### Constraints
262+
1. The name may contain only letters, numbers, and underscores, must start with a letter or underscore, ending with "_assistant", and stay within 30 characters.
263+
2. Keep the new name semantically close to the original one while ensuring it does not duplicate existing names.
264+
3. Return the variable name only—no explanations or extra symbols.
265+
266+
267+
AGENT_NAME_REGENERATE_USER_PROMPT: |-
268+
### Task Description
269+
{{ task_description }}
270+
271+
### Original Variable Name
272+
{{ original_value }}
273+
274+
### Existing Variable Names
275+
{{ existing_values }}
276+
277+
Generate a new variable name that satisfies the constraints, keeps the original meaning, and does not duplicate any existing names. Output only the variable name.
278+
279+
280+
AGENT_DISPLAY_NAME_REGENERATE_SYSTEM_PROMPT: |-
281+
### You are an [Agent Display Name Refinement Expert]
282+
You summarize the agent's capability and generate a readable display name that remains unique within the workspace.
283+
284+
#### Constraints
285+
1. The name must be concise, easy to read, summarize the agent's responsibility, ending with "Assistant", and stay within 30 characters.
286+
2. Avoid mentioning specific tool names or adding extra punctuation.
287+
3. Return only the display name.
288+
289+
290+
AGENT_DISPLAY_NAME_REGENERATE_USER_PROMPT: |-
291+
### Task Description
292+
{{ task_description }}
293+
294+
### Original Display Name
295+
{{ original_value }}
296+
297+
### Existing Display Names
298+
{{ existing_values }}
299+
300+
Output a new display name that is semantically aligned with the original while remaining unique and honoring the constraints. Return only the display name.

0 commit comments

Comments
 (0)