agentscope-ai / agentscope-ai/agentscope-java

[Bug]: AgentScope-Java V2 版本中手动设置agentId后,获取到的agentId还是uuid格式

Open
#1,583 3 comments 0 reactions 0 assignees View on GitHub
area/core/agent bug
Dominant language
Java
Stars
5.6k
Forks
1.3k
Avg merge
4d 12h
Merged PRs (30d)
77

Description

```java
package com.eavision.agent;

import io.agentscope.core.agent.RuntimeContext;
import io.agentscope.core.message.Msg;
import io.agentscope.core.message.MsgRole;
import io.agentscope.core.tool.Toolkit;
import io.agentscope.harness.agent.HarnessAgent;
import io.agentscope.harness.agent.filesystem.spec.LocalFilesystemSpec;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.nio.file.Path;
import java.util.List;

/**
* 验证 HarnessAgent 的 agentId 设置和获取。
*/
public class AgentIdVerificationDemo {
private static final Logger LOGGER = LoggerFactory.getLogger(AgentIdVerificationDemo.class);

public static void main(String[] args) throws IOException {
System.out.println("=== HarnessAgent AgentId 验证 Demo ===\n");

// 手动指定 agentId
String manualAgentId = "alice:note-taker";
System.out.println("1. 手动指定 agentId: " + manualAgentId);

// 构建 HarnessAgent
HarnessAgent agent = HarnessAgent.builder()
.name("note-taker")
.agentId(manualAgentId)
.sysPrompt("You are a helpful assistant.")
.model("dashscope:qwen3.6-plus")
.workspace(Path.of(System.getProperty("user.home"), ".harness-agent", "workspaces", "alice", "agents", "note-taker"))
.toolkit(new Toolkit())
.filesystem(new LocalFilesystemSpec())
.build();

// 获取 agentId
String retrievedAgentId = agent.getAgentId();
System.out.println("2. 获取 agent.getAgentId(): " + retrievedAgentId);

// 验证是否一致
boolean isSame = manualAgentId.equals(retrievedAgentId);
System.out.println("3. 验证结果: " + (isSame ? "✅ 一致" : "❌ 不一致"));

if (!isSame) {
System.out.println(" 期望值: " + manualAgentId);
System.out.println(" 实际值: " + retrievedAgentId);
}

agent.close();
System.out.println("\n=== Demo 结束 ===");
}
}

```

```shell
17:39:18.433 [main] INFO io.agentscope.core.skill.repository.FileSystemSkillRepository -- FileSystemSkillRepository initialized with base directory: /Users/lxw/.harness-agent/workspaces/alice/agents/note-taker/skills
17:39:18.442 [main] INFO io.agentscope.harness.agent.tools.ToolFilter -- tools.json filter applied: removed 12 tool(s); 6 tool(s) remain: [edit_file, glob_files, grep_files, list_files, read_file, write_file]
17:39:18.442 [main] INFO io.agentscope.harness.agent.HarnessAgent -- HarnessAgent 'note-taker' built [workspace=/Users/lxw/.harness-agent/workspaces/alice/agents/note-taker, backend=ShellAwareOverlay, subagents=true]
2. 获取 agent.getAgentId(): 86882652-25d0-4644-9109-e51495714ed6
3. 验证结果: ❌ 不一致
期望值: alice:note-taker
实际值: 86882652-25d0-4644-9109-e51495714ed6

=== Demo 结束 ===
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.