fix(providers): route Copilot enterprise tokens via proxy endpoint#358
Open
lijunle wants to merge 2 commits intomoltis-org:mainfrom
Open
fix(providers): route Copilot enterprise tokens via proxy endpoint#358lijunle wants to merge 2 commits intomoltis-org:mainfrom
lijunle wants to merge 2 commits intomoltis-org:mainfrom
Conversation
…oltis-org#352) The Copilot token exchange response includes an `endpoints.api` field that specifies the correct API base URL. Enterprise tokens point at the enterprise proxy (e.g. proxy.enterprise.githubcopilot.com) rather than the individual endpoint (api.individual.githubcopilot.com). Changes: - Parse `endpoints.api` from CopilotTokenResponse - Persist the resolved API base URL alongside the cached Copilot token - Use the dynamic endpoint for models, complete, and streaming requests - Detect enterprise proxy in complete() and delegate to streaming, since the enterprise proxy rejects non-streaming requests (HTTP 400) - Add collect_stream_response() helper to assemble streamed events into a CompletionResponse for the non-streaming code path - Add tests for endpoint parsing, stream collection, and error propagation Closes moltis-org#352 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
944e791 to
c72ff95
Compare
Contributor
Author
|
Hi @penso Could you check on this fix? I confirmed this working with my github account. |
This was referenced Mar 11, 2026
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.
Summary
Route GitHub Copilot enterprise tokens through the proxy endpoint returned in the token exchange response, fixing HTTP 421 errors for enterprise accounts.
endpoints.apifrom the Copilot token exchange response and persist it alongside the cached API tokencomplete()on enterprise proxy (non-streaming returns 400), reusing the existingstream_with_tools()path and collecting the SSE stream into aCompletionResponseapi.individual.githubcopilot.comunchangedCloses #352
Validation
Completed
cargo +nightly-2025-11-30 fmt --all -- --checkcargo check -p moltis-providers -p moltis-gatewaycargo test -p moltis-providers --features provider-github-copilot -- copilotRemaining
./scripts/local-validate.shManual QA
GET {proxy-ep}/modelsreturns 200)complete()path works (tool-calling flows use this)