feat: support directory paths in get_symbols_overview with max_files safeguard (#1412)#1560
Open
weiconghe wants to merge 1 commit into
Open
feat: support directory paths in get_symbols_overview with max_files safeguard (#1412)#1560weiconghe wants to merge 1 commit into
weiconghe wants to merge 1 commit into
Conversation
eafacb1 to
78617d6
Compare
Contributor
Author
|
Hi, I noticed the CI checks failed on this PR, but the failures don't appear to be related to my changes:
Could you kindly rerun the failed jobs? Thanks! |
00453ca to
78617d6
Compare
…safeguard (issue oraios#1412) - Add directory support to GetSymbolsOverviewTool via _apply_directory, returning a per-file mapping of grouped symbols - Add max_files parameter (default 20) that raises ValueError when a directory contains more analyzable files than the limit, addressing maintainer feedback on issue oraios#1412 about unbounded top-level overviews - Single-file behavior is unchanged - Tests: directory happy path, single-file regression, max_files guard
78617d6 to
868ad1b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Closes #1412
Type of change
What does this PR do?
GetSymbolsOverviewToolnow supports directory paths, guarded bymax_files(Issue #1412)Problem:
get_symbols_overviewraisedValueError: Expected a file path, but got a directory pathwhen given a directory. Agents had to list directory contents, then call the tool per file — N round-trips for a common navigation pattern.Root cause: The underlying LSP layer (
request_overviewinsolidlsp/ls.py) already handled directories viarequest_dir_overview, but the tool layer insymbol_tools.pyexplicitly rejected directory paths.Maintainer concern (from @MischaPanch on the issue): A previous variant allowed directories, but it was deliberately restricted because models tended to start with the top-level directory, producing huge outputs. The maintainer hinted that a
max_filesoption could mitigate this.Fix:
_apply_directorymethod that delegates to the existing LSP directory support. When a directory path is given, the tool returns a per-file mapping of grouped symbols:{ "test_repo/services.py": {"Function": ["create_service_container", ...]}, "test_repo/models.py": {"Class": ["User"]} }Single-file behavior is completely unchanged.
max_filesparameter (default20). When a directory contains more analyzable files than the limit, the tool raisesValueErrorbefore serializing — the error message shows the actual count, a sample of file paths, and tells the agent to narrow the path or learn the layout from memories first. This directly addresses @MischaPanch's concern: the agent can't accidentally dump the top-level directory, and gets actionable guidance when it tries.How did you verify your code works?
Environment: Windows 11, Python 3.13, uv 0.11.13
New tests (all passing):
test_get_symbols_overview_directory_returns_per_file_symbols— passes a directory path, asserts the result is a per-file mapping with.pyfile keystest_get_symbols_overview_file_returns_same_format— regression test, single-file output format is unchanged (not wrapped in per-file mapping)test_get_symbols_overview_directory_raises_when_exceeds_max_files— passesmax_files=1against a directory with multiple files, assertsValueErrorwithmax_files=1in the messageRegression: All other Python-language tests in
TestSerenaAgentstill pass. (Some Go / C# / Rust / Kotlin / PowerShell tests fail in my local environment due to missing language-server binaries — unrelated to this PR and reproducible onmain.)Screenshots / recordings
N/A
Checklist