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

[Bug]:glob_files tool description advertises **/*.java pattern but BaseSandboxFilesystem implementation doesn't support it

Open HuJiShuang opened this issue 5 months ago • 2 comments

The glob_files tool in FilesystemTool.java declares its pattern parameter with the example **/*.java:

@ToolParam(name = "pattern", description = "Glob pattern (e.g., **/*.java)")

However, BaseSandboxFilesystem.glob() translates this directly into find -name:

String cmd = "find " + escapedPath + " -type f -name " + escapedPattern + " 2>/dev/null | sort";

find -name does not support ** — it only matches the filename portion, so **/*.md always returns empty results.

Impact

  • LLM follows the tool description, uses **/*.md as instructed
  • Tool silently returns empty, model retries with list_files、raw find shell commands
  • Causes 3-4 rounds of wasted tool calls and unnecessary context bloat

Steps to Reproduce

  1. Create a sandbox-backed agent with files in subdirectories (e.g., knowledge/foo.md)
  2. Call glob_files with pattern **/*.md
  3. Observe empty results

Suggested Fix

Option A: Strip / prefix before passing to find -name: String findPattern = pattern.startsWith("/") ? pattern.substring(3) : pattern;

Option B: Update tool description to only advertise find -name compatible patterns (e.g., *.java).

Location

  • FilesystemTool.java line 125

HuJiShuang avatar Jun 08 '26 14:06 HuJiShuang

I'd like to work on this. Plan: make BaseSandboxFilesystem.glob() handle **/ patterns (compatible with the tool description), and add a regression test so **/*.ext finds files in subdirectories.

Blue-Berrys avatar Jul 28 '26 06:07 Blue-Berrys

Update: on current main, BaseSandboxFilesystem.glob() already calls stripRecursivePrefix(), so **/*.java is translated to *.java for find -name. This looks fixed already — stepping back unless a remaining edge case (e.g. nested ** mid-pattern) still needs work.

Blue-Berrys avatar Jul 28 '26 06:07 Blue-Berrys