Repository navigation
Description
[Bug] list_files fails to find workspace data in Redis mode on Windows due to backslash path mismatch
Describe the bug
When using RemoteFilesystemSpec with Redis as the distributed store on Windows, the list_files tool cannot find workspace data stored in Redis. It only queries the local disk filesystem, completely bypassing the RemoteFilesystem routes.
To Reproduce
- Configure a
HarnessAgentwithRemoteFilesystemSpecand RedisDistributedStoreon Windows - Write some data via
memory_save(which succeeds and stores data in Redis) - Call
list_fileswith the workspace-relative path tomemory/, e.g.:{"path": "D:\\workspace\\my-learn\\agentscope-v2\\.agentscope\\workspace\\memory"} - The result is empty or only shows local disk files, not the Redis data
Root Cause
The issue is in WorkspacePathNormalizer.tryStrip():
// WorkspacePathNormalizer.java, line 90-98
private static String tryStrip(String path, String prefix) {
if (path.startsWith(prefix + "/")) { // prefix + "/" uses forward slash
return path.substring(prefix.length() + 1);
}
if (path.equals(prefix)) {
return ".";
}
return null;
}On Windows:
prefixcomes fromresolvedWorkspace.toAbsolutePath().toString(), e.g.D:\workspace\my-learn\agentscope-v2\.agentscope\workspace\- The incoming
pathfrom the LLM also uses backslashes, e.g.D:\workspace\my-learn\agentscope-v2\.agentscope\workspace\memory\ prefix + "/"producesD:\workspace\...\workspace/— the trailing/is a forward slashpath.startsWith(prefix + "/")fails because the path uses backslashes (\)
As a result, normalize() returns the raw path unchanged. This un-normalized Windows absolute path is then passed to CompositeFilesystem.ls(), where routeForPath() fails to match any route prefix (like "memory/", "skills/", etc.), so it falls back to defaultBackend (LocalFilesystem), which only queries the local disk.
Expected behavior
list_files should correctly resolve the workspace path to a relative path (e.g. memory), which would then be routed by CompositeFilesystem to the appropriate RemoteFilesystem (Redis) backend, returning the actual workspace data.
Additional context
memory_getandmemory_savework correctly because they use workspace-relative paths (e.g."MEMORY.md","memory/2026-04-01.md") that match routes directly without going throughWorkspacePathNormalizerlist_filesworks correctly when the LLM passes a relative path like"memory/"directly, but LLMs often discover the workspace via absolute paths fromRuntimeContext, leading to this issue- This is a Windows-only bug; on Linux/macOS, paths use
/natively and the matching succeeds
Suggested fix
Normalize backslashes to forward slashes in tryStrip() before comparison:
private static String tryStrip(String path, String prefix) {
String normalizedPath = path.replace('\\', '/');
String normalizedPrefix = prefix.replace('\\', '/');
if (normalizedPath.startsWith(normalizedPrefix + "/")) {
return normalizedPath.substring(normalizedPrefix.length() + 1);
}
if (normalizedPath.equals(normalizedPrefix)) {
return ".";
}
return null;
}Affected files
agentscope-harness/src/main/java/io/agentscope/harness/agent/workspace/WorkspacePathNormalizer.java—tryStrip()methodagentscope-harness/src/main/java/io/agentscope/harness/agent/filesystem/CompositeFilesystem.java—ls()fallback logic
Activity
fix(harness): normalize Windows list_files paths (#1892)
fix(harness): normalize Windows list_files paths (agentscope-ai#1892)