Skip to content

agentHost: surface SDK inventory refusals and recover once on list - #342471

Merged
Vritant Bhardwaj (vritant24) merged 1 commit into
mainfrom
agents/fix-copilot-sdk-inventory-error-handling
Oct 19, 2026
Merged

Vritant Bhardwaj (vritant24) merged 1 commit into
mainfrom
agents/fix-copilot-sdk-inventory-error-handling

Conversation

@vritant24

Copy link
Copy Markdown
Member

Follow-up to #339896.

Problem

The workbench logged this, with no indication of why it failed:

[AgentHostCustomizationMarketplace] Unable to load session-bound SDK installation receipts The SDK could not list installed MCP servers.

The Copilot runtime's mcp.installations.list / skills.installations.list reports refusals as { kind: 'outcome', outcome: { kind: 'refused', reason: '<code>' } } or { kind: 'outcome', outcome: { kind: 'recovery-required' } }, without a top-level message. resultError only used result.message ?? fallback, so the reason was always lost. Also, list(session) never called installations.recover, so a recovery-required inventory could never resolve on its own.

Changes

In copilotCustomizationInstallations.ts:

  • Clearer errors: resultError now adds the outcome kind and reason after the existing message, using the localized pattern "{0} ({1})". Example: The SDK could not list installed MCP servers. (refused: lifecycle-unavailable). Reason codes are left as non-localized SDK identifiers. Other callers (plan, prepare, uninstall) only reach resultError when something has already failed, so the only change for them is the added detail.
  • Recovery in list(session): if skills or MCP inventory returns recovery-required, it calls installations.recover once for that kind only and uses the recovered inventory. If recovery returns recovery-required again, it throws (recovery-required) instead of retrying, so it can't loop.

For reviewers: the private listWithClient used by the uninstall flow still does not recover. That's deliberate, to keep this change scoped to list(session).

Testing

copilotCustomizationInstallations.test.ts gets a new inventory failures suite with three tests:

  • A refused MCP list puts the reason in the error message.
  • recovery-required calls recover once and returns the recovered installations.
  • A repeated recovery-required after recovery produces an error and no second retry.

Commands run:

  • ./scripts/test.sh --run src/vs/platform/agentHost/test/node/copilotCustomizationInstallations.test.ts: passed (15 passing)
  • npm run eslint -- <changed files>: passed
  • npm run typecheck-client: passed

Copilot SDK customization inventory refusals (`refused` with a reason
code, or `recovery-required`) carry no top-level message, so the
workbench only logged the generic "The SDK could not list installed MCP
servers." fallback and dropped the cause.

- Append the outcome kind and reason to SDK result errors, e.g.
  "The SDK could not list installed MCP servers. (refused:
  lifecycle-unavailable)". Reason codes stay non-localized identifiers.
- When skills or MCP inventory reports `recovery-required`, call the
  matching `installations.recover` once and use the recovered inventory.
  A repeated `recovery-required` surfaces as an error instead of looping.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 19, 2026 03:54

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 changes are narrowly scoped, recovery is bounded, and no blocking defects were identified.

No open issues 🎉

What changed in this PR

Improves diagnostics and recovery for SDK-owned customization inventory in Agent Host, following #339896.

Changes:

  • Includes SDK outcome kinds and refusal reasons in errors.
  • Attempts recovery once per affected inventory kind in list(session), leaving uninstall behavior unchanged.
  • Adds tests for refusals, successful recovery, and repeated recovery requirements.
File Description
src/​vs/​platform/​agentHost/​test/​node/​copilotCustomizationInstallations.test.ts Tests MCP inventory diagnostics and bounded recovery.
src/​vs/​platform/​agentHost/​node/​copilot/​customizations/​copilotCustomizationInstallations.ts Adds outcome details and one-time inventory recovery.

Review effort: Balanced

@vritant24
Vritant Bhardwaj (vritant24) merged commit 341e0fa into main Oct 19, 2026
50 checks passed
@vritant24
Vritant Bhardwaj (vritant24) deleted the agents/fix-copilot-sdk-inventory-error-handling branch October 19, 2026 04:23
@vs-code-engineering vs-code-engineering Bot added this to the 1.143.0 milestone Oct 19, 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.

3 participants