Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

OpenClaw GitHub Copilot Business/Enterprise 421 Fix

Problem: GitHub Copilot Business and Enterprise accounts get HTTP 421 (Misdirected Request) errors when using OpenClaw. This repository explains the root cause and provides a workaround.

The Issue

OpenClaw uses the api.individual.githubcopilot.com endpoint by default. However, GitHub Copilot token exchange provides account-tier-specific endpoints via the token's proxy-ep field:

Account Type Token proxy-ep Correct Endpoint Current Behavior
Individual proxy.individual.githubcopilot.com api.individual.githubcopilot.com ✅ Works
Business proxy.business.githubcopilot.com api.business.githubcopilot.com ❌ 421 error
Enterprise proxy.enterprise.githubcopilot.com api.enterprise.githubcopilot.com ❌ 421 error

Root Cause: The token-derived baseUrl is never applied at runtime. All requests fall through to the hardcoded api.individual endpoint, which rejects Business/Enterprise tokens with HTTP 421.

Workaround

Add this to ~/.openclaw/openclaw.json:

{
  "models": {
    "providers": {
      "github-copilot": {
        "baseUrl": "https://api.business.githubcopilot.com",
        "models": []
      }
    }
  }
}

Replace business with enterprise if you have an Enterprise account.

Restart OpenClaw:

openclaw gateway restart

Making the Workaround Persistent

The config workaround survives updates as long as you don't clear the config file. To automate it, use the provided ensure-copilot-baseurl.py script.

Option 1: Manual setup

# Copy the script
mkdir -p ~/.local/lib
cp ensure-copilot-baseurl.py ~/.local/lib/

# Make it executable
chmod +x ~/.local/lib/ensure-copilot-baseurl.py

# Test it
python3 ~/.local/lib/ensure-copilot-baseurl.py

Option 2: Systemd integration (automatic)

Add this to your systemd service file (~/.config/systemd/user/openclaw-gateway.service):

[Service]
ExecStartPre=/usr/bin/python3 /home/YOUR_USERNAME/.local/lib/ensure-copilot-baseurl.py
ExecStart=/path/to/node /path/to/openclaw/dist/index.js gateway

Then reload and restart:

systemctl --user daemon-reload
systemctl --user restart openclaw-gateway

The script will silently run before every gateway start and ensure the baseUrl is set correctly. Exit code is always 0 — it will never block startup.

Permanent Fix

A code fix is in progress that automatically applies the token-derived baseUrl at runtime:

  • PR #29614: Primary fix in OpenClaw source
  • PR #44136: Follow-up addressing reviewer concerns (user-config priority)

Once merged, you won't need the workaround anymore.

Testing Your Fix

Run the provided test-fix.sh script to verify the fix is applied:

bash test-fix.sh

This checks:

  • ✅ openclaw.json exists and is valid JSON
  • ✅ models.providers.github-copilot.baseUrl is configured
  • ✅ The baseUrl matches your account tier
  • ✅ OpenClaw gateway can start

Related Issues

  • Issue #41379: OpenClaw 2026.3.8, Copilot Business → 421
  • Issue #8366: OpenClaw gpt-5.2-codex → 421
  • Issue #17508: Copilot-proxy usage broken
  • PR #29614: Code fix (in review)
  • PR #44136: Follow-up with priority logic

Tested On

  • OpenClaw 2026.3.8
  • GitHub Copilot Business account
  • Ubuntu Linux with systemd user service
  • Models: GPT-5.1-Codex, GPT-5.2-Codex, GPT-5.3-Codex, Claude models

Environment

  • OpenClaw: 2026.3.8+
  • Node.js: 18+ (via linuxbrew or system)
  • Python: 3.8+
  • Git: Any recent version

Support

If you're still seeing 421 errors after applying the workaround:

  1. Verify ~/.openclaw/openclaw.json has the correct baseUrl
  2. Restart the gateway: openclaw gateway restart
  3. Check logs: journalctl --user -u openclaw-gateway -f
  4. Comment on the related GitHub issues with your OpenClaw version and account tier

License

This guide and scripts are provided as-is for troubleshooting purposes.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages