This guide shows how to manually apply the fix to remove the x-onbehalf-extension-id header from 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# Replace <version> with the actual version number found in step 1
cd github.copilot-chat-<version>\distWindows:
copy extension.js extension.js.backup-manualmacOS/Linux:
cp extension.js extension.js.backup-manualOpen extension.js in any text editor:
Using VS Code:
code extension.jsOr use any text editor:
- Notepad (Windows)
- TextEdit (macOS)
- vim/nano (Linux)
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?.()??{}}}:- VS Code: Ctrl+S (Windows/Linux) or Cmd+S (macOS)
- Other editors: Use File → Save
- Open Command Palette:
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(macOS) - Type and select:
Developer: Reload Window
After reload, search for x-onbehalf-extension-id in the file again - it should not be found.
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 GreenTo run:
- Copy the script above
- Open PowerShell
- Paste and press Enter
- Reload VS Code when prompted
#!/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:
- Save the script to a file (e.g.,
fix-copilot.sh) - Make it executable:
chmod +x fix-copilot.sh - Run it:
./fix-copilot.sh - Reload VS Code
If something goes wrong or you want to undo the fix:
Windows:
copy extension.js.backup-manual extension.jsmacOS/Linux:
cp extension.js.backup-manual extension.jsThen reload VS Code.
Make sure GitHub Copilot Chat is installed:
- Open VS Code Extensions (Ctrl+Shift+X)
- Search for "GitHub Copilot Chat"
- Install if not already installed
Windows:
- Run PowerShell as Administrator
- Or close VS Code before editing
macOS/Linux:
- Use
sudoif necessary - Or close VS Code before editing
The extension might:
- Already be fixed
- Use a different version/format
- Be corrupted (try reinstalling)
After GitHub Copilot Chat updates, you'll need to reapply the fix.
- The
extension.jsfile 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