Skip to content

[Bug]:read_file读取project目录的时候,没有拼接userId #1775

Open

Description

@ld555

write_file写入hi.txt的时候,path传hi.txt,默认拼接了userId,写到了 {project}/{userId}/hi.txt
read_file的时候,path传hi.txt,差不到文件,path必须传 {userId}/hi.txt 才能读出来

Activity

  1. added
    bug
    on Jun 16, 2026
  2. ld555 commented on Jun 16, 2026

    @ld555
    Author

    list_files 工具也没有拼接userid

  3. added
    area/core/tool
    on Jun 16, 2026
  4. oss-maintainer commented on Sep 22, 2026

    @oss-maintainer
    Collaborator

    Issue Evaluation

    Category: bug | Module: agentscope-harness | Status: Confirmed — still live on main @ ed77530a4, and NOT a duplicate of #3245 (raised by the cross-reference in #3245 on 2026-09-22)

    Root cause — an asymmetric namespace factory across the two overlay layers. In local mode the filesystem is an overlay whose layers are built with different namespace settings (agentscope-harness/src/main/java/io/agentscope/harness/agent/filesystem/spec/LocalFilesystemSpec.java):

    Layer Construction Namespace factory
    upper (workspace, read/write) LocalFilesystemSpec.java:296-306 localNamespaceFactory (applies {userId})
    projectFs (writable project target) LocalFilesystemSpec.java:309-311 localNamespaceFactory (applies {userId})
    lower (project, read fallback) LocalFilesystemSpec.java:307 — new LocalFilesystem(effectiveProject, true, 10, null) null → no prefix

    LocalFilesystem.applyNamespacePrefix short-circuits when the factory is null (local/LocalFilesystem.java:689-693), so the lower layer resolves paths verbatim under {project}, while the write side namespaces them.

    Why the reported symptom follows exactly:

    • write_file("hi.txt") → non-workspace write is routed to projectFs (ProjectAwareOverlay.java:134-139), which namespaces → lands at {project}/{userId}/hi.txt.
    • read_file("hi.txt") → overlay read checks upper first, then the lower layer with the same caller path (ProjectAwareOverlay.java:200-202 → OverlayFilesystem.java:162), and the un-namespaced lower layer looks at {project}/hi.txt → not found. Passing {userId}/hi.txt makes the literal path match what the write side produced → found. Matches the report.
    • list_files shows the same asymmetry (the follow-up note "list_files 也没有拼接 userid"): OverlayFilesystem.ls (OverlayFilesystem.java:139-140) lists both layers with the same caller path, so lower-layer entries are returned un-namespaced while upper-layer entries are namespaced.

    Not a duplicate of #3245. #3245 is about the remote default backend (RemoteFilesystemSpec.java:212) namespacing tool reads while a host java.nio write lands at the workspace root. This issue is about the local overlay's project layers, i.e. tool-write vs tool-read inside the framework itself. Consequently PR #3247 (sharedLocalWorkspace) does not cover it — LocalFilesystemSpec.java:307 is outside that change.

    Impact: any project-overlay configuration where a file is written through the framework and later read or listed by relative path silently resolves to a different physical location; the user-visible failure is "file is missing" for read_file / list_files while the file demonstrably exists on disk.

    Severity: medium (local/project mode only; a workaround exists — spell the path with the namespace prefix, as the reporter found).

    Fix direction, needs a maintainer decision before any PR: either (a) give the lower layer the same namespace factory as the write side (LocalFilesystemSpec.java:307), or (b) make the read/list fallback apply the namespace explicitly at the overlay level so all three layers agree. (a) is the smaller change but also changes which project files are visible for a shared project tree; (b) keeps the project layer physically shared and only aligns the resolution, which is probably closer to the intended copy-on-write semantics described in OverlayFilesystem.java:37-51. Either way a regression test should assert that a framework write followed by a read and a listing of the same relative path round-trips in local mode, in both projectWritable states.

    Requested from the reporter: confirm the spec configuration in use (.project(...) path and whether projectWritable(true) is set), since the report is from 2026-06-16 and the code paths have moved since — the defect is reproducible from the code above, but a current-revision reproducer would pin down which of (a)/(b) applies.


    Automated evaluation by github-manager-bot

  5. added
    area/harness
    wait-for-response
    on Sep 22, 2026
  6. aiyili commented on Sep 22, 2026

    @aiyili
    Contributor

    Providing the current-revision reproducer the evaluation asked for — a local run against current main (ed77530), namespace factory rc -> ["u1"], relative-path hi.txt:

    projectWritable=false (default) — self-consistent, no defect:

    step result
    write("hi.txt") lands at {workspace}/u1/hi.txt
    read("hi.txt") found (upper layer, same namespaced resolution)
    ls(".") shows hi.txt
    user-authored baseline {project}/docs/readme.md via read("docs/readme.md") found

    projectWritable=true — the defect reproduces exactly as reported:

    step result
    write("hi.txt") lands at {project}/u1/hi.txt
    read("hi.txt") not found (falls to the un-namespaced lower at {project}/hi.txt)
    read("u1/hi.txt") found — the reporter's workaround
    ls(".") shows only /u1/ — the namespace directory itself leaked into the listing

    So the reporter must have been on projectWritable=true; the default mode round-trips fine. This narrows the fix scope to the projectWritable branch only.

    A codebase precedent favoring option (b): ProjectAwareOverlay.edit() and delete() already route through the namespaced projectFs first (if (projectFs.exists(rc, target)) → projectFs.edit/delete(...), ProjectAwareOverlay.java:150-158, :161-170) and only fall back to the overlay path afterwards — exactly the "align resolution so all layers agree" shape. read/ls/glob/grep/exists simply never got the same routing, which is why write→edit→delete round-trips but write→read does not. Extending that existing routing pattern to the read-family operations would fix the asymmetry while keeping the project tree physically shared (option (b), per the evaluation's own lean).

    Happy to implement (a) or (b) once the maintainer picks — the reproducer above converts directly into the required regression test (write → read → list round-trip in both projectWritable states).

  7. oss-maintainer commented on Sep 23, 2026

    @oss-maintainer
    Collaborator

    Reproducer received — it closes exactly the gap the evaluation asked about, and the diagnosis holds up under a fresh read of main @ ed77530a4. Thanks for running both modes.

    Confirmed, with the scope narrowed to projectWritable(true):

    • Writes on the project leg are resolved by the namespaced projectFs (agentscope-harness/src/main/java/io/agentscope/harness/agent/filesystem/ProjectAwareOverlay.java:134-139), while read delegates with the caller-relative key and never consults projectFs (ProjectAwareOverlay.java:200-203), so it falls through to the lower layer built with a null factory (LocalFilesystemSpec.java:307) — hence {project}/hi.txt instead of {project}/u1/hi.txt. Your table matches the code path exactly, and projectWritable=false is self-consistent because both legs stay on the namespaced upper layer.

    One precision on the precedent framing (it changes how (b) should be implemented, not whether it works): the read family does not call the lower layer directly — read/exists/ls/grep/glob (ProjectAwareOverlay.java:200-203, :206-208, :219-221, :224-228, :231-233) delegate to OverlayFilesystem, which checks the namespaced upper layer first and only then the un-namespaced lower one. That is precisely why write→edit→delete round-trips: edit (:150-158) and delete (:162-169) probe projectFs.exists(...) before the overlay fallback. Option (b) is therefore just extending that existing projectFs.exists-first routing to the read family — a small, symmetric change that keeps the project tree physically shared, which is the shape the evaluation leaned toward.

    Second symptom the fix must cover. ls(".") returning only /u1/ under projectWritable=true is the same root cause surfacing in the other direction: the un-namespaced lower layer lists the namespace directory itself rather than its contents. Please include that listing shape in the regression set alongside the write → read → list round-trip in both projectWritable states.

    Status: no bot PR. You have offered to implement, and the remaining choice between (a) matching the lower layer's namespace factory and (b) aligning resolution in the overlay is a maintainer product decision — (a) changes which project files become visible for a shared project tree, so it is not mechanically safe. wait-for-response stays until a maintainer picks a direction; per rule 7 the bot will not open a competing PR.


    Automated follow-up by github-manager-bot

  8. moved this from Backlog to In progress in AgentScope Javaon Oct 20, 2026
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

    area/core/toolarea/harnessbugwait-for-response

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions