agentscope-ai / agentscope-ai/agentscope-java

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

Đang mở
#1,583 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
area/core/agent bug
Ngôn ngữ chính
Java
Star
5.6k
Fork
1.3k
Merge trung bình
4 ngày 12 giờ
Pull request đã merge (30 ngày)
77

Mô tả

```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 结束 ===
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.