Skip to content

perf: improve Java LSP tool result handoff#1031

Draft
wenytang-ms wants to merge 2 commits into
mainfrom
experiment/lsp-tool-contract-tuning
Draft

perf: improve Java LSP tool result handoff#1031
wenytang-ms wants to merge 2 commits into
mainfrom
experiment/lsp-tool-contract-tuning

Conversation

@wenytang-ms

Copy link
Copy Markdown
Contributor

Summary

This draft follows the 0.27.5 Java LSP telemetry diagnosis:

  • findSymbol -> findSymbol improved from the 0.27.4 baseline but is still high (~43.8%).
  • For success_small_result, the next tool is still findSymbol ~41.7% of the time, even though these results should usually be directly consumable.
  • getFileStructure still has a noticeable fileNotFound / outsideWorkspace tail, and findSymbol previously returned location as path:line while getFileStructure expected a clean path.

Changes

  • Return more directly consumable findSymbol result fields: file, startLine, endLine, range, and outlineInput.
  • Add a top-level nextStep hint to findSymbol responses, with stronger guidance for small exact result sets.
  • Let file resolution tolerate Java location strings such as src/Foo.java:42.
  • Improve multi-root relative-path handling when asRelativePath includes the workspace folder name.
  • Update LM tool metadata, skill docs, and Java chat instruction to prefer outlineInput / file handoff.

Validation

  • npm run compile
  • npm run tslint
  • npm test currently fails in existing Library Controller tests because toReferencedLibraryPath / toReferencedLibraryExcludePath are not exported from extension_bundle_1; unrelated to this LSP tool change.

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.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@wenytang-ms wenytang-ms changed the title Improve Java LSP tool result handoff perf: improve Java LSP tool result handoff Jun 9, 2026
@wenytang-ms wenytang-ms requested a review from Copilot June 9, 2026 07:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the Java LSP Copilot tools’ result “handoff” so downstream steps (e.g., read_file / lsp_java_getFileStructure) can consume lsp_java_findSymbol output more directly, and so file resolution is more tolerant of Java-style path:line inputs and multi-root workspaces.

Changes:

  • Enhanced lsp_java_findSymbol payload with file, startLine, endLine, and outlineInput, and added a nextStep hint to reduce unnecessary repeat tool calls.
  • Made file URI resolution tolerate Java location suffixes (e.g., src/Foo.java:42) and improved multi-root relative-path handling when the workspace folder name is included.
  • Updated skill docs, instrument instructions, and tool metadata to prefer outlineInput/file handoff patterns.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/copilot/tools/javaContextTools.ts Adds Java path:line tolerance, improves multi-root relative resolution, and enriches findSymbol results with additional fields and guidance.
resources/skills/java-lsp-tools/SKILL.md Documents the updated findSymbol output fields and the preferred handoff flow using outlineInput/file.
resources/instruments/javaLspContext.instructions.md Updates Java chat instructions to prefer read_file with file/range and getFileStructure with outlineInput.
package.json Updates tool metadata/schema descriptions to reflect new fields and tolerated path:line inputs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/copilot/tools/javaContextTools.ts
Comment thread src/copilot/tools/javaContextTools.ts Outdated
Comment on lines +343 to +346
const nextStep = symbols.length <= 3
? [
"These are exact Java symbol locations.",
"Use read_file on the returned file/range, or lsp_java_getFileStructure with outlineInput for broader file context.",
Use normalized relative paths consistently when resolving file structure inputs and classify truncated findSymbol responses before small exact-result guidance.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants