Repository navigation
fix(copilot): keep the selected pool token through mid-turn refresh - #91
Closed
salch-cred wants to merge 1 commit into
Closed
salch-cred wants to merge 1 commit into
salch-cred wants to merge 1 commit into
Conversation
prepare_pool_entry exchanges the chosen pool row's raw GitHub token, but the 401/400/expiry refresh helpers resolved only from environment vars. A multi-account turn could silently switch to an env account after 30 minutes; a pool-only login (hermes auth add copilot) could not refresh at all. Pin the selected raw token when the pool entry is prepared and have the refresh and base-URL seams use it first, falling back to env. Fixes NousResearch#87
Contributor
|
Thanks @salch-cred — the diagnosis in #87 is right, but a process-wide pin means the last account selected wins for every session in a multi-profile gateway, and the suite is red on this head (3 failures). The row-scoped version is #77 (waits on core hermes-agent#154360); we'll land that instead. |
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.
What
With multiple Copilot accounts in
credential_pool, turn start correctly exchanges the selected row's rawghu_token. But the mid-turn recovery seams —_refresh_exchanged_token(),_reexchange_stale_token(),_revalidate_in_memory_token(), andruntime_base_url()— calledresolve_copilot_token(), which reads onlyCOPILOT_GITHUB_TOKEN/GH_TOKEN/GITHUB_TOKEN.Two consequences (#87):
.envtoken silently switches to that account when the exchanged ~30-minute token expires.hermes auth add copilot, no env token) cannot refresh at all — resolution returns("", "").Fix
prepare_pool_entry()now pins the selected row's raw token in a module slot. A newresolve_copilot_runtime_token()prefers that pin and falls back to the env resolution. All four runtime seams use it, so refresh and base-URL reconstruction stay on the account the turn started with; existing env-only setups are unchanged when no pool entry was prepared.Verification
tests/test_copilot_pool_refresh.py(4 tests): pin preference, env fallback, pinning onprepare_pool_entry, and a 401 refresh that evicts/re-exchanges the pinned token rather than the env one — 4 passed.Fixes #87