Skip to content

feat(adk): align filesystem backend FileInfo.Path field behavior with Python glob and ls command#767

Merged
hi-pender merged 1 commit intoalpha/08from
feat/filesystemv4
Feb 5, 2026
Merged

feat(adk): align filesystem backend FileInfo.Path field behavior with Python glob and ls command#767
hi-pender merged 1 commit intoalpha/08from
feat/filesystemv4

Conversation

@zhuangjie1125
Copy link
Contributor

Enhanced the filesystem backend to align Path field behavior with Python glob patterns and standard ls command output.

Key Changes:

  1. Updated FileInfo.Path field documentation:

    • Changed from "absolute path only" to support filename, relative path, or absolute path
    • Clarified that Path value depends on the command context (Ls vs Glob)
  2. Modified LsInfo implementation:

    • Returns only filename/directory name instead of full path
    • Uses filepath.Base() for file entries
    • Uses parts[0] for immediate children in directory listings
    • Behavior now matches standard ls command output
  3. Enhanced GlobInfo with Python glob compatibility:

    • Added matchGlob() and matchGlobParts() functions for recursive pattern matching
    • Implemented ** (double star) support for recursive directory traversal
    • Added absolute pattern detection (patterns starting with /)
    • Absolute patterns return absolute paths; relative patterns return relative paths
    • Supports ** in any position: beginning, middle, or end of pattern
  4. Comprehensive test coverage:

    • Added TestInMemoryBackend_LsInfo_PathIsFilename: validates Ls returns filenames only
    • Added TestInMemoryBackend_GlobInfo_RelativePath: tests relative/absolute pattern behavior
    • Added TestInMemoryBackend_GlobInfo_RecursivePattern: validates ** recursive matching
    • Updated existing tests to match new Path field behavior

Technical Implementation:

  • Recursive matching algorithm handles ** by trying all possible directory depths
  • Pattern matching splits paths by "/" and matches segment by segment
  • Absolute patterns (starting with /) bypass basePath filtering and return full paths
  • Relative patterns respect basePath and return paths relative to it

Impact:

  • Ls command now returns clean filenames like standard Unix ls
  • Glob patterns behave identically to Python glob.glob() with recursive=True
  • Supports complex patterns like "/*.go", "src//.go", and "/absolute/path/**/.go"

type FileInfo struct {
// Path is the absolute path of the file or directory.
// Path is the path of the file or directory, which can be a filename, relative path, or absolute path.
Path string
Copy link

Choose a reason for hiding this comment

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

🚨 Breaking API Changes Detected

Package: github.com/cloudwego/eino/adk/middlewares/reduction

Incompatible changes:

  • New: removed
Review Guidelines

Please ensure that:

  • The changes are absolutely necessary
  • They are properly documented
  • Migration guides are provided if needed

⚠️ Please resolve this thread after reviewing the breaking changes.

type FileInfo struct {
// Path is the absolute path of the file or directory.
// Path is the path of the file or directory, which can be a filename, relative path, or absolute path.
Path string
Copy link

Choose a reason for hiding this comment

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

🚨 Breaking API Changes Detected

Package: github.com/cloudwego/eino/adk/middlewares/patchtoolcalls

Incompatible changes:

  • Config: removed
  • NewMiddleware: removed
Review Guidelines

Please ensure that:

  • The changes are absolutely necessary
  • They are properly documented
  • Migration guides are provided if needed

⚠️ Please resolve this thread after reviewing the breaking changes.

type FileInfo struct {
// Path is the absolute path of the file or directory.
// Path is the path of the file or directory, which can be a filename, relative path, or absolute path.
Path string
Copy link

Choose a reason for hiding this comment

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

🚨 Breaking API Changes Detected

Package: github.com/cloudwego/eino/adk/middlewares/skill

Incompatible changes:

  • NewChatModelAgentMiddleware: removed
Review Guidelines

Please ensure that:

  • The changes are absolutely necessary
  • They are properly documented
  • Migration guides are provided if needed

⚠️ Please resolve this thread after reviewing the breaking changes.

type FileInfo struct {
// Path is the absolute path of the file or directory.
// Path is the path of the file or directory, which can be a filename, relative path, or absolute path.
Path string
Copy link

Choose a reason for hiding this comment

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

🚨 Breaking API Changes Detected

Package: github.com/cloudwego/eino/adk/middlewares/filesystem

Incompatible changes:

  • New: removed
Review Guidelines

Please ensure that:

  • The changes are absolutely necessary
  • They are properly documented
  • Migration guides are provided if needed

⚠️ Please resolve this thread after reviewing the breaking changes.

type FileInfo struct {
// Path is the absolute path of the file or directory.
// Path is the path of the file or directory, which can be a filename, relative path, or absolute path.
Path string
Copy link

Choose a reason for hiding this comment

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

🚨 Breaking API Changes Detected

Package: github.com/cloudwego/eino/adk/middlewares/summarization

Incompatible changes:

  • Config.ModelOptions: removed
Review Guidelines

Please ensure that:

  • The changes are absolutely necessary
  • They are properly documented
  • Migration guides are provided if needed

⚠️ Please resolve this thread after reviewing the breaking changes.

input: `{"path": "/"}`,
expected: []string{"/file1.txt", "/file2.go", "/dir1", "/dir2"},
expected: []string{"file1.txt", "file2.go", "dir1", "dir2"},
},
Copy link

Choose a reason for hiding this comment

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

🚨 Breaking API Changes Detected

Package: github.com/cloudwego/eino/adk/middlewares/filesystem

Incompatible changes:

  • New: removed
Review Guidelines

Please ensure that:

  • The changes are absolutely necessary
  • They are properly documented
  • Migration guides are provided if needed

⚠️ Please resolve this thread after reviewing the breaking changes.

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 87.09677% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.86%. Comparing base (2e0a483) to head (206e940).
⚠️ Report is 1 commits behind head on alpha/08.

Files with missing lines Patch % Lines
components/tool/utils/invokable_func.go 0.00% 2 Missing ⚠️
adk/filesystem/backend_inmemory.go 94.44% 1 Missing ⚠️
components/tool/callback_extra.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           alpha/08     #767      +/-   ##
============================================
- Coverage     79.88%   79.86%   -0.03%     
============================================
  Files           146      146              
  Lines         15806    15813       +7     
============================================
+ Hits          12627    12629       +2     
- Misses         2197     2202       +5     
  Partials        982      982              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…lob and ls command

Enhanced the filesystem backend to align Path field behavior with Python glob patterns and standard ls command output.
Also improved documentation for enhanced tool call wrapper methods.

Key Changes:

1. Updated FileInfo.Path field documentation:
   - Changed from "absolute path only" to support filename, relative path, or absolute path
   - Clarified that Path value depends on the command context (Ls vs Glob)

2. Modified LsInfo implementation:
   - Returns only filename/directory name instead of full path
   - Uses filepath.Base() for file entries
   - Uses parts[0] for immediate children in directory listings
   - Behavior now matches standard ls command output

3. Enhanced GlobInfo with Python glob compatibility:
   - Replaced custom recursive matching with github.com/bmatcuk/doublestar/v4 library
   - Implemented ** (double star) support for recursive directory traversal
   - Added absolute pattern detection (patterns starting with /)
   - Absolute patterns return absolute paths; relative patterns return relative paths
   - Supports ** in any position: beginning, middle, or end of pattern

4. Comprehensive test coverage:
   - Added TestInMemoryBackend_LsInfo_PathIsFilename: validates Ls returns filenames only
   - Added TestInMemoryBackend_GlobInfo_RelativePath: tests relative/absolute pattern behavior
   - Added TestInMemoryBackend_GlobInfo_RecursivePattern: validates ** recursive matching
   - Updated existing tests to match new Path field behavior

5. Documentation improvements:
   - Added comprehensive documentation for WrapEnhancedInvokableToolCall method
   - Added comprehensive documentation for WrapEnhancedStreamableToolCall method
   - Documentation follows the same pattern as existing WrapInvokableToolCall and WrapStreamableToolCall methods

Technical Implementation:
   - Uses doublestar.Match() for robust glob pattern matching with ** support
   - Pattern matching handles complex patterns like "**/*.go", "src/**/*.go"
   - Absolute patterns (starting with /) bypass basePath filtering and return full paths
   - Relative patterns respect basePath and return paths relative to it

Impact:
   - Ls command now returns clean filenames like standard Unix ls
   - Glob patterns behave identically to Python glob.glob() with recursive=True
   - Supports complex patterns like "**/*.go", "src/**/*.go", and "/absolute/path/**/*.go"
   - Enhanced tool wrapper methods are now properly documented for middleware developers
@hi-pender hi-pender merged commit 679b911 into alpha/08 Feb 5, 2026
15 of 16 checks passed
@hi-pender hi-pender deleted the feat/filesystemv4 branch February 5, 2026 12:48
hi-pender pushed a commit that referenced this pull request Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants