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

harness: workspace-rooted absolute paths are misrouted when projectWritable(true)

Open chcodex opened this issue 4 months ago • 0 comments

Summary

With projectWritable(true), ProjectAwareOverlay is expected to route non-metadata writes to the project directory. However, when the agent supplies an absolute path under the workspace root (e.g. /your/workspace/src/Foo.java), the write is always routed to the workspace layer instead of the project.

Root cause

ProjectAwareOverlay.isWorkspacePath() classifies absolute paths purely by prefix:

if (Path.of(normalized).isAbsolute()) {
    return Path.of(normalized).normalize().startsWith(workspaceRoot);
}

Any absolute path under the workspace root is unconditionally treated as a workspace path, so the relative part (src/Foo.java) is never inspected against WORKSPACE_PREFIXES. The write therefore lands in workspace/src/Foo.java and projectWritable(true) is effectively ignored.

Note that fixing only the classification is not enough: projectFs runs in ROOTED mode with the workspace listed in its PathPolicy, so a workspace-rooted absolute path handed to it directly would still resolve back into the workspace. The path must be relativized before being passed to the project filesystem.

Expected behaviour

  • write("/your/workspace/src/Foo.java", ...) → project/src/Foo.java
  • write("/your/workspace/MEMORY.md", ...) → workspace/MEMORY.md

Environment

  • Module: agentscope-harness
  • Class: io.agentscope.harness.agent.filesystem.ProjectAwareOverlay

chcodex avatar Aug 01 '26 08:08 chcodex