agentscope-java icon indicating copy to clipboard operation
agentscope-java copied to clipboard

[Bug]: `InvalidPathException` when using default FileSystemSkillRepository on `Windows` due to illegal character `:`

Open xiongbw opened this issue 9 months ago • 3 comments

Describe the bug When creating an AgentSkill object using FileSystemSkillRepository constructor without passing the source field on Windows system, an InvalidPathException is thrown when building the ReActAgent object with .skillBox(skillBox). The exception occurs because the default path contains the illegal character : which is not allowed in Windows file paths.

To Reproduce Steps to reproduce the behavior:

  1. Create an AgentSkill object without specifying the source field:

    // ...
    // Use FileSystemSkillRepository constructor without source param
    FileSystemSkillRepository repository = new FileSystemSkillRepository(resourcesDir, false);
    AgentSkill skillCreator = repository.getSkill(SKILL_NAME);
    skillBox.registration().skill(skillCreator).apply();
    // ...
    // Exception thrown while creating ReActAgent when loading skillBox.
    ReActAgent agent = ReActAgent.builder()
        .name("agent")
        .model(model)
        .skillBox(skillBox) // Because the skillBox has no source set, and the default value used contains a ':' character.
        .build();
    
  2. Execute on Windows(You can directly run the AgentSkillExample file on Windows.)

  3. See error Expected behavior When using the default source field (without passing it explicitly), the ReActAgent should be able to load the SkillBox normally, rather than failing due to illegal path characters. The default source field should be a valid file system path that does not contain characters illegal on Windows systems.

Error messages

Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <:> at index 24: skill-creator_filesystem:resources_skills
	at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
	at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
	at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:232)
	at java.base/java.nio.file.Path.resolve(Path.java:515)
	at io.agentscope.core.skill.SkillBox.uploadSkillFiles(SkillBox.java:748)
	at io.agentscope.core.ReActAgent$Builder.configureSkillBox(ReActAgent.java:1549)
	at io.agentscope.core.ReActAgent$Builder.build(ReActAgent.java:1379)
	at io.agentscope.examples.quickstart.AgentSkillExample.main(AgentSkillExample.java:102)

Environment:

  • AgentScope-Java Version: 1.0.9
  • Java Version: 17
  • OS: Windows

Additional context The problematic path is skill-creator_filesystem:resources_skills, where the colon : is an illegal character in Windows file systems, causing the Path.resolve() method to throw an exception. This issue may not occur on Linux/Mac systems as their file systems allow colons in paths.

xiongbw avatar Feb 27 '26 13:02 xiongbw

me too.

amyaxy avatar Mar 05 '26 02:03 amyaxy

Modify the colon in the getSource method of the FileSystemSkillRepository class to an underscore. Then you can run it normally.

    @Override
    public String getSource() {
//        return source != null ? source : "filesystem:" + buildDefaultSourceSuffix();
        return source != null ? source : "filesystem_" + buildDefaultSourceSuffix();
    }

duanfangrui avatar Mar 09 '26 02:03 duanfangrui

Modify the colon in the getSource method of the FileSystemSkillRepository class to an underscore. Then you can run it normally.

    @Override
    public String getSource() {
//        return source != null ? source : "filesystem:" + buildDefaultSourceSuffix();
        return source != null ? source : "filesystem_" + buildDefaultSourceSuffix();
    }

Yes, it's also possible to directly specify the source param value like example-skill at the FileSystemSkillRepository repository = new FileSystemSkillRepository(resourcesDir, false, "example-skill"); , and that would be fine as well.

xiongbw avatar Mar 09 '26 02:03 xiongbw