Skip to content

agentHost: stop retrying chat catalog conversions that wait for an impossible re-projection - #342077

Merged
Sandeep Somavarapu (sandy081) merged 2 commits into
mainfrom
agents/fix-catalog-conversion-retry-storm
Oct 16, 2026
Merged

Sandeep Somavarapu (sandy081) merged 2 commits into
mainfrom
agents/fix-catalog-conversion-retry-storm

Conversation

@sandy081

Copy link
Copy Markdown
Member

Fixes a production regression from Move Chats Block 4a (#341904). There is no separate issue; it was found in today's Insiders agent host logs.

Root cause

Block 4a C4 removed the requiresLegacyChatCatalog gate, so older provider-scheme sessions (codex:/, copilotcli:/, claude:/) now go through chat catalog conversion. For about 110 of them, the provider can't vouch for the session. Either it is registered with an unreadable catalog (providerUnavailable), or it no longer knows the session (sourceUnresolvable, parked). Their aggregate therefore never becomes verified, and every conversion ends notReady: the session aggregate is unverified or awaits its re-projection. Each attempt then fed a loop:

  1. Opened the session DB before checking. _migrateChatCatalog ran reconcileLegacy and runMigrationExclusive, which calls tryOpenDatabase, before migrateChatCatalogV2 read the cheap central state.
  2. Marked the payload dirty on notReady. This bumped the dirty revision, so in-flight re-projections came back superseded. It also woke parked sessions, so the reconciliation re-opened them on the next pass.
  3. Bypassed the retry limit of 5. The limit only bounds convertAfterReprojection. The conversion batch re-attempted every legacy session on each cursor cycle. _convertReprojected treated parked and unverified sessions as ready, because _listDirtySessions omits parked rows. On top of that, every attempt scheduled a follow-up pass at the 30 s floor.

Evidence (Insiders e9f10b9, which contains 38f4504; counts only)

  • About 717 registered sessions, about 110 affected: 69 codex resolving providerUnavailable, plus copilotcli/claude sessions resolving sourceUnresolvable.
  • Two retained windows of about 5 min each: 432 and 488 kind=migration operations, with 4–6 per session per window. Passes ran every 20–30 s (median gap 22 s). Up to 159 operations per pass, against 50 before 4a.
  • "N attempts in a row" reached 14 and 19 per session within a process.
  • Parking was defeated. Pre-4a (6756a73), the 32 sourceUnresolvable sessions were re-attempted about 8–9 times in 4 hours. Post-4a, 22 of them were re-attempted 3 times in 5 minutes.
  • codex providerUnavailable retries went from about 10 to about 80 per session per hour.
  • listSessions median went from 151 ms (n=15) to 519 ms during the storm (n=5). This is suggestive only.

Fix

  • agentService._migrateChatCatalog: a new _readChatCatalogConversionReadiness reads only readCatalogSnapshot and getSessionV2. An unverified or dirty aggregate returns notReady without opening session.db, writing, or waking anything, because its re-projection is already owed. _migrateChatMetadataWrite uses the same helper. The check under the session lock stays authoritative, and catalog-override restores are unchanged.
  • _convertReprojected: a waiting session becomes ready only when this pass re-projected it (succeeded, or an already-current skipped), or when its verified receipt is clean. Parked and unverified sessions now wait without an attempt.
  • Conversion batch: skips legacy sessions that are waiting for re-projection. Older-build edit imports are unaffected.
  • convertAfterReprojection: does nothing for a session already waiting, and requests no follow-up pass when called inside a pass.
  • Docs: agentHostChatCatalogV2.md describes the new behaviour.

4a's guarantees are kept: sessions still convert once they can, there are no URI-derived owners, and no optional APIs.

Measurement (110 unvouchable sessions, twelve 30 s passes ≈ 6 min)

before after
kind=migration operations 150 per pass (≈300/min) 50, 50, 10 in the first three passes, then 0
Session DB opens 350 per pass (≈700/min) 150, 150, 30 in the first three passes, then 0
Central dirty marks 100 per pass 0
Self-requested follow-up passes (unit, 12 sessions) 7 0

After the fix, all remaining operations and opens are the reconciliation parking each session once; conversion opens and writes nothing. In the unit test, once the source resolves again, all 12 sessions convert. Before the fix only 8 of 12 did, because their retry budget was spent while unresolvable.

Remaining, not changed here (pre-existing, needs a decision)

codex sessions whose provider is registered but whose catalog is unreadable resolve providerUnavailable only after their session DB is opened. They are never parked, so they are re-attempted on every pass. This predates 4a (about 10 per session per hour on 6756a73). Parking them, with a wake when the provider's catalog becomes readable, would change re-projection retry policy, so it is left as a follow-up.

Tests

  • New, reconciliation: 12 unresolvable sessions over 12 passes. Checks per-pass attempts and DB opens, follow-up passes, passes owed by writes, and conversion once they become resolvable.
  • New, agentService end-to-end: 110 sessions the provider can't vouch for, over 12 passes. Checks per-pass migration operations, conversion attempts, session DB opens and dirty marks.
  • Updated: the retry-limit test now expects [2,1,1,1,1,1,1] instead of [2,2,2,2,2,1,1]. The batch no longer re-attempts a session that the same pass's prompt retry already covers. The limit and the fallback to the batch cadence still hold.
  • Mutations: each was applied, transpiled and run against both suite files, and each is killed. Removing the central precheck; the batch not skipping waiting sessions; counting unverified sessions as ready; re-scheduling for a session already waiting; scheduling inside a pass; and not counting skipped as re-projected (killed by the existing default-provenance conversion test).

Validation

  • npm run transpile-client: passed.
  • npm run test-node -- --run …/agentService.test.ts --run …/agentHostCatalogReconciliationService.test.ts --run …/agentHostChatCatalogMigration.test.ts: 1134 passing, 0 failing.
  • npm run test-node -- --runGlob "**/vs/platform/agentHost/test/node/**/*.test.js": 11610 passing, 14 failing. All 14 are CopilotAgent environment failures, and the same 14 fail on unmodified main.
  • npm run typecheck-client: passed.
  • 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.

…possible re-projection

Block 4a (#341904) made every legacy chat catalog convert, including older
provider-scheme sessions whose provider cannot vouch for them (registered
but with an unreadable catalog, or no longer knowing the session). Their
aggregate never becomes verified, so every conversion attempt ended
`notReady` and fed a loop:

- `_migrateChatCatalog` opened the session database (`runMigrationExclusive`)
  and ran legacy reconciliation before the readiness check, then marked the
  payload dirty, which superseded in-flight re-projections and woke parked
  sessions so the reconciliation re-opened them on the next pass.
- The conversion batch re-attempted every legacy session each cursor cycle,
  and `_convertReprojected` treated parked or unverified sessions as ready
  because `_listDirtySessions` omits parked rows, so the retry limit of five
  never bounded them. Each attempt also scheduled a follow-up pass.

Production (one Insiders profile, ~717 sessions, ~110 affected): ~920
migration operations in two ~5 minute windows, passes every 20-30 s.

Conversion now decides readiness from central state first: an unverified or
dirty aggregate returns `notReady` without opening session.db, writing or
waking anything (its re-projection is already owed). A waiting session is
skipped by the conversion batches and owes no follow-up pass; it converts
right after a pass re-projects it (`succeeded` or an already-current
`skipped`) or once its receipt is verified and clean. The check under the
session lock stays authoritative.

With 110 unvouchable sessions over twelve 30 s passes: 150 migration
operations, 350 session database opens and 100 dirty marks per pass before;
50/50/10 operations in the first three passes (re-projections parking each
session once, no conversion opens or writes) and nothing after.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 14:30
@sandy081 Sandeep Somavarapu (sandy081) added this to the 1.143.0 milestone 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.

🟢 Approval recommended

The focused changes have regression coverage for retry suppression and recovery, with no unresolved blocking findings.

0 open findings

What changed in this PR

Stops repeated Agent Host chat-catalog conversion attempts while sessions cannot be re-projected, addressing the Block 4a retry regression.

Changes:

  • Checks central readiness before opening session databases.
  • Suppresses redundant conversion retries and follow-up passes while preserving recovery.
  • Adds regression coverage and documents the retry behavior.

No actionable findings remain. Tests were not rerun; validation relies on the reported results.

File Description
src/​vs/​platform/​agentHost/​test/​node/​agentService.test.ts Covers conversion attempts, database opens, and dirty marks.
src/​vs/​platform/​agentHost/​test/​node/​agentHostCatalogReconciliationService.test.ts Covers retry suppression, scheduling, and recovery.
src/​vs/​platform/​agentHost/​node/​agentService.ts Adds shared central-state readiness checks.
src/​vs/​platform/​agentHost/​node/​agentHostChatCatalogV2.md Documents waiting and retry behavior.
src/​vs/​platform/​agentHost/​node/​agentHostChatCatalogMigration.ts Shares the awaiting-reprojection result.
src/​vs/​platform/​agentHost/​node/​agentHostCatalogReconciliationService.ts Gates retries on readiness and avoids redundant scheduling.

🧠 Review effort: Balanced


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

@github-actions

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 3fda34cf Current: 1f0c8044

Changed (1)

sessions/chatCompositeBar/MixedStatuses/Light
Before After
before after

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.

3 participants