alibaba/spring-ai-alibaba · error · IllegalArgumentException
智能体名称已存在,请使用其他名称: ${name}
Error message
智能体名称已存在,请使用其他名称: ${name} What it means
Business-rule rejection raised in AgentSchemaServiceImpl.createAgentSchema when an agent schema with the same name already exists in the target workspace. Before saving, the service queries the agent schema table filtered by workspaceId (defaulting to "1" when the request context carries no workspace) and the incoming name; a match means the name is not unique within that workspace, so creation is refused with a BizException rather than producing a duplicate. Callers should surface this to the user as a naming conflict and prompt for a different name.
Source
Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/service/impl/AgentSchemaServiceImpl.java:61
implements AgentSchemaService {
@Override
public AgentSchemaEntity createAgentSchema(AgentSchemaEntity agentSchemaEntity) {
RequestContext requestContext = RequestContextHolder.getRequestContext();
// Check for duplicate name in the same workspace
String workspaceId = requestContext != null ? requestContext.getWorkspaceId() : null;
if (StringUtils.isBlank(workspaceId)) {
workspaceId = "1"; // Use default workspace ID that matches database
}
LambdaQueryWrapper<AgentSchemaEntity> duplicateCheck = new LambdaQueryWrapper<>();
duplicateCheck.eq(AgentSchemaEntity::getWorkspaceId, workspaceId);
duplicateCheck.eq(AgentSchemaEntity::getName, agentSchemaEntity.getName());
List<AgentSchemaEntity> existingAgents = list(duplicateCheck);
if (!existingAgents.isEmpty()) {
throw new IllegalArgumentException("智能体名称已存在,请使用其他名称: " + agentSchemaEntity.getName());
}
// Set default values
if (StringUtils.isBlank(agentSchemaEntity.getAgentId())) {
agentSchemaEntity.setAgentId(IdGenerator.generateAgentId());
}
agentSchemaEntity.setWorkspaceId(workspaceId);
agentSchemaEntity.setStatus(AgentStatus.ACTIVE);
agentSchemaEntity.setEnabled(true);
agentSchemaEntity.setGmtCreate(new Date());
agentSchemaEntity.setGmtModified(new Date());
String accountId = requestContext != null ? requestContext.getAccountId() : "10000";
agentSchemaEntity.setCreator(accountId);
agentSchemaEntity.setModifier(accountId);
save(agentSchemaEntity);View on GitHub (pinned to f82da0b50f)
Solutions
- Choose a different agent name within the workspace
- Rename or delete the existing agent first
- Include workspaceId in the uniqueness check on the client side before submit
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/service/impl/AgentSchemaServiceImpl.java:61 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/4b5b6120857c67bc.
Report an issue: GitHub.