Skip to content

[Bug]:IsolationScope (SESSION/USER) does not apply to execute_shell_command working_directory #2329

Open

Description

@xxc-11

Description:

When using IsolationScope.SESSION or IsolationScope.USER, the framework correctly isolates internal data (like memory files and session logs) into the specific session/user directory. However, when the Agent invokes the built-in execute_shell_command tool, the working_directory parameter does not automatically point to the isolated directory. This causes the command to fail because it attempts to execute in the project root directory instead of the isolated workspace.

Steps to Reproduce:

Configure the HarnessAgent with IsolationScope.SESSION (or USER).
Prompt the Agent to generate a Python script (e.g., generate_helloworld.py). The script is successfully created in the isolated directory (e.g., workspace/<session_id>/).
Prompt the Agent to execute the script using the execute_shell_command tool.
Observe the tool call parameters and the execution result.

Expected Behavior:

The execute_shell_command tool should automatically resolve the working_directory to the current isolated path (e.g., workspace/<session_id>/), ensuring the script can be found and executed successfully.

Actual Behavior:

The tool call parameters look like this:

{
  "command": "python generate_helloworld.py",
  "working_directory": "D:\\data\\spring_boot\\v420\\agent\\workspace", // Points to project root, not the session directory
  "timeout": 30
}

Because the file exists in the isolated directory but the command runs in the root directory, it results in a Windows system error:
Exit code: 1\n\n[stderr] The filename, directory name, or volume label syntax is incorrect.

Environment:

AgentScope Java Version: 2.0.0

Activity

  1. added
    bug
    on Jul 21, 2026
  2. added 2 commits that reference this issue on Jul 27, 2026
  3. waterWang commented on Jul 27, 2026

    @waterWang

    I have submitted a fix for this issue in PR #2435.

    Root Cause: resolveExecuteCwd() in LocalFilesystemWithShell short-circuits when shellCwd is set (the project root), returning it directly without applying the namespace prefix from the NamespaceFactory. This causes shell commands to run in the project root instead of the isolated session/user directory.

    Fix: Use shellCwd as the base path and apply namespace resolution on top of it, so the shell working directory becomes <projectRoot>/<sessionId>/ when isolation scope is configured.

  4. oss-maintainer commented on Jul 28, 2026

    @oss-maintainer
  5. added
    area/build
    area/core/memory
    area/core/tool
    area/harness
    on Aug 11, 2026
  6. moved this from Backlog to In progress in AgentScope Javaon Aug 11, 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/buildarea/core/memoryarea/core/toolarea/harnessbug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions