fix(tests): monkeypatch copilot token resolution to survive borrowed-credential pruning - #31975
fix(tests): monkeypatch copilot token resolution to survive borrowed-credential pruning#31975talwayh1 wants to merge 2 commits into
Conversation
…copilot_suppresses_all_variants CI: test_auth_remove_copilot_suppresses_all_variants fails with SystemExit: No credential NousResearch#1. Provider: copilot. because load_pool() prunes the gh_cli borrowed credential entry when resolve_copilot_token() returns empty in CI/test environment (pitfall NousResearch#13). Monkeypatch hermes_cli.copilot_auth.resolve_copilot_token and get_copilot_api_token so the gh_cli entry survives pruning.
|
The copilot token monkeypatch test fix in test_auth_commands.py duplicates merged #31946 (same fix). This PR also bundles an unrelated agent_init.py change (stale localhost base_url guard for direct providers) which is the same fix as open PR #30034. Consider splitting — the test fix is already merged, and the agent_init.py change should coordinate with #30034. |
|
The copilot test fix itself is correct — monkeypatching But the diff is broader than the One correctness check on the guard while it's here: it sets |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for identifying the borrowed-Copilot fixture interaction.
Problems
- The auth-test portion is already on
main:tests/hermes_cli/test_auth_commands.py:1832-1864hydrates the credential through the same Copilot resolver path. It merged in920b350e57544285002c813b35747ebcc6659f9a(#31946). - The added provider guard would clear every direct provider's loopback endpoint. That conflicts with the current resolver, which deliberately honors
model.base_urlwhen its configured provider matches (hermes_cli/runtime_provider.py:481-491). Existing switch persistence clears stale URLs only when the new provider has no endpoint (tui_gateway/server.py:2813-2823).
Suggested changes
- Drop the already-merged fixture change from salvage.
- Keep the routing change separate and target a verified stale-persistence path while preserving explicit local proxy endpoints.
Automated hermes-sweeper review.
| _base_host = urlparse(agent.base_url or "").hostname or "" | ||
| if ( | ||
| agent.provider in PROVIDER_REGISTRY | ||
| and agent.provider not in {"custom", "openrouter"} |
There was a problem hiding this comment.
This condition cannot distinguish a stale loopback URL from an intentional local proxy for a direct provider. Current runtime resolution intentionally honors a matching provider's configured model.base_url (hermes_cli/runtime_provider.py:481-491); please preserve that supported override and address the specific stale persistence path instead.
What
Fix
test_auth_remove_copilot_suppresses_all_variants—load_pool()prunes thegh_cliborrowed credential entry becauseresolve_copilot_token()returns empty string in CI/test environment.Root Cause
From PR #31416,
_prune_stale_seeded_entries()removes all borrowed credential entries (gh_cli,env:*for copilot, etc.) when the token resolver returns empty — which is always the case in test environments without real tokens. The test writes agh_clientry, butload_pool()immediately prunes it, soresolve_target("1")fails with "No credential #1".Fix
Monkeypatch
hermes_cli.copilot_auth.resolve_copilot_tokenandget_copilot_api_tokenbefore callingauth_remove_commandso the entry survives pruning (pitfall #13).CI
fix/direct-provider-stale-local-base-url(PR fix(agent): ignore stale local base_url for direct providers #30034)