Repository navigation
fix(github_copilot): honor caller credentials for messages - #11
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Approving. The change is right, and I've tested it live with a real per-user Copilot key.
Code: the order is right. The user session wins; otherwise a non-blank caller key is used, with the caller's base or the default host and never the stored login's endpoint. Without a caller key, behaviour is unchanged, and the caller's base is still ignored when the stored token is used. get_complete_url follows the same rule.
Unit tests: I ran the fork's whole tests/unit/llms/github_copilot suite on a v1.110.1 install, without and with this commit. All 7 new tests fail on the base and pass with the change, and 296 tests pass in total. 7 other failures and 1 error appear identically with and without the change. They come from my environment: the image sets GITHUB_COPILOT_NON_INTERACTIVE, and the local_beta_headers_config fixture wasn't available. Note that only the PR-title check ran on the fork, because its unit-test workflows don't trigger for PRs into *_with_jh_fixes.
Live check: I copied this commit's messages/transformation.py onto JuliaHub's litellmsrvr image (JuliaComputing/JuliaHub#25720, v1.110.1). The test user had a connected Copilot account, so the JuliaHub plugin got a per-user key from GitHub and set api_key/api_base on each request. The container had no stored login.
/v1/messages call |
Before (base) | With this PR |
|---|---|---|
claude-sonnet-5, plain |
401 "No GitHub Copilot access token" | ✓ 200, spend row under the user |
claude-sonnet-5, streaming |
401 | ✓ 200 SSE, spend row under the user |
claude-sonnet-5, tool use |
401 | ✓ 200 tool_use, spend row under the user |
| No user headers (no caller key) | 401 | 401 (unchanged, no key used) |
| User without a Copilot connection | 403 | 403 (unchanged, plugin refuses) |
/chat/completions on a Copilot model still works as a control. One model the test account isn't entitled to returned GitHub's own 400 ("not available for integrator"), which shows the request reached Copilot with the caller's key.
After merging, please use a merge commit, not squash or rebase, so this commit's SHA ends up on the branch. JuliaHub can then pin it in a follow-up after JuliaComputing/JuliaHub#25720 merges.
Fixes caller-key authentication for Copilot Messages.
Handwritten 1-3 sentence description
Copilot
/v1/messagesnow uses the caller's per-user key when there is no user session, the same way chat, embeddings and Responses already do after #9. Without a caller key the stored login path is unchanged. Live proof with a real per-user Copilot key is still outstandingDetails
TLDR
Problem this solves:
How it solves it:
User Flow
Before, a caller cannot use Messages without a stored login. The example hostname below represents the caller's proxy.
After, the same request uses the caller's key. The automated proof below mocks the provider response.
Pre-Submission checklist
Screenshots / Proof of Fix
Tested commit
4b4f9c46772ce7a40de76773291eee717cf8945awith mocked HTTP only. No live proxy or real provider calls were run. This authentication change does not qualify for the mechanical-change E2E exception. Live before/after proof remains outstanding before maintainer review.The regression check loaded the original transformation module from base commit
d8f3861655178f099e1629e4f528cf4987019ed4into a separate Python process, then ran the new caller-key and public-request tests. It did not modify the working tree.All new and existing Copilot unit tests were run at the tested commit with this command from the checkout.
LITELLM_LOCAL_MODEL_COST_MAP=true PYTHONPATH="$PWD" \ /home/ubuntu/work/venv-upgrade/bin/python -m pytest \ tests/unit/llms/github_copilot -qThe tests cover caller keys with explicit and default bases, no stored endpoint discovery for caller keys, blank-key fallback, missing credentials, and user-session precedence. Public request tests cover plain and streaming responses through
litellm.anthropic_messagesandlitellm.anthropic.messages.acreatewith bearer-header and URL assertions.Type
Bug Fix
Caveats (if any)
Medium
Low
litellm.aanthropic_messagesexport.Final Attestation