fix(agent): 使用短 UUID 替代名称生成 Agent ID#2065
Open
gongzhi-netease wants to merge 1 commit into
Open
Conversation
Replace name-based slug generation with UUID v4 first 8 characters. This prevents data resurrection when recreating agents with the same name after deletion, as each new agent now gets a unique random ID. - Generate 8-char hex ID from UUID v4 (e.g. '550e8400') - Retry if ID already exists (collision probability is negligible) - Preserve backward compatibility when request.id is provided
This was referenced May 28, 2026
|
This pull request has been inactive for 30 days. It will be automatically closed in 14 days unless there is new activity. If you're still working on this, please leave a comment or push new commits to keep it open. Thank you! |
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.
问题背景
当前 Agent ID 基于名称生成(如 "My Assistant" → "my-assistant"),存在以下问题:
数据复活问题:删除 Agent 后,本地文件(workspace、sessions)未清理,重新创建同名 Agent 时会复用相同 ID,导致旧数据意外复活。
删除 Agent 时的遗漏问题(待后续修复)
当前删除 Agent 时存在以下数据未清理的问题:
cowork_sessions(关联的会话)cowork_messages(关联的消息)im_session_mappings(IM 映射)本次 PR 通过使用随机 ID 解决数据复活的核心问题,上述清理逻辑作为后续优化项。
解决方案
使用 UUID v4 前 8 位作为 Agent ID(如
550e8400):request.id,仍使用传入值改动内容
src/main/coworkStore.ts:修改createAgent方法的 ID 生成逻辑