Salvatore
Salvatore

Reputation: 12064

GitHub Copilot: Sorry, the response matched public code so it was blocked. Please rephrase your prompt

When using Copilot in VSCode, I occasionally see the following error instead of a result from my prompt:

Sorry, the response matched public code so it was blocked. Please rephrase your prompt

Why does this happen, what does it mean, and is there a way to avoid it?

Upvotes: 10

Views: 6284

Answers (1)

Salvatore
Salvatore

Reputation: 12064

When your prompt generates an output, GitHub Copilot checks any code suggestions with their surrounding code of about 150 characters against public code on GitHub. If there is a match, or a near match, the suggestion is not shown to you.

Rephrasing the prompt should give you a different output that doesn't match public code.

You can also tell Copilot to show the output anyway:

  1. In the upper-right corner of any page on GitHub, click your profile photo, then click Settings.
  2. In the left sidebar, click Copilot.
  3. Under Suggestions matching public code, select the dropdown menu, then click Allow to allow suggestions matching public code, or Block to block suggestions matching public code.
  4. To confirm your new settings, click Save.

For more information, see enabling-or-disabling-suggestions-matching-public-code.

Note this is a commonly controlled organizational setting, so you may not be able to change it on a work account.

Upvotes: 6

Related Questions