gopls: add opt-in eager diagnostic clearing for agentic workflows#620
gopls: add opt-in eager diagnostic clearing for agentic workflows#620alliprice wants to merge 2 commits intogolang:masterfrom
Conversation
Add opt-in setting (eagerDiagnosticsClear, default: false) that immediately publishes diagnostics for changed files in didModifyFiles when the change originates from didChange. The existing version-filtering in publishFileDiagnosticsLocked ensures stale view diagnostics tagged with the previous version are excluded, producing an empty set that clears stale errors. This prevents agentic/headless LSP clients from acting on stale diagnostics between an edit and the completion of reanalysis. Includes settings documentation, integration test, and schema entry.
settings.md is auto-generated from struct doc comments via gopls/internal/doc/generate. The previous commit manually edited settings.md with additional text not present in the source doc comment, which would cause TestGenerated to fail. Regenerated using: cd gopls/internal/doc/generate && go run . The settings.go doc comment is the source of truth.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
557557e to
ff54883
Compare
|
This PR (HEAD: ff54883) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/tools/+/751400. Important tips:
|
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/751400. |
|
Message from Gopher Robot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be Please don’t reply on this GitHub thread. Visit golang.org/cl/751400. |
Summary
Adds an opt-in
eagerDiagnosticsClearsetting that immediately publishes empty diagnostics for a file when its content changes (viatextDocument/didChange), before reanalysis completes.Motivation
The current debounce behavior is correct for GUI editors - it prevents diagnostic flicker while a human is typing. This default should remain unchanged.
However, LSP is increasingly used by headless agentic tools (AI coding assistants, automated refactoring systems) that consume diagnostics programmatically. For these clients, stale diagnostics between an edit and reanalysis are incorrect input to decision loops. This can cause:
This is not about servers being buggy - it is about different client requirements. Interactive editors need stable UI. Programmatic clients need immediate staleness signals.
Changes
New setting:
eagerDiagnosticsClear(default:false, status:"advanced")textDocument/didChangetriggers an immediate publish of empty diagnostics for the changed fileImplementation:
EagerDiagnosticsCleartoDiagnosticOptionsinsettings.godidModifyFilesintext_synchronization.goforFromDidChangecausepublishFileDiagnosticsLockedpipelineTests: New integration test verifies:
Documentation: Updated
gopls/doc/settings.mdwith new settingConfiguration
{ "gopls": { "eagerDiagnosticsClear": false } }Setting this to
trueis intended for non-UI rapid-edit workflows such as agentic coding tools.Test Plan
go test ./...go test -run TestEagerDiagnosticInvalidation ./gopls/internal/test/integration/diagnosticsRelated Work
This is part of a coordinated effort across multiple LSP server ecosystems to support agentic workflows. See: https://github.com/lsp-eager-invalidation
Similar PRs: