Skip to content

Allow Diagnostic providers to enrich AI-driven fix workflows with context via an optional method #252011

Open
@m-paternostro

Description

@m-paternostro

VS Code offers a “Fix using Copilot” link in the hover UI for diagnostics. When selected, this triggers an in-editor chat session with the /fix command, invoking an AI-driven code fix based on the diagnostic.

However, extension authors who contribute diagnostics via languages.createDiagnosticCollection() currently have no way to enrich that fix flow with domain-specific context - e.g. remediation hints, surrounding logs, links to documentation, or synthetic analysis results. This often limits the quality and relevance of AI-generated fixes, especially for domain-specific tooling (e.g. linters, policy checkers, custom analysis engines).


Proposal

Introduce a new optional hook for diagnostic collections:

provideFixInformation?: (diagnostic: Diagnostic) => ProviderResult<string | undefined>;

This could be added either:

  • as a method on the DiagnosticCollection, or
  • as part of a new options object to languages.createDiagnosticCollection(name: string, options?: {...}).

The returned string would be included in the AI model prompt when fixing that diagnostic—providing structured, dynamic, and extension-specific guidance.


Use Cases

  • A security extension detects a risky pattern and adds an explanation of why it’s insecure and how to safely rewrite it.
  • A custom DSL linter includes auto-generated fix rationale or references to the project’s style guide.
  • An extension analyzing build errors includes metadata like full macro expansions or evaluated conditions that don’t appear directly in the source.

Design Considerations

  • This does not prescribe a specific UX or interaction model - how the Copilot chat or any agent uses the string is up to them.
  • The term “model” is intentionally used here instead of “agent” because it is unclear whether /fix flows operate in agent mode or not.
  • This hook could also be reused in future diagnostic flows that involve automated analysis or remediation, beyond just /fix.
  • Whenever pertinent, the same pattern could be added to other "editor overlay providers"

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions