Skip to content

Fix skills duplication when Agent Skills Location overlaps with Plugin Locations#307693

Open
Copilot wants to merge 4 commits intomainfrom
copilot/fix-skills-duplication-issue
Open

Fix skills duplication when Agent Skills Location overlaps with Plugin Locations#307693
Copilot wants to merge 4 commits intomainfrom
copilot/fix-skills-duplication-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 3, 2026

Skills appeared multiple times in the slash command list when SKILLS_LOCATION_KEY was configured to a workspace-relative path that overlapped with a plugin location — the same SKILL.md URI would surface via both the file locator and _pluginPromptFilesByType. This affected both the findAgentSkills() path and, critically, the user-facing slash command list built via getPromptSlashCommands()computeSlashCommandDiscoveryInfo()listPromptFiles(PromptsType.skill).

Changes

  • promptsServiceImpl.tscomputeListPromptFiles: Add URI-based deduplication using a ResourceSet so that when the file locator and plugin registration both return the same URI, only the first occurrence is kept. This fixes the slash-command path (getPromptSlashCommands).

  • promptsServiceImpl.tscomputeSkillDiscoveryInfo: URI-based deduplication using a ResourceSet (instead of Set<string>) checked before parseNew(), so the same file path from any number of sources is only processed once. The existing name-based dedup (seenNames) is preserved for catching distinct files that resolve to the same skill name.

  • promptsService.test.ts: Test covering the overlap scenario uses a workspace-relative SKILLS_LOCATION_KEY path (absolute paths are rejected by isValidPromptFolderPath and would not be found by the file locator). Both findAgentSkills() and getPromptSlashCommands() are asserted to return exactly one result, covering both affected code paths.

When 'Agent Skills Location' overlaps with 'Plugin Locations', the same
skill URI can appear in both discoveredSkills and pluginSkills sources.
Add URI-based deduplication (seenUris Set) before processing each skill
to prevent the same file from being included multiple times.

Also add a test verifying that skills are not duplicated when the same
URI appears via both SKILLS_LOCATION_KEY and plugin sources.

Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/93df8c49-237a-434e-938e-5ba4e004cfd9

Co-authored-by: connor4312 <2230985+connor4312@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix skills duplication when Agent Skills Location overlaps with Plugin Locations Fix skills duplication when Agent Skills Location overlaps with Plugin Locations Apr 3, 2026
Copilot AI requested a review from connor4312 April 3, 2026 19:17
const uri = skill.uri;
const promptPath = skill;

const uriKey = uri.toString();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot use a ResourceSet. And don't bother logging.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 86c2a15 — switched to ResourceSet (already imported) and removed the log line.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to prevent the same SKILL.md from being surfaced multiple times when skill discovery sources overlap (notably when SKILLS_LOCATION_KEY points into a plugin’s skills area), which previously led to duplicate entries in user-facing lists.

Changes:

  • Add URI-based de-duplication to computeSkillDiscoveryInfo using a ResourceSet, so the same URI is only parsed once across sources.
  • Add a unit test for the overlap scenario to ensure a single skill result is returned.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts Adds URI-based de-duplication in skill discovery.
src/vs/workbench/contrib/chat/test/common/promptSyntax/service/promptsService.test.ts Adds a test intended to cover overlap de-duplication.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment on lines 1532 to 1536
private async computeSkillDiscoveryInfo(token: CancellationToken): Promise<IPromptFileDiscoveryResult[]> {
const files: IPromptFileDiscoveryResult[] = [];
const seenNames = new Set<string>();
const seenUris = new ResourceSet();
const nameToUri = new Map<string, URI>();
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

This URI de-duplication is added in computeSkillDiscoveryInfo, which is used by findAgentSkills()/cachedSkills. However, the slash command list is built via getPromptSlashCommands()computeSlashCommandDiscoveryInfo()listPromptFiles(PromptsType.skill), and that path still merges file-locator + plugin skills without URI de-duplication. If the user-facing duplication was in slash commands (per PR description), this change likely won’t address it; consider adding URI de-duplication in computeListPromptFiles (for PromptsType.skill) or in computeSlashCommandDiscoveryInfo, and update tests accordingly.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 88f9527. Added URI deduplication (ResourceSet) to computeListPromptFiles — the function that feeds both computeSlashCommandDiscoveryInfo and all other listPromptFiles callers. Also fixed the test: the previous version used an absolute path for SKILLS_LOCATION_KEY which is rejected by isValidPromptFolderPath, so the file locator never actually found the skill. The updated test uses a workspace-relative path, causing the file locator to discover the same URI the plugin registers — and both findAgentSkills and getPromptSlashCommands now assert exactly 1 result.

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.

Skills duplication when 'Agent Skills Location' overlaps with 'Plugin Locations'

3 participants