Skip to content

fix(#2329): apply namespace scope to shellCwd in resolveExecuteCwd [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH] - #2434

Open
waterWang wants to merge 1 commit into
agentscope-ai:mainfrom
waterWang:fix-isolation-scope-execute-cwd
Open

fix(#2329): apply namespace scope to shellCwd in resolveExecuteCwd [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH]#2434
waterWang wants to merge 1 commit into
agentscope-ai:mainfrom
waterWang:fix-isolation-scope-execute-cwd

Conversation

@waterWang

Copy link
Copy Markdown

Description

Fixes #2329

When IsolationScope.SESSION or IsolationScope.USER is configured, the execute_shell_command tool should automatically resolve the working directory to the isolated path (e.g., workspace/<session_id>/). However, when shellCwd is explicitly set (to the project root) in LocalFilesystemWithShell, the resolveExecuteCwd method returns it directly without applying the namespace scope.

Root Cause

In LocalFilesystemWithShell.resolveExecuteCwd(), the early return for non-null shellCwd bypasses the namespace factory entirely:

if (shellCwd != null) {
    return shellCwd;  // ignores namespace/scope
}

Fix

The namespace prefix is now applied to shellCwd when it is set, just as it is applied to getCwd() when shellCwd is null. This ensures that shell commands run in the isolated directory matching the session/user scope.

Testing

  • Existing tests pass (no regression)
  • When IsolationScope.SESSION is configured, execute_shell_command now resolves to <shellCwd>/<sessionId>/ instead of just <shellCwd>
  • When shellCwd is null, behavior is unchanged (namespace still applied to getCwd())

Wallet: FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH

…ExecuteCwd [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH]
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ent/filesystem/local/LocalFilesystemWithShell.java 25.00% 2 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@oss-maintainer oss-maintainer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Same fix as #2435 — correctly applies namespace isolation on top of shellCwd in resolveExecuteCwd().

Analysis

The logic is identical to #2435: extract a base path, then resolve namespace segments on top. Build passes.

Note: This is a duplicate of #2435 for the same issue (#2329). The author should close one of the two PRs to avoid confusion during merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants