Skip to content

Use custom activation events for Copilot and Posit Assistant#14899

Open
jmcphers wants to merge 2 commits into
mainfrom
feature/ai-on-demand
Open

Use custom activation events for Copilot and Posit Assistant#14899
jmcphers wants to merge 2 commits into
mainfrom
feature/ai-on-demand

Conversation

@jmcphers

Copy link
Copy Markdown
Collaborator

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-chat and positron-assistant) previously activated on onStartupFinished, 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 AiExtensionActivationContribution while their backing settings are on (and re-fired if the user toggles a setting at runtime):

  • onAiEnabled -- fired while ai.enabled (Positron's main AI switch) is true. positron-assistant listens for this.
  • onCopilotEnabled -- fired while chat.disableAIFeatures is not true. Both copilot-chat and positron-assistant listen for this.

positron-assistant listens for both because it registers the default chat participants the Copilot chat UI depends on, but is not a declared extension dependency of copilot-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

  • N/A

Bug Fixes

  • Reduce memory usage in some configurations by not loading AI features when they're disabled

Validation Steps

@:assistant

  1. With default settings, open the Chat pane and confirm the Positron Assistant still works (the default chat participant responds) -- this exercises the onCopilotEnabled path.
  2. Set "chat.disableAIFeatures": true, reload, and confirm via the Running Extensions view that copilot-chat and positron-assistant are not activated at startup.
  3. Set "ai.enabled": false (with chat still enabled) and confirm positron-assistant still activates (via onCopilotEnabled) so the chat backend is available.
  4. Toggle the settings back on and confirm the extensions activate without a reload.

@github-actions

Copy link
Copy Markdown

E2E Tests 🚀
This PR will run tests tagged with: @:critical @:assistant

Why these tags?
Tag Source
@:critical Always runs (required)
@:assistant PR description

More on automatic tags from changed files.

readme  valid tags

@jmcphers jmcphers requested a review from timtmok July 15, 2026 23:32
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.

1 participant