diff --git a/agentscope-core/src/main/java/io/agentscope/core/skill/SkillToolFactory.java b/agentscope-core/src/main/java/io/agentscope/core/skill/SkillToolFactory.java index 0ed633231..1943b8a42 100644 --- a/agentscope-core/src/main/java/io/agentscope/core/skill/SkillToolFactory.java +++ b/agentscope-core/src/main/java/io/agentscope/core/skill/SkillToolFactory.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import reactor.core.publisher.Mono; @@ -169,14 +170,11 @@ private String loadSkillResourceImpl(String skillId, String path) { } // Get resource - Map resources = skill.getResources(); - if (resources == null || !resources.containsKey(path)) { - // Resource not found, return available resource paths - throw new IllegalArgumentException( - buildResourceNotFoundMessage(skillId, path, resources)); + Set paths = skill.getResourcePaths(); + if (paths == null || !paths.contains(path)) { + throw new IllegalArgumentException(buildResourceNotFoundMessage(skillId, path, paths)); } - - String resourceContent = resources.get(path); + String resourceContent = skill.getResource(path); activateSkill(skillId); return buildResourceResponse(skillId, path, resourceContent); } @@ -225,11 +223,10 @@ private String buildResourceResponse(String skillId, String path, String resourc * * @param skillId The skill ID * @param path The requested path that was not found - * @param resources The available resources map + * @param paths The available resources * @return Formatted error message with available resources */ - private String buildResourceNotFoundMessage( - String skillId, String path, Map resources) { + private String buildResourceNotFoundMessage(String skillId, String path, Set paths) { StringBuilder message = new StringBuilder(); message.append("Resource not found: '") .append(path) @@ -241,8 +238,8 @@ private String buildResourceNotFoundMessage( List resourcePaths = new ArrayList<>(); resourcePaths.add("SKILL.md"); // Always add SKILL.md as the first resource - if (resources != null && !resources.isEmpty()) { - resourcePaths.addAll(resources.keySet()); + if (paths != null && !paths.isEmpty()) { + resourcePaths.addAll(paths); } message.append("Available resources:\n");