Skip to content

feat(adk): Enhanced GrepRequest API by converting pointer parameters to value types and added extensive test suite for backend_inmemory GrepRaw implementation#750

Merged
zhuangjie1125 merged 2 commits intoalpha/08from
feat/filesystemv3
Feb 4, 2026

Conversation

@zhuangjie1125
Copy link
Contributor

Enhanced GrepRequest API by converting pointer parameters to value types and added extensive test suite for backend_inmemory GrepRaw implementation.

Key Improvements:

  1. GrepRequest Parameter Enhancement (backend.go):

    • Converted AfterLines, BeforeLines, ContextLines, HeadLimit, Offset from *int to int
    • Simplified parameter usage: direct value assignment instead of pointer references
    • Added clear semantics: values <= 0 indicate unset/default state
    • Improved API ergonomics and reduced boilerplate code
  2. Backend_inmemory GrepRaw Support (backend_inmemory.go):

    • Updated parameter handling logic to support value-based parameters
    • Enhanced applyContext function with proper value validation (> 0 checks)
    • Improved applyPagination to handle int parameters correctly
    • Maintained backward compatibility while simplifying implementation
  3. Middleware Integration (middlewares/filesystem/filesystem.go):

    • Added seamless pointer-to-value conversion for parameter passing
    • Implemented proper default value handling for HeadLimit and Offset
    • Ensured compatibility between middleware and backend layers
  4. Comprehensive Test Suite (backend_inmemory_test.go):

    • Added 40+ table-driven test scenarios for GrepRaw functionality
    • Implemented concurrent safety tests (50 goroutines)
    • Added edge case tests (long lines, unicode, special characters)
    • Created detailed content validation tests
    • Added 4 performance benchmark tests
    • Included complete test coverage documentation

Test Coverage:

  • All output modes: 100% (files_with_matches, content, count)
  • Parameter combinations: comprehensive coverage
  • Context lines: all combinations tested
  • Pagination: HeadLimit + Offset scenarios
  • Error handling: invalid patterns, boundary conditions
  • Concurrency: thread-safety verified
  • Performance: benchmarked common use cases

Impact:

  • Simplified API: ContextLines: 1 instead of &contextLines
  • Better usability: no pointer variable creation needed
  • Enhanced reliability: comprehensive test coverage added
  • Improved maintainability: clear parameter semantics

Files Changed:

  • adk/filesystem/backend.go: parameter type definitions
  • adk/filesystem/backend_inmemory.go: GrepRaw implementation
  • adk/filesystem/backend_inmemory_test.go: comprehensive test suite
  • adk/middlewares/filesystem/filesystem.go: middleware integration
  • adk/middlewares/filesystem/filesystem_test.go: test updates
  • adk/middlewares/filesystem/prompt.go: minor adjustments

@codecov
Copy link

codecov bot commented Feb 4, 2026

Codecov Report

❌ Patch coverage is 88.91455% with 48 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (alpha/08@6524f7a). Learn more about missing BASE report.

Files with missing lines Patch % Lines
adk/middlewares/filesystem/filesystem.go 75.00% 18 Missing and 11 partials ⚠️
adk/filesystem/backend_inmemory.go 94.00% 14 Missing and 5 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             alpha/08     #750   +/-   ##
===========================================
  Coverage            ?   80.25%           
===========================================
  Files               ?      145           
  Lines               ?    15617           
  Branches            ?        0           
===========================================
  Hits                ?    12534           
  Misses              ?     2109           
  Partials            ?      974           

☔ 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.

@zhuangjie1125 zhuangjie1125 force-pushed the feat/filesystemv3 branch 2 times, most recently from c8f70a6 to db312ab Compare February 4, 2026 07:36
…ensive test coverage

Enhanced GrepRequest API by converting pointer parameters to value types and added extensive test suite for backend_inmemory GrepRaw implementation.

Key Improvements:

1. GrepRequest Parameter Enhancement (backend.go):
   - Converted AfterLines, BeforeLines, ContextLines, HeadLimit, Offset from *int to int
   - Simplified parameter usage: direct value assignment instead of pointer references
   - Added clear semantics: values <= 0 indicate unset/default state
   - Improved API ergonomics and reduced boilerplate code

2. Backend_inmemory GrepRaw Support (backend_inmemory.go):
   - Updated parameter handling logic to support value-based parameters
   - Enhanced applyContext function with proper value validation (> 0 checks)
   - Improved applyPagination to handle int parameters correctly
   - Maintained backward compatibility while simplifying implementation

3. Middleware Integration (middlewares/filesystem/filesystem.go):
   - Added seamless pointer-to-value conversion for parameter passing
   - Implemented proper default value handling for HeadLimit and Offset
   - Ensured compatibility between middleware and backend layers

4. Comprehensive Test Suite (backend_inmemory_test.go):
   - Added 40+ table-driven test scenarios for GrepRaw functionality
   - Implemented concurrent safety tests (50 goroutines)
   - Added edge case tests (long lines, unicode, special characters)
   - Created detailed content validation tests
   - Added 4 performance benchmark tests
   - Included complete test coverage documentation

Test Coverage:
- All output modes: 100% (files_with_matches, content, count)
- Parameter combinations: comprehensive coverage
- Context lines: all combinations tested
- Pagination: HeadLimit + Offset scenarios
- Error handling: invalid patterns, boundary conditions
- Concurrency: thread-safety verified
- Performance: benchmarked common use cases

Impact:
- Simplified API: ContextLines: 1 instead of &contextLines
- Better usability: no pointer variable creation needed
- Enhanced reliability: comprehensive test coverage added
- Improved maintainability: clear parameter semantics

Files Changed:
- adk/filesystem/backend.go: parameter type definitions
- adk/filesystem/backend_inmemory.go: GrepRaw implementation
- adk/filesystem/backend_inmemory_test.go: comprehensive test suite
- adk/middlewares/filesystem/filesystem.go: middleware integration
- adk/middlewares/filesystem/filesystem_test.go: test updates
- adk/middlewares/filesystem/prompt.go: minor adjustments
@zhuangjie1125 zhuangjie1125 force-pushed the feat/filesystemv3 branch 2 times, most recently from 404d849 to 0c95be5 Compare February 4, 2026 08:57
@zhuangjie1125 zhuangjie1125 force-pushed the feat/filesystemv3 branch 2 times, most recently from 5e221ad to 3b81f9f Compare February 4, 2026 09:59
@zhuangjie1125 zhuangjie1125 force-pushed the feat/filesystemv3 branch 2 times, most recently from d8f9e4a to e4e019a Compare February 4, 2026 10:34
Add detailed JSON Schema descriptions to all filesystem tool argument
structs for better AI model understanding and tool invocation.

Changes:
- readFileArgs: Added descriptions for file_path, offset, and limit fields
- writeFileArgs: Added descriptions for file_path and content fields
- editFileArgs: Added descriptions for file_path, old_string, new_string,
  and replace_all fields with default value annotation
- globArgs: Added descriptions for pattern and path fields
- grepArgs: Added comprehensive descriptions for all 14 fields including
  pattern, path, glob, output_mode (with enum values), context options
  (-A/-B/-C), line numbers, case sensitivity, file type, pagination
  (head_limit/offset), and multiline mode

Also updated tool descriptions in prompt.go:
- WriteFileToolDesc: Improved usage guidelines with clearer instructions
- GlobToolDesc: Simplified description focusing on key capabilities

This enhancement enables LLM-based agents to better understand tool
parameters and generate more accurate tool calls.
@zhuangjie1125 zhuangjie1125 merged commit 374eed4 into alpha/08 Feb 4, 2026
16 checks passed
@zhuangjie1125 zhuangjie1125 deleted the feat/filesystemv3 branch February 4, 2026 12:20
hi-pender pushed a commit that referenced this pull request Feb 14, 2026
…to value types and added extensive test suite for backend_inmemory GrepRaw implementation (#750)

* feat(adk): enhance GrepRequest with value-type parameters and comprehensive test coverage

Enhanced GrepRequest API by converting pointer parameters to value types and added extensive test suite for backend_inmemory GrepRaw implementation.

Key Improvements:

1. GrepRequest Parameter Enhancement (backend.go):
   - Converted AfterLines, BeforeLines, ContextLines, HeadLimit, Offset from *int to int
   - Simplified parameter usage: direct value assignment instead of pointer references
   - Added clear semantics: values <= 0 indicate unset/default state
   - Improved API ergonomics and reduced boilerplate code

2. Backend_inmemory GrepRaw Support (backend_inmemory.go):
   - Updated parameter handling logic to support value-based parameters
   - Enhanced applyContext function with proper value validation (> 0 checks)
   - Improved applyPagination to handle int parameters correctly
   - Maintained backward compatibility while simplifying implementation

3. Middleware Integration (middlewares/filesystem/filesystem.go):
   - Added seamless pointer-to-value conversion for parameter passing
   - Implemented proper default value handling for HeadLimit and Offset
   - Ensured compatibility between middleware and backend layers

4. Comprehensive Test Suite (backend_inmemory_test.go):
   - Added 40+ table-driven test scenarios for GrepRaw functionality
   - Implemented concurrent safety tests (50 goroutines)
   - Added edge case tests (long lines, unicode, special characters)
   - Created detailed content validation tests
   - Added 4 performance benchmark tests
   - Included complete test coverage documentation

Test Coverage:
- All output modes: 100% (files_with_matches, content, count)
- Parameter combinations: comprehensive coverage
- Context lines: all combinations tested
- Pagination: HeadLimit + Offset scenarios
- Error handling: invalid patterns, boundary conditions
- Concurrency: thread-safety verified
- Performance: benchmarked common use cases

Impact:
- Simplified API: ContextLines: 1 instead of &contextLines
- Better usability: no pointer variable creation needed
- Enhanced reliability: comprehensive test coverage added
- Improved maintainability: clear parameter semantics

Files Changed:
- adk/filesystem/backend.go: parameter type definitions
- adk/filesystem/backend_inmemory.go: GrepRaw implementation
- adk/filesystem/backend_inmemory_test.go: comprehensive test suite
- adk/middlewares/filesystem/filesystem.go: middleware integration
- adk/middlewares/filesystem/filesystem_test.go: test updates
- adk/middlewares/filesystem/prompt.go: minor adjustments

* feat(adk): add jsonschema descriptions to filesystem tool arguments

Add detailed JSON Schema descriptions to all filesystem tool argument
structs for better AI model understanding and tool invocation.

Changes:
- readFileArgs: Added descriptions for file_path, offset, and limit fields
- writeFileArgs: Added descriptions for file_path and content fields
- editFileArgs: Added descriptions for file_path, old_string, new_string,
  and replace_all fields with default value annotation
- globArgs: Added descriptions for pattern and path fields
- grepArgs: Added comprehensive descriptions for all 14 fields including
  pattern, path, glob, output_mode (with enum values), context options
  (-A/-B/-C), line numbers, case sensitivity, file type, pagination
  (head_limit/offset), and multiline mode

Also updated tool descriptions in prompt.go:
- WriteFileToolDesc: Improved usage guidelines with clearer instructions
- GlobToolDesc: Simplified description focusing on key capabilities

This enhancement enables LLM-based agents to better understand tool
parameters and generate more accurate tool calls.
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