Skip to content

agentHost: park sessions whose provider cannot vouch for them until its catalog becomes readable - #342127

Merged
Sandeep Somavarapu (sandy081) merged 3 commits into
mainfrom
agents/park-provider-unavailable-sessions
Oct 16, 2026
Merged

Sandeep Somavarapu (sandy081) merged 3 commits into
mainfrom
agents/park-provider-unavailable-sessions

Conversation

@sandy081

Copy link
Copy Markdown
Member

Follow-up to #342077, as a separate PR. There is no separate issue; it was found while investigating today's Insiders agent host logs.

Problem

Catalog reconciliation already parks sourceUnresolvable sessions, but it retried providerUnavailable sessions on every pass. If a provider is registered but its catalog is unreadable, reconciliation opened each of its sessions' databases on every 30 s pass, indefinitely. In today's logs, the 69 older codex sessions in that state were re-attempted about 10 times per session per hour before Block 4a and about 80 times after it. This predates 4a, and #342077 left it in place.

Fix

  • Parking: providerUnavailable now parks a session like sourceUnresolvable. This applies both when the provider is unregistered (checked before any storage is opened) and when a registered provider can't vouch for the session. Parked sessions remember their provider.
  • Wake on an event, not a timer: when a provider's catalog becomes readable, wakeParkedProviderSessions releases only that provider's parked sessions, and schedules a pass only if any were released. That pass re-projects them and converts their legacy chat catalogs. Provider registration, session mutations and the hourly verification still wake parked sessions as before.
  • Race: a wake generation stops a pass from parking a session whose source it resolved just before a wake, in the same way as the existing dirty-marker check.
  • Chat moves (agentHost: harden chat moves (refusals, strict movable, session moves, Copilot storage, new sessions) #342047): parking and every wake, including the new per-provider wake, fire onDidChangeParkedSessions. Chat movability treats a parked legacy catalog as unverifiable, so it stays current. A loaded session never resolves providerUnavailable (its live summary supplies the metadata), so this doesn't block moves of open sessions.
  • Docs: AGENTS.md describes both parking reasons and their wake signals.

Measurement (passes every 30 s)

before after
Unit test, 110 sessions, session DB opens in an hour 6,000 110 (each session once, when it is parked), then the hourly verification's sample of 50
End to end, 70 sessions, session DB opens per pass 150 every pass 150, then 60, then 0
Converted once the catalog becomes readable (end to end) — 70 of 70

Tests

  • New:
    • An hour of passes over 110 sessions from two providers, with a per-provider wake and the hourly verification.
    • The wake-generation race.
    • An unregistered provider is parked without opening storage.
    • Parking and the per-provider wake fire change events for each session.
    • End to end through AgentService with the real database: 70 sessions are parked, then woken and converted when the catalog becomes readable.
  • Updated: the existing tests that relied on providerUnavailable being retried every pass now use a failing source. The chat-move tests from agentHost: harden chat moves (refusals, strict movable, session moves, Copilot storage, new sessions) #342047 call the new _park signature.
  • Mutations: eight, each applied, transpiled and run against both suite files, and each killed:
    1. Don't park a resolved providerUnavailable.
    2. Don't park a session whose provider is unregistered.
    3. No wake when the catalog becomes readable.
    4. The provider wake releases every provider's sessions.
    5. No wake-generation guard.
    6. Schedule a pass even when nothing was woken.
    7. The provider wake isn't announced.
    8. Parking isn't announced.

Validation

  • npm run transpile-client: passed.
  • npm run test-node -- --run …/agentService.test.ts --run …/agentHostCatalogReconciliationService.test.ts --run …/agentHostChatCatalogMigration.test.ts --run …/agentHostChatMovability.test.ts: 1159 passing, 0 failing.
  • npm run test-node -- --runGlob "**/vs/platform/agentHost/test/node/**/*.test.js": 11688 passing, 14 failing. All 14 are CopilotAgent environment failures; the same 14 fail on unmodified main.
  • npm run typecheck-client: 2 errors, both in copilotSdkManagedSettings.integrationTest.ts (ensembleTier). That file is untouched here, and the same 2 errors occur on unmodified origin/main. This change adds none.
  • npm run eslint -- <changed .ts files>: passed.
  • Hygiene (npm run precommit, also run by the commit hook): passed.
  • npm run build-fast was not run; dependency install hits an npm E401, and credentials were not changed.

…ts catalog becomes readable

Reconciliation parked `sourceUnresolvable` sessions but retried
`providerUnavailable` ones on every pass. A registered provider whose
catalog is unreadable (older codex sessions in production) therefore had
each session's database opened on every 30 s pass, indefinitely: about
10 re-attempts per session per hour before Block 4a and about 80 after it.

- `providerUnavailable` now parks the session like `sourceUnresolvable`,
  both when the provider is unregistered (checked before any storage is
  claimed) and when a registered provider cannot vouch for it. Parked
  sessions remember their provider.
- When a provider's catalog becomes readable, `wakeParkedProviderSessions`
  releases only that provider's parked sessions and a pass is scheduled if
  any were released. That pass re-projects them and converts their legacy
  chat catalogs. Provider registration, session mutations and the hourly
  verification still wake parked sessions as before.
- A wake generation keeps a pass from parking a session whose source it
  resolved before a wake, matching the existing dirty-marker guard.
- Parking and every wake, including the per-provider one, are announced
  through `onDidChangeParkedSessions`, so chat movability (#342047), which
  treats a parked legacy catalog as unverifiable, stays current.
- AGENTS.md describes the two parking reasons and their wake signals.

Measured with 110 such sessions and passes every 30 s: 6,000 session
database opens in an hour before, 110 after (each session's re-projection
parks it once), then only the hourly verification's sample. End to end
with 70 sessions: 150 opens every pass before; 150 and 60 in the first two
passes after, then 0. All 70 convert once the catalog becomes readable.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 17:45
@sandy081 Sandeep Somavarapu (sandy081) added this to the 1.143.0 milestone Oct 16, 2026
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: bb42e51d Current: 1f2c6658

Changed (1)

sessions/sessionActivityBar/sessionActivityBar/SubmenuOpen/Light
Before After
before after

roblourens
roblourens previously approved these changes Oct 16, 2026

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.

🟡 Changes recommended

Successfully restored legacy sessions can remain parked, blocking conversion and chat moves until another wake signal.

1 open finding
What changed in this PR

Reduces repeated Agent Host database reads by parking sessions whose provider cannot verify them, extending the earlier chat-catalog retry fix.

Changes:

  • Parks provider-unavailable sessions and adds provider-specific wakeups.
  • Guards against parking after a concurrent wake and emits parking-change notifications.
  • Adds regression coverage and documents wake behavior.
File Description
src/​vs/​platform/​agentHost/​test/​node/​agentService.test.ts Tests parking, wakeup, and conversion together.
src/​vs/​platform/​agentHost/​test/​node/​agentHostCatalogReconciliationService.test.ts Tests retry suppression, provider-specific wakes, races, and events.
src/​vs/​platform/​agentHost/​node/​agentService.ts Wakes parked sessions when their provider catalog becomes readable.
src/​vs/​platform/​agentHost/​node/​agentHostCatalogReconciliationService.ts Implements provider-aware parking and wake-generation checks.
src/​vs/​platform/​agentHost/​AGENTS.md Documents parking reasons and wake signals.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

…lookup

A legacy session parked as `providerUnavailable` can restore through its
provider's per-session lookup (`activation: 'restore'`) while the
provider's whole catalog stays unreadable. Codex, for example, answers a
restore but returns nothing to passive lookups until it is activated. That
restore neither made the catalog readable nor woke the session, so the
session stayed excluded from reconciliation. `_normalizeCatalogForMove`
then refused its chats as `legacyCatalog` until another wake, possibly
the hourly verification.

A successful restore is evidence that the session's source resolves, so it
now releases that session's parking and schedules a pass. Once loaded, the
session re-projects from its live state and converts.

Addresses review feedback on #342127.

Co-authored-by: Copilot <[email protected]>
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.

4 participants