You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf: improve Java LSP tool result handoff (#1031)
* Improve Java LSP tool result handoff
Return structured file and line fields from findSymbol so the model can consume precise ranges without repeating symbol search. Accept line-suffixed Java locations in file structure resolution and document outlineInput handoff.
* Address Java LSP handoff review comments
Use normalized relative paths consistently when resolving file structure inputs and classify truncated findSymbol responses before small exact-result guidance.
* Remove speculative Java location suffix handling
Keep the PR focused on the evidence-backed findSymbol handoff contract. Do not claim getFileStructure accepts path:line inputs without telemetry proving that case.
* Remove prescriptive findSymbol next step
Keep findSymbol results as structured location data and leave next-tool choice to the model. The payload still exposes file, line, range, and outlineInput for downstream consumption without embedding result-level routing guidance.
* Use file field for Java LSP handoff
Remove the redundant outlineInput field and keep findSymbol output focused on factual location data: file, startLine, endLine, and range. getFileStructure can consume the returned file when broader file outline context is needed.
* Return read_file input from Java symbol lookup
* Add read ranges to Java file structure
* Tighten Java file structure limit
* Remove ambiguous Java symbol location field
* perf: trim Java LSP tool descriptions to reduce token cost
modelDescription is sent to the model on every request, so condense both
tool descriptions and the uri param description while keeping the
read_file (offset/limit) handoff and no-re-search guidance intact.
* fix: address review nits on getFileStructure limit and instruction tool name
- Use nullish coalescing + Math.floor for getFileStructure limit so an
explicit 0 and fractional values are handled correctly.
- Use the full lsp_java_findSymbol tool name in the Java LSP instructions.
Copy file name to clipboardExpand all lines: package.json
+7-3Lines changed: 7 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,7 @@
52
52
{
53
53
"name": "lsp_java_getFileStructure",
54
54
"toolReferenceName": "javaFileStructure",
55
-
"modelDescription": "Get a known Java file's outline: classes, interfaces, methods, fields, symbol kinds, and line ranges, to pick a precise read_file range instead of reading the whole file.\n\nUse after lsp_java_findSymbol returns a file, or when the user gave a Java file path; do not guess paths. Not for workspace-wide search\u2014use lsp_java_findSymbol for that. Do not re-call for the same file unless the first result was empty.",
55
+
"modelDescription": "Outline a known Java file (classes, methods, fields with line ranges) to pick a precise read_file range instead of reading the whole file. Needs a path from lsp_java_findSymbol or the user — do not guess. Returns file plus per-symbol readFileRange ({ offset, limit }) for read_file. Use limit to cap outline items (default 20, max 60). Not for workspace search (use lsp_java_findSymbol).",
56
56
"displayName": "Java: Get File Structure",
57
57
"userDescription": "Get a Java file outline with classes, methods, fields, and line ranges.",
58
58
"tags": [
@@ -69,7 +69,11 @@
69
69
"properties": {
70
70
"uri": {
71
71
"type": "string",
72
-
"description": "Workspace-relative path to a Java file. Must be a known path from prior tool results or user input — do not guess."
72
+
"description": "Workspace-relative path to a Java file, from lsp_java_findSymbol or user input — do not guess."
73
+
},
74
+
"limit": {
75
+
"type": "number",
76
+
"description": "Maximum outline items to return (default: 20, max: 60). Use a smaller value when only top-level context is needed."
73
77
}
74
78
},
75
79
"required": [
@@ -80,7 +84,7 @@
80
84
{
81
85
"name": "lsp_java_findSymbol",
82
86
"toolReferenceName": "javaFindSymbol",
83
-
"modelDescription": "Find Java class, interface, method, or field definitions across the workspace by name or partial identifier. Prefer over grep_search, file_search, semantic_search, or search subagents for Java symbol lookup.\n\nOn relevant results, do not repeat with a similar query; continue with lsp_java_getFileStructure or read_file on the returned line range. The tool retries internally, so on an empty result do not re-search\u2014retry once only if it reports indexing in progress, otherwise use generic search.\n\nDo not use for non-Java files, literals, comments, build/XML files, or conceptual exploration.",
87
+
"modelDescription": "Find Java class/interface/method/field definitions across the workspace by name or partial identifier. Prefer over grep_search, file_search, or semantic_search for Java symbol lookup. Each result has file and readFileInput ({ filePath, offset, limit }) for read_file; use it when source is needed, or lsp_java_getFileStructure with file for broader context. On empty results don't re-search (it retries internally); retry once only if it reports indexing in progress, else use generic search. Not for non-Java files, literals, comments, or build/XML files.",
84
88
"displayName": "Java: Find Symbol",
85
89
"userDescription": "Find Java class, method, field, or interface definitions by name.",
Copy file name to clipboardExpand all lines: resources/instruments/javaLspContext.instructions.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,6 @@ For Java symbol navigation, two compiler-accurate `lsp_java_*` tools are availab
10
10
11
11
If these tools are not already available in the current tool list, load them with `tool_search` using a query such as `Java LSP symbol navigation lsp_java`.
12
12
13
-
Use `lsp_java_findSymbol` before `grep_search`, `search_subagent`, `semantic_search`, or `file_search` only when the task is to locate Java symbols by name or partial identifier. If it returns relevant symbols, do not call it again with the same or similar query; next use `lsp_java_getFileStructure`for the returned file or `read_file` on the smallest useful line range.
13
+
Use `lsp_java_findSymbol` before `grep_search`, `search_subagent`, `semantic_search`, or `file_search` only when the task is to locate Java symbols by name or partial identifier. If it returns relevant symbols and source is needed, call `read_file`with the returned `readFileInput`, or call `lsp_java_getFileStructure`with the returned `file` when broader file context is needed.
14
14
15
-
Use `lsp_java_getFileStructure` only with a path confirmed by the user or a previous tool result. Do not guess paths. Use generic search for string literals, comments, XML, Gradle/Maven files, non-Java files, or broad conceptual exploration. `findSymbol` already retries internally with a normalized identifier, so do not re-issue the same search on an empty result: if it reports indexing in progress, retry once after a short pause; otherwise fall back to generic search.
15
+
Use `lsp_java_getFileStructure` only with a path confirmed by the user or a previous tool result. Prefer `file` from `lsp_java_findSymbol`; do not guess paths. Its output includes a top-level `file` and per-symbol `readFileRange`; to read a selected symbol, call `read_file` with `filePath=file` and that `readFileRange`. Use `limit` to keep large outlines small. Use generic search for string literals, comments, XML, Gradle/Maven files, non-Java files, or broad conceptual exploration. `lsp_java_findSymbol` already retries internally with a normalized identifier, so do not re-issue the same search on an empty result: if it reports indexing in progress, retry once after a short pause; otherwise fall back to generic search.
Copy file name to clipboardExpand all lines: resources/skills/java-lsp-tools/SKILL.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,14 +12,14 @@ Two compiler-accurate tools backed by the Java Language Server (jdtls). They ret
12
12
### `lsp_java_findSymbol`
13
13
Search for Java symbol definitions (classes, methods, fields) by name across the workspace. Supports partial matching.
14
14
- Input: `{ query, limit? }` — limit defaults to 20, max 50
15
-
- Output: `{ results: [{ name, kind, container?, location, range }], total }` (~60 tokens); `range` is `L start-end`
15
+
- Output: `{ results: [{ name, kind, container?, file, startLine, endLine, readFileInput, range }], total }`; `readFileInput` is `{ filePath, offset, limit }` for `read_file`, and `file` can be passed to `lsp_java_getFileStructure`
16
16
-**Use instead of**`grep_search`, `file_search`, `semantic_search`, or `search_subagent` when looking for where a Java class/method/field is defined by identifier
17
-
-Do not repeat with the same or similar query after relevant results are returned
17
+
-When source is needed for a returned symbol, use its `readFileInput` directly
18
18
19
19
### `lsp_java_getFileStructure`
20
20
Get hierarchical outline of a Java file (classes, methods, fields) with line ranges.
21
-
- Input: `{ uri}` — workspace-relative path. Must be a known path from prior tool results or user input — do not guess
22
-
- Output: symbol tree with `L start-end` ranges (~100 tokens)
21
+
- Input: `{ uri, limit? }` — workspace-relative path plus max outline items. Prefer `file` from `lsp_java_findSymbol`; limit defaults to 20, max 60. Must be a known path from prior tool results or user input — do not guess
22
+
- Output: `{ file, symbols: [{ name, kind, startLine, endLine, readFileRange, range, detail?, children? }], truncated? }`; call `read_file` with `filePath=file` and the selected symbol's `readFileRange`
23
23
-**Use before**`read_file` when you need to choose a precise line range in a known Java file
24
24
25
25
## When to Use
@@ -34,9 +34,9 @@ Get hierarchical outline of a Java file (classes, methods, fields) with line ran
If `findSymbol` returns relevant symbols, move forward to `getFileStructure` or`read_file`; do not call `findSymbol` again with the same or similar identifier.
39
+
If `lsp_java_findSymbol` returns relevant symbols and source is needed, call`read_file` with the returned `readFileInput`, or call `lsp_java_getFileStructure`with the returned `file` when broader file context is needed.
0 commit comments