Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jongio/2077dd30c718ebf5ab2dbb3249d98fce to your computer and use it in GitHub Desktop.

Select an option

Save jongio/2077dd30c718ebf5ab2dbb3249d98fce to your computer and use it in GitHub Desktop.
Fix for model not supported error in GitHub Copilot

Manual Fix for GitHub Copilot Chat "Model Not Supported" Error

This guide shows how to manually apply the fix to remove the x-onbehalf-extension-id header from the GitHub Copilot Chat extension.

Manual Fix Steps

1. Locate the GitHub Copilot Chat Extension

Windows:

cd $env:USERPROFILE\.vscode\extensions
dir github.copilot-chat-*

macOS/Linux:

cd ~/.vscode/extensions
ls -la | grep github.copilot-chat

2. Navigate to the dist Folder

# Replace <version> with the actual version number found in step 1
cd github.copilot-chat-<version>\dist

3. Create a Backup (Important!)

Windows:

copy extension.js extension.js.backup-manual

macOS/Linux:

cp extension.js extension.js.backup-manual

4. Edit the File

Open extension.js in any text editor:

Using VS Code:

code extension.js

Or use any text editor:

  • Notepad (Windows)
  • TextEdit (macOS)
  • vim/nano (Linux)

5. Find and Remove the Header

The file is minified (all on one line), so use Find & Replace:

Search for:

,"x-onbehalf-extension-id":

You'll find something like:

S==="getExtraHeaders"?function(){return{...f.getExtraHeaders?.()??{},"x-onbehalf-extension-id":`${A}/${c}`}}:

Remove this part:

,"x-onbehalf-extension-id":`${A}/${c}`

So it becomes:

S==="getExtraHeaders"?function(){return{...f.getExtraHeaders?.()??{}}}:

6. Save the File

  • VS Code: Ctrl+S (Windows/Linux) or Cmd+S (macOS)
  • Other editors: Use File → Save

7. Reload VS Code

  1. Open Command Palette: Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (macOS)
  2. Type and select: Developer: Reload Window

8. Verify the Fix

After reload, search for x-onbehalf-extension-id in the file again - it should not be found.

Quick PowerShell Script (Windows)

For advanced users, here's a one-liner script to apply the fix automatically:

# Find the extension
$extPath = Get-ChildItem "$env:USERPROFILE\.vscode\extensions" -Filter "github.copilot-chat-*" | Select-Object -First 1
$jsFile = Join-Path $extPath.FullName "dist\extension.js"

# Create timestamped backup
Copy-Item $jsFile "$jsFile.backup-$(Get-Date -Format 'yyyy-MM-ddTHH-mm-ss')"

# Read, modify, and write
$content = Get-Content $jsFile -Raw
$content = $content -replace ',"x-onbehalf-extension-id":`\$\{[^}]+\}/\$\{[^}]+\}`', ''
Set-Content $jsFile $content -NoNewline

Write-Host "Fix applied! Please reload VS Code." -ForegroundColor Green

To run:

  1. Copy the script above
  2. Open PowerShell
  3. Paste and press Enter
  4. Reload VS Code when prompted

Quick Bash Script (macOS/Linux)

#!/bin/bash

# Find the extension
EXT_DIR=$(find ~/.vscode/extensions -maxdepth 1 -name "github.copilot-chat-*" | head -n 1)
JS_FILE="$EXT_DIR/dist/extension.js"

# Create timestamped backup
BACKUP_FILE="$JS_FILE.backup-$(date +%Y-%m-%dT%H-%M-%S)"
cp "$JS_FILE" "$BACKUP_FILE"

# Apply the fix
sed -i.tmp 's/,"x-onbehalf-extension-id":`\${[^}]*}\/\${[^}]*}`//g' "$JS_FILE"
rm "$JS_FILE.tmp"

echo "Fix applied! Backup saved to: $BACKUP_FILE"
echo "Please reload VS Code."

To run:

  1. Save the script to a file (e.g., fix-copilot.sh)
  2. Make it executable: chmod +x fix-copilot.sh
  3. Run it: ./fix-copilot.sh
  4. Reload VS Code

Restore from Backup

If something goes wrong or you want to undo the fix:

Windows:

copy extension.js.backup-manual extension.js

macOS/Linux:

cp extension.js.backup-manual extension.js

Then reload VS Code.

Troubleshooting

Can't Find the Extension

Make sure GitHub Copilot Chat is installed:

  1. Open VS Code Extensions (Ctrl+Shift+X)
  2. Search for "GitHub Copilot Chat"
  3. Install if not already installed

Permission Denied

Windows:

  • Run PowerShell as Administrator
  • Or close VS Code before editing

macOS/Linux:

  • Use sudo if necessary
  • Or close VS Code before editing

Pattern Not Found

The extension might:

  • Already be fixed
  • Use a different version/format
  • Be corrupted (try reinstalling)

Fix Gets Overwritten

After GitHub Copilot Chat updates, you'll need to reapply the fix.

Notes

⚠️ Important Warnings:

  • The extension.js file is minified (all on one line), so it's hard to read manually
  • Always create a backup before editing
  • You'll need to reapply this fix after GitHub Copilot Chat updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment