Skip to content

agentHost: refresh model catalogs periodically - #327408

Merged
roblourens merged 3 commits into
microsoft:mainfrom
roblourens:roblou/agents/model-refresh-logic-agent-host
Jul 25, 2026
Merged

agentHost: refresh model catalogs periodically#327408
roblourens merged 3 commits into
microsoft:mainfrom
roblourens:roblou/agents/model-refresh-logic-agent-host

Conversation

@roblourens

@roblourens roblourens commented Jul 24, 2026

Copy link
Copy Markdown
Member

Summary

  • refresh Agent Host provider model catalogs every 10 minutes from a single host-owned scheduler
  • coalesce periodic refreshes while preserving forced refreshes for token, transport, usage-source, and client-generation changes
  • refresh Copilot models after CLI restart and prevent stale same-token responses from the previous client generation from publishing
  • preserve last-known-good Claude, Codex, and Copilot catalogs after transient refresh failures

Fixes #327413.

Validation

  • TypeScript typecheck
  • npm run valid-layers-check
  • staged-file precommit hygiene
  • full Agent Host unit suite: 3427 passing, 0 failing

(Written by Copilot)

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>
Copilot AI review requested due to automatic review settings July 24, 2026 22:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 AgentModelRefreshScheduler and wires it into agent host startup to trigger periodic refreshModels across 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

Comment thread src/vs/platform/agentHost/test/node/copilotAgent.test.ts
Comment thread src/vs/platform/agentHost/test/node/agentModelRefreshScheduler.test.ts Outdated
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
roblourens marked this pull request as ready for review July 24, 2026 22:51
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@TylerLeonhardt

Matched files:

  • src/vs/platform/agentHost/node/claude/claudeAgent.ts

joshspicer
joshspicer previously approved these changes Jul 24, 2026
justschen
justschen previously approved these changes Jul 24, 2026
@roblourens
roblourens enabled auto-merge (squash) July 24, 2026 22:56
Comment thread src/vs/platform/agentHost/node/claude/claudeAgent.ts
Comment thread src/vs/platform/agentHost/node/copilot/copilotAgent.ts
Comment thread src/vs/platform/agentHost/node/copilot/copilotAgent.ts Outdated
Comment thread src/vs/platform/agentHost/node/agentModelRefreshScheduler.ts Outdated
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>
@roblourens
roblourens dismissed stale reviews from justschen and joshspicer via 48579de July 25, 2026 00:53
@roblourens
roblourens merged commit a6aa5f8 into microsoft:main Jul 25, 2026
29 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.131.0 milestone Jul 25, 2026
lramos15 added a commit that referenced this pull request Aug 4, 2026
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.

Agent Host model catalogs are not refreshed periodically

6 participants