Skip to content

[codex] fix sandbox glob_files recursive patterns#1684

Open
gaoxiaolei-s59 wants to merge 3 commits into
agentscope-ai:mainfrom
gaoxiaolei-s59:codex/fix-1674-glob-files-recursive-pattern
Open

[codex] fix sandbox glob_files recursive patterns#1684
gaoxiaolei-s59 wants to merge 3 commits into
agentscope-ai:mainfrom
gaoxiaolei-s59:codex/fix-1674-glob-files-recursive-pattern

Conversation

@gaoxiaolei-s59

Copy link
Copy Markdown

Summary

  • normalize leading **/ in sandbox glob() before passing the pattern to find -name
  • add a regression test covering glob_files calls like **/*.md

Root Cause

The glob_files tool description advertises recursive patterns such as **/*.java, but BaseSandboxFilesystem.glob() forwarded that pattern directly to find -name. find -name matches the filename portion only, so the leading **/ caused sandbox-backed recursive glob calls to return no matches.

Validation

  • mvn -pl agentscope-harness -am -Dtest=BaseSandboxFilesystemTest,FilesystemGlobTest test

@CLAassistant

CLAassistant commented Jun 10, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...gent/filesystem/sandbox/BaseSandboxFilesystem.java 50.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@gaoxiaolei-s59 gaoxiaolei-s59 marked this pull request as ready for review June 10, 2026 02:07
@gaoxiaolei-s59 gaoxiaolei-s59 requested a review from a team June 10, 2026 02:07
@AgentScopeJavaBot AgentScopeJavaBot added bug Something isn't working area/harness agentscope-harness (test/runtime support) labels Jun 10, 2026

@AgentScopeJavaBot AgentScopeJavaBot 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.

🤖 AI Review

This PR fixes a real bug: glob_files in sandbox mode advertised support for recursive patterns like **/*.java, but the implementation forwarded the pattern directly to find -name, which only matches the filename portion. The fix correctly strips the leading **/ prefix since find already performs recursive directory traversal. The change is minimal, null-safe, and well-tested with a new BaseSandboxFilesystemTest using a clean fake-sandbox design. One minor symmetry observation regarding the sibling grep method is noted below.

public GlobResult glob(RuntimeContext runtimeContext, String pattern, String path) {
String escapedPath = FilesystemUtils.shellQuote(path != null ? path : "/");
String escapedPattern = FilesystemUtils.shellQuote(pattern);
String findNamePattern =

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.

[nit] Symmetry note: the sibling grep() method (line ~282) passes its glob parameter directly to grep --include= without the same **/ stripping. GNU grep's --include also matches only the filename portion, so grep_files with **/*.java would silently return no matches — the same bug this PR fixes for glob_files. Consider applying the same normalization in a follow-up, or extracting a shared helper like stripRecursivePrefix(String).


private static final RuntimeContext RT = RuntimeContext.empty();

@Test

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.

[praise] Nice test design — capturing the generated command string and asserting it directly is the right approach for testing shell-command delegation. The FakeSandboxFilesystem stub is minimal and focused.

@AgentScopeJavaBot AgentScopeJavaBot 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.

🤖 AI Review

This PR fixes a real bug: glob_files in sandbox mode advertised support for recursive patterns like **/*.java, but the implementation forwarded the pattern directly to find -name, which only matches the filename portion. The fix correctly strips the leading **/ prefix since find already performs recursive directory traversal. The change is minimal, null-safe, and well-tested with a new BaseSandboxFilesystemTest using a clean fake-sandbox design. One minor symmetry observation regarding the sibling grep method is noted below.

public GlobResult glob(RuntimeContext runtimeContext, String pattern, String path) {
String escapedPath = FilesystemUtils.shellQuote(path != null ? path : "/");
String escapedPattern = FilesystemUtils.shellQuote(pattern);
String findNamePattern =

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.

[nit] Symmetry note: the sibling grep() method (line ~282) passes its glob parameter directly to grep --include= without the same **/ stripping. GNU grep's --include also matches only the filename portion, so grep_files with **/*.java would silently return no matches — the same bug this PR fixes for glob_files. Consider applying the same normalization in a follow-up, or extracting a shared helper like stripRecursivePrefix(String).


private static final RuntimeContext RT = RuntimeContext.empty();

@Test

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.

[praise] Nice test design — capturing the generated command string and asserting it directly is the right approach for testing shell-command delegation. The FakeSandboxFilesystem stub is minimal and focused.

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

Labels

area/harness agentscope-harness (test/runtime support) bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants