Repository navigation
[cherry-pick] agentHost: refresh plugin state when the runtime reloads contributions - #348660
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were reported for the changes that refresh plugin state after runtime contribution reloads.
No open issues 🎉
What changed in this PR
Cherry-picks #348606 to keep Agent Host plugin state current when the Copilot runtime reloads contributions, reducing stale plugin enablement in the UI.
Changes:
- Uses top-level skill, custom-agent, and MCP-server reload events to trigger plugin-state checks.
- Coalesces overlapping checks and republishes only when inventory changes, including reloads received before peer-chat registration.
- Adds tests for event filtering, change detection, burst handling, and registration timing.
| File | Description |
|---|---|
src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts |
Tests top-level reload signals with MCP skills disabled and subagent events ignored. |
src/vs/platform/agentHost/test/node/copilotAgent.test.ts |
Tests inventory publication, throttling, and peer-chat registration timing; updates session stubs. |
src/vs/platform/agentHost/node/copilot/copilotSessionWrapper.ts |
Exposes the runtime’s custom-agent update event. |
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts |
Emits contribution-reload notifications for top-level runtime events. |
src/vs/platform/agentHost/node/copilot/copilotAgent.ts |
Routes reload notifications to throttled plugin checks and handles pre-registration events. |
Review effort: Balanced
Vritant Bhardwaj (vritant24)
approved these changes
Nov 16, 2026
Vritant Bhardwaj (vritant24)
enabled auto-merge
November 16, 2026 19:54
Dirk Bäumer (dbaeumer)
approved these changes
Nov 16, 2026
Vritant Bhardwaj (vritant24)
merged commit Nov 16, 2026
d4344e3
into
release/1.147
53 of 54 checks passed
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.
Cherry-pick of #348606 from
main.Problem
The Copilot runtime installs organization-required and team plugins in the background after a session starts. The Agent Host only re-read plugin state on
session.infomanaged_plugins_complete, which the runtime sends only when every required plugin succeeds. After a partial failure (for example, an org policy that requires a plugin that doesn't exist), or on the runtime's best-effort team-default path, nothing tells the UI to refresh. A plugin the runtime enabled then appears out of date until the user switches chats and back. Plugin preparation can finish after the first turn ends, so checking at the end of a turn is too early.Change
Every runtime plugin reload ends by reloading skills, agents and MCP servers. The top-level
session.skills_loaded,session.mcp_servers_loadedandsession.custom_agents_updatedevents are now used as a cue to re-check plugin state:CopilotAgentSessionfires a newonDidReloadRuntimeContributionsevent for these top-level events. Subagent events are ignored. It fires whether or not MCP skills are enabled. The existing MCP skills and MCP server inventory handlers are unchanged.CopilotSessionWrapperexposesonCustomAgentsUpdated.CopilotChatEntryroutes the new event toSessionPluginController.publishIfRuntimePluginsChanged(). This is aThrottleraround the existingpublishWhenSettled(true): it readsplugins.listonce, compares the result with the previous read, and publishes only if something changed. A reload fires several events at once, so they are combined into at most one check running and one waiting.onDidChangeRuntimePlugins, which still does the full rediscovery formanaged_plugins_complete.Notes for reviewers
plugins.listkeeps failing, the existing warning repeats about once per reload burst.mcp_servers_loadedis re-sent on later turns, so this adds oneplugins.listcall per chat per turn when nothing changed. Nothing is published in that case.skills_loaded.PluginCachesInvalidatedevent would be the ideal signal, but the SDK doesn't expose it.publishWhenSettled(true)callers.Testing
./scripts/test.sh --reporter dot --run src/vs/platform/agentHost/test/node/copilotAgent.test.ts --run src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts: passed (2838 passing, 1 pending)plugins.listcalls.pnpm run typecheck-client: passedpnpm run oxlint <changed files>: passedManual test: