Repository navigation
Extract reusable CopilotToolInvocationService from FixVulnerabilitiesService - #7418
Merged
Merged
Conversation
jebriede
reviewed
May 26, 2026
jebriede
left a comment
Contributor
There was a problem hiding this comment.
This extraction is clean and the CopilotToolSessionResult pattern nicely encapsulates the session lifecycle, failure checks, resource ownership, and resource cleanup, so callers can focus on their responsibility! Left a few comments on null safety and resource disposal.
jebriede
reviewed
May 28, 2026
donnie-msft
force-pushed
the
dev-donnie-msft-copilotInvokeRefactor
branch
from
May 29, 2026 01:06
e4a7365 to
10e1d96
Compare
jebriede
reviewed
May 29, 2026
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.
Bug
Fixes: https://github.com/NuGet/Client.Engineering/issues/3795
Description
Extracts the shared Copilot pre-flight logic (auth check, service available, etc) into a reusable
ICopilotToolInvocationServiceso it can be shared across multiple GH Copilot entry points.ICopilotToolInvocationService.csCopilotToolInvocationService.csFixVulnerablitiesService; minimal refactoring to accept parameters instead of hard-coded values.CopilotToolSession.csCopilotThread+ discovered functions + disposables into a singleIAsyncDisposableso callers don'tmanage lifetimes manually.CopilotToolSessionResult.csCopilotToolSessionError.csFixVulnerablitiesService).FixVulnerablitiesService.csICopilotToolInvocationService; method is ~40 lines shorter and focuses only on prompt construction and request dispatch.Copilot service availability handling
Per the latest Copilot extensibility guidance, callers should treat a successful
IServiceBroker.GetProxyAsync<ICopilotService>as confirmation that the service is available, and subscribe toIServiceBroker.AvailabilityChangedwhen holding the service long-term.ICopilotService.CheckAvailabilityAsyncandSubscribeToAvailabilityAsyncare deprecated.ICopilotToolInvocationServicenow exposes anAvailabilityChangedevent that forwards broker notifications filtered to the Copilot service moniker, so future long-lived consumers can react. Today's consumer (FixVulnerablitiesService) uses sessions per-invocation viaawait usingand does not need to subscribe.PR Checklist