agentHost: refresh model catalogs periodically - #327408
Merged
roblourens merged 3 commits intoJul 25, 2026
Merged
Conversation
Refresh provider model catalogs every ten minutes from the Agent Host, preserve last-known-good catalogs on transient failures, and invalidate stale Copilot client generations after restart.\n\n(Written by Copilot)\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
This PR adds a host-owned periodic scheduler to refresh agent provider model catalogs, while updating providers to coalesce overlapping refreshes, guard against stale writes across client/token generations, and retain last-known-good catalogs on transient failures.
Changes:
- Introduces
AgentModelRefreshSchedulerand wires it into agent host startup to trigger periodicrefreshModelsacross providers. - Updates Copilot/Claude/Codex agents to coalesce concurrent refreshes, handle client-generation invalidation, and keep last-known-good catalogs on refresh failures.
- Adds/extends unit tests covering scheduler behavior, coalescing, stale in-flight drops, and last-known-good preservation.
Show a summary per file
| File | Description |
|---|---|
| src/vs/platform/agentHost/node/agentModelRefreshScheduler.ts | New periodic scheduler that triggers provider refreshModels on a fixed interval. |
| src/vs/platform/agentHost/node/agentHostMain.ts | Installs the scheduler for process-lifetime periodic refreshes. |
| src/vs/platform/agentHost/node/agentHostServerMain.ts | Installs the scheduler in the server entrypoint as well. |
| src/vs/platform/agentHost/node/agentService.ts | Exposes an observable of registered agents for background jobs like the scheduler. |
| src/vs/platform/agentHost/common/agentService.ts | Extends the IAgent contract with optional, non-rejecting refreshModels. |
| src/vs/platform/agentHost/node/copilot/copilotAgent.ts | Adds refresh coalescing, client-generation invalidation, and forced refresh semantics. |
| src/vs/platform/agentHost/node/claude/claudeAgent.ts | Adds refresh coalescing and retains last-known-good models on transient failures. |
| src/vs/platform/agentHost/node/codex/codexAgent.ts | Adds refresh coalescing and preserves last-known-good model catalogs on failures. |
| src/vs/platform/agentHost/test/node/agentModelRefreshScheduler.test.ts | New unit tests validating scheduler ticking, dispose behavior, and fault tolerance. |
| src/vs/platform/agentHost/test/node/copilotAgent.test.ts | Enhances test client to gate responses; adds tests for coalescing, restart refresh, and stale-flight dropping. |
| src/vs/platform/agentHost/test/node/claudeAgent.test.ts | Adds tests for refresh coalescing and last-known-good model retention. |
| src/vs/platform/agentHost/test/node/codex/codexModelRefresh.test.ts | Adds a Codex regression test ensuring last-known-good models persist on periodic failure. |
Review details
- Files reviewed: 12/12 changed files
- Comments generated: 2
- Review effort level: Low
Capture gated test responses in request order and use the standard disposable leak tracker in scheduler tests.\n\n(Written by Copilot)\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
roblourens
marked this pull request as ready for review
July 24, 2026 22:51
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @TylerLeonhardtMatched files:
|
joshspicer
previously approved these changes
Jul 24, 2026
justschen
previously approved these changes
Jul 24, 2026
roblourens
enabled auto-merge (squash)
July 24, 2026 22:56
dmitrivMS
reviewed
Jul 24, 2026
dmitrivMS
reviewed
Jul 24, 2026
dmitrivMS
reviewed
Jul 24, 2026
dmitrivMS
reviewed
Jul 24, 2026
Invalidate token-scoped Claude catalogs, serialize Copilot refreshes with client lifecycle changes, prevent late publications after shutdown, and improve refresh diagnostics.\n\n(Written by Copilot)\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
anthonykim1
approved these changes
Jul 25, 2026
anthonykim1
approved these changes
Jul 25, 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.
Summary
Fixes #327413.
Validation
npm run valid-layers-check(Written by Copilot)