Skip to content

[Bug] list_files fails to find workspace data in Redis mode on Windows due to backslash path mismatch #1887

Closed

Description

@HelloRabbits

[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

  1. Configure a HarnessAgent with RemoteFilesystemSpec and Redis DistributedStore on Windows
  2. Write some data via memory_save (which succeeds and stores data in Redis)
  3. Call list_files with the workspace-relative path to memory/, e.g.:
    {"path": "D:\\workspace\\my-learn\\agentscope-v2\\.agentscope\\workspace\\memory"}
  4. 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:

  • prefix comes from resolvedWorkspace.toAbsolutePath().toString(), e.g. D:\workspace\my-learn\agentscope-v2\.agentscope\workspace\
  • The incoming path from the LLM also uses backslashes, e.g. D:\workspace\my-learn\agentscope-v2\.agentscope\workspace\memory\
  • prefix + "/" produces D:\workspace\...\workspace/ — the trailing / is a forward slash
  • path.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_get and memory_save work correctly because they use workspace-relative paths (e.g. "MEMORY.md", "memory/2026-04-01.md") that match routes directly without going through WorkspacePathNormalizer
  • list_files works correctly when the LLM passes a relative path like "memory/" directly, but LLMs often discover the workspace via absolute paths from RuntimeContext, 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() method
  • agentscope-harness/src/main/java/io/agentscope/harness/agent/filesystem/CompositeFilesystem.java — ls() fallback logic

Activity

  1. added a commit that references this issue on Jun 25, 2026
    9e192f8
  2. added a commit that references this issue on Aug 12, 2026
    9dd768d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions