fix(copilot): keep rotated credentials on account endpoint - #61757
fix(copilot): keep rotated credentials on account endpoint#61757nullptr0807 wants to merge 1 commit into
Conversation
cc83e5d to
4b118f8
Compare
Related to #61746 (the issue) and the complementary core fix #61754 (open). #61754 refreshes the Copilot token + |
|
Thanks — the reported rotation defect is present on current Current The gateway addition also matches the current behavior: Automated hermes-sweeper review. |
What does this PR do?
Fixes Copilot credential rotation for Enterprise/proxied accounts by keeping the runtime API token and account-specific endpoint together.
When a pool entry contains a raw GitHub token,
_swap_credential()exchanges it and applies the returned short-lived Copilot token plusbase_urlas one runtime pair. When the pool already contains an exchanged semicolon metadata token, Hermes avoids an invalid re-exchange and derives the Enterprise endpoint fromproxy-epinstead. Exchange failures remain fail-soft and preserve the selected pool values.The PR also categorizes GitHub's exact endpoint-forbidden HTTP 403 envelope as an authentication/endpoint-access failure on chat gateways rather than the misleading generic “failed after retries” message.
This builds on the core fix in #61754, while covering the already-exchanged token path and the gateway diagnostic reported in the issue.
Related Issue
Fixes #61746
Type of Change
Changes Made
run_agent.pygateway/run.pytests/agent/test_restore_primary_pool_reselect.pytests/gateway/test_telegram_noise_filter.pyHow to Test
Run focused Copilot, credential-pool, Responses transport, and gateway tests:
python -m pytest \ tests/run_agent/test_run_agent_codex_responses.py \ tests/agent/test_restore_primary_pool_reselect.py \ tests/agent/test_credential_pool_routing.py \ tests/gateway/test_telegram_noise_filter.py \ tests/hermes_cli/test_copilot_token_exchange.py \ -o 'addopts=' -qExpected:
335 passed.Run lint and whitespace checks:
With a Copilot Enterprise credential whose token advertises
proxy-ep=proxy.enterprise.githubcopilot.com, rotate from a stale pool entry whose stored URL ishttps://api.githubcopilot.com. The rebuilt client should usehttps://api.enterprise.githubcopilot.com.Checklist
Code
pytest tests/ -qsuite — the hermetic full-suite runner reached 16.1% with no failures before the local 10-minute command timeout; focused affected tests passDocumentation & Housekeeping
cli-config.yaml.exampleupdate — N/ACONTRIBUTING.md/AGENTS.mdupdate — N/ATest Results