Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Copilot MentionsNew to Visual Studio Code? Get it now.
Copilot Mentions

Copilot Mentions

CaffeineCat

| (0) | Free
Restores #tool / @mention completions and selection/file pins in the chat input
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Copilot Mentions

Restores #tool / @mention completions in the chat input for Copilot harness (agent-host) sessions, plus selection/file context pins.

Why this is needed

In Local harness sessions, typing # or @ in the chat input pops tool completions (internal ToolCompletions provider) — picking #exa inserts the token, which the request parser resolves to a tool reference and sends to the runtime as toolReferences. In Copilot harness sessions that internal provider short-circuits (isAgentHostBackedWidget → return null) and no host-side tool completion provider exists, so #exa gets no completion.

The request pipeline itself works fine though: #name typed into the chat input is still parsed and shipped as toolReferences. This extension only re-adds the completion popup by registering a completion provider on the chat input model (scheme chatSessionInput).

Features

  • # / @ completions in the chat input, sourced from:
    • MCP server names in ~/.copilot/mcp-config.json, workspace .mcp.json and .vscode/mcp.json (server name = tool-set reference, e.g. #exa)
    • vscode.lm.tools (extension-registered LM tools)
  • #selection — attaches the active editor's selected code as a range-carrying file context (same shape Local's #selection produces, so the Copilot harness turns it into a selection attachment)
  • Copilot Mentions: Insert Mention (alt+m while chat input is focused) — quick pick to insert a mention at the cursor
  • Copilot Mentions: Copy All Mention Names — dumps all #name tokens to clipboard
  • Copilot Mentions: Pin Selection to Chat — pins the current editor selection as a ranged attachment (works from sidebar chat and chat editors, where the built-in attachSelection command reads an empty text editor and fails). This repo's config-set binds shift+cmd+a to it in keybindings/src/modules/chat.json
  • Copilot Mentions: Pin File to Chat — pins the current editor's whole file as an attachment (the extension stand-in for the built-in attachFile command, which silently no-ops while a chat surface is focused). This repo's config-set binds cmd+alt+a to it in keybindings/src/modules/chat.json

How selection mentions attach

There is no public API to register inline chat references. The completion command routes through workbench.action.chat.open with IChatViewOpenOptions.attachFiles: [{uri, range}] — the only extension-reachable path that creates a kind: 'file' context entry with a Location value. That entry is what both harnesses understand: Local shows it as context, and the Copilot harness serializes it as a selection attachment (<tagged_files> + range) in the AHP message.

Gotcha (worked around in attachReferenceCommand): the entry id is derived from uri.toString() + range?.toString(), and a JSON-marshalled range is a plain object whose toString() is "[object Object]" — so ranged attachments on the same file collide and addContext silently drops all but the first. The command encodes the range into the URI fragment (#L28C1-L49C2) to keep ids unique; file reads ignore the fragment, and the real range travels via value.range.

Why mentions are meaningful to the model

The Copilot harness drops #name tool references from the prompt (they become a silent per-turn tool enablement in the AHP runtime), so the model only sees the raw text. The static ~/.copilot/instructions/tool-mention.instructions.md (in config-set, symlinked) teaches the model the #name convention — server mentions, tool mentions, and reference-names-not-IDs — so it interprets the tokens correctly.

Build & Install

pnpm install
pnpm run package        # check-types + lint + esbuild (production)
vsce package --no-dependencies   # -> copilot-mentions-completions-0.0.1.vsix (deps are bundled by esbuild)

# install into stable + Insiders
"/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" \
  --install-extension copilot-mentions-completions-0.0.1.vsix
code-insiders --install-extension copilot-mentions-completions-0.0.1.vsix

Reload the window (Developer: Reload Window) afterwards.

Settings

Setting Description
copilot-mentions-completions.sources Per-source on/off switches (selection, mcpServers, tools, toolSets; default all on)
copilot-mentions-completions.mcpConfigPaths Extra MCP config files to scan

Mention names

The chat input parser resolves #name against toolReferenceName ?? displayName — not tool IDs (see chatRequestParser.ts, toolsByName.set(entry.toolReferenceName ?? entry.displayName, ...)):

Type Valid mention Invalid (tool ID)
MCP tool set (server) #exa —
MCP tool #web_fetch_exa #mcp_exa_web_fetch_exa
Built-in tool #applyPatch #copilot_applyPatch

The completion list offers the valid name and shows the tool ID in the detail text. A mention that matches nothing stays plain text (no pill) and is not attached to the request.

Notes

  • Symbol mentions are intentionally not provided: VS Code's native symbol completion now works in agent-host sessions too (upstream 2026-11-05) and attaches higher-fidelity chips (symbol name + kind icon), so this extension's former #sym: source was removed in its favor.
  • In Local sessions the internal provider also fires, so entries may show up twice; both insert identical text. Our entries are pinned to the top of the suggestion list (sortText starts with \u0000).
  • Whether #name actually attaches a tool depends on the name being present in the session's selected-tools model (same rule as Local). The insertion is plain text — if a name doesn't resolve, the model still sees it as a hint.
  • Mention tokens cannot contain whitespace.
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft