feat : add headroom proxy for intercept request llm for good compression then save credits#320867
Draft
damnthonyy wants to merge 2 commits into
Draft
feat : add headroom proxy for intercept request llm for good compression then save credits#320867damnthonyy wants to merge 2 commits into
damnthonyy wants to merge 2 commits into
Conversation
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Origin
This PR was initiated from the following prompt:
What this PR resolves
Routes Copilot LLM requests through a local proxy (e.g. Headroom) for token compression, monitoring, and quota management — without modifying the core request logic.
What changed
New:
extensions/copilot/src/platform/networking/common/proxyUtils.tsisLLMEndpoint(url)— restricts interception to known Copilot LLM hostnames (api.githubcopilot.comand variants)getConfiguredProxyUrl()— reads theCOPILOT_PROXY_URLenv varmaybeInterceptUrlThroughProxy()— rewrites the request URL to route through the proxy and injectsX-Original-Url/X-Original-Hostheaders so the proxy knows where to forwardModified:
extensions/copilot/src/platform/endpoint/common/capiClient.tsProxyInterceptingFetcherService— wraps the internal fetcher to intercept CAPI requests (standard Copilot chat completions) whenCOPILOT_PROXY_URLis set and the resolved URL is an LLM endpointModified:
extensions/copilot/src/platform/networking/common/networking.tsgetConfiguredProxyUrl()andmaybeInterceptUrlThroughProxy()intonetworkRequest()for direct URL / BYOK requestsproxyUtils.tsCoverage summary
ProxyInterceptingFetcherServicenetworkRequest()isLLMEndpoint()How to test
Make a chat request in Copilot. The POST to
api.githubcopilot.com/chat/completionswill be intercepted and routed through the proxy.Evidence — real token compression with Headroom
Tested end-to-end with Headroom v0.24.0:
Enregistrement.de.l.ecran.2026-06-11.a.15.00.13.mov
Todo
ProxyInterceptingFetcherService)@parcel/watchernative module, mermaid types)