#8467: fix(github-copilot): add configurable IDE headers + fix null filtering
agents
stale
Cluster:
GitHub Copilot Enhancements
## Summary
Enhanced fix for HTTP 421 Misdirected Request errors on GitHub Copilot Enterprise accounts. This PR addresses feedback from @greptile-apps on #8457.
## Changes from #8457
This PR includes all changes from #8457 plus:
### 1. Configurable IDE Headers (addresses P3 feedback)
The Copilot IDE headers are now configurable via `models.providers["github-copilot"].headers`:
```json
{
"models": {
"providers": {
"github-copilot": {
"headers": {
"Editor-Version": "vscode/1.120.0",
"X-Custom-Header": "custom-value"
}
}
}
}
}
```
- Default headers are still applied automatically (no config needed for most users)
- Users can override specific headers or add custom ones
- Useful if GitHub changes validation rules in the future
### 2. Fix extraParamsOverride null filtering (addresses P1 feedback)
The `extraParamsOverride` filtering now removes both `undefined` AND `null` values:
```typescript
// Before: only filtered undefined
.filter(([, value]) => value !== undefined)
// After: filters both null and undefined
.filter(([, value]) => value !== undefined && value !== null)
```
This prevents callers from accidentally overriding config params with `null` values from JSON/CLI/config merges.
## Testing
- [x] All existing tests pass
- [x] New test: config headers override default Copilot headers
- [x] New test: null values filtered from extraParamsOverride
## References
- Fixes #1797
- Addresses review feedback from #8457
- Thanks @at10ti0n for the original issue report
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR extends the embedded runner’s provider-specific request customization:
- Adds a GitHub Copilot stream wrapper that injects required IDE headers to address HTTP 421 errors on some Enterprise accounts, with optional overrides via `models.providers["github-copilot"].headers`.
- Updates `extraParamsOverride` merging to filter out both `undefined` and `null` so JSON/CLI merges don’t accidentally clobber configured params.
- Adds Vitest coverage for Copilot header injection/override behavior and for null/undefined filtering.
The changes are isolated to `src/agents/pi-embedded-runner/extra-params.ts` and integrate via the existing `applyExtraParamsToAgent` hook used by the embedded runner attempt flow.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- Logic changes are small and well-scoped, header merge order is intentional (caller headers win), and added tests cover the new behaviors including config overrides and null/undefined filtering.
- No files require special attention.
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#13505: feat(copilot): add GitHub Enterprise Cloud (GHE.com) support for Co...
by kryptus47 · 2026-02-10
82.5%
#4364: fix(github-copilot): use gho_ tokens directly without exchange
by RebelSyntax · 2026-01-30
80.4%
#11782: fix: resolve 403 auth error for GithubCopilot imageModel (#10277)
by adamkoncz · 2026-02-08
79.6%
#8805: [Bug Fix][AI-assisted] Refresh Copilot token before expiry and retr...
by Arthur742Ramos · 2026-02-04
78.0%
#19311: feat: add github-copilot gpt-5.3-codex with xhigh support (AI-assis...
by mrutunjay-kinagi · 2026-02-17
76.3%
#15044: fix: refresh GitHub Copilot default model list
by Godzilla675 · 2026-02-12
75.9%
#15999: fix: handle null/undefined in activity feed filters
by pamnlambert · 2026-02-14
75.7%
#19451: fix(errors): surface provider hint for role-ordering failures
by rafaelipuente · 2026-02-17
75.6%
#14368: fix: skip auth profile cooldown on format errors to prevent provide...
by koatora20 · 2026-02-12
75.3%
#15852: fix: pass agentId when resolving IRC session paths
by MisterGuy420 · 2026-02-14
74.9%