Use custom activation events for Copilot and Posit Assistant#14899
Open
jmcphers wants to merge 2 commits into
Open
Use custom activation events for Copilot and Posit Assistant#14899jmcphers wants to merge 2 commits into
jmcphers wants to merge 2 commits into
Conversation
|
E2E Tests 🚀 Why these tags?
More on automatic tags from changed files. |
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.
Summary
When auditing memory usage as part of https://github.com/posit-dev/positron-builds/issues/1099, I found that a nontrivial amount of memory usage is attributed to AI features, especially the Copilot extension which is very large and loads a lot of tokenizers, etc.
Specifically, the bundled AI extensions (
copilot-chatandpositron-assistant) previously activated ononStartupFinished, so they loaded eagerly on every launch -- including for users who don't use AI features, where they only add to the memory footprint.This PR switches them to activate on demand via two custom activation events, fired by a new
AiExtensionActivationContributionwhile their backing settings are on (and re-fired if the user toggles a setting at runtime):onAiEnabled-- fired whileai.enabled(Positron's main AI switch) istrue.positron-assistantlistens for this.onCopilotEnabled-- fired whilechat.disableAIFeaturesis nottrue. Bothcopilot-chatandpositron-assistantlisten for this.positron-assistantlistens for both because it registers the default chat participants the Copilot chat UI depends on, but is not a declared extension dependency ofcopilot-chat, so it must come up alongside it. Each extension's on-demand activation events (e.g.onLanguageModelChat:copilot) are unchanged, so anything that actually uses AI still activates the extension immediately.Note
When this is part of a release build we will want a companion PR for Posit Assistant to also gate its activation on
onAiEnabled.Because we cannot unload an already-activated extension without a reload, turning a setting off mid-session does not deactivate anything; the extensions' individual features remain gated on their own preconditions. Turning a setting on activates immediately.
Release Notes
New Features
Bug Fixes
Validation Steps
@:assistant
onCopilotEnabledpath."chat.disableAIFeatures": true, reload, and confirm via the Running Extensions view thatcopilot-chatandpositron-assistantare not activated at startup."ai.enabled": false(with chat still enabled) and confirmpositron-assistantstill activates (viaonCopilotEnabled) so the chat backend is available.