Files
hermes-agent/hermes_cli
Brooklyn Nicholson 665a42bb08 fix(auth): serialize MiniMax OAuth refresh and keep it a credential-only write
teknium1's request-changes review of #133534, all four findings plus nits:

1. Concurrent refresh logged the user out (major): _minimax_fresh_state now
   holds _auth_store_lock across read -> refresh -> save and re-reads state
   inside the lock, so a second concurrent consumer (main agent + aux task)
   sees the first caller's new expiry instead of replaying the single-use
   refresh token into refresh_token_reused and quarantining the winner's
   fresh tokens. Lock timeout outlives the refresh POST (codex pattern).
2. Aux refresh overwrote active_provider (medium): _minimax_save_auth_state
   gains set_active; the refresh and quarantine paths persist with
   set_active=False (the _save_provider_state_to_source rule), only
   _minimax_oauth_login sets active.
3. Warning spam when logged out (medium, #21521's complaint): the arm's
   expected absent/not-logged-in/AuthError fall-throughs are debug-once
   (contract test_auxiliary_client_resolve_dedup.py); only a genuinely
   unexpected exception keeps exc_info, logged once.
4. Probe mode made a network call (minor): under _aux_probe_active() the arm
   reads get_provider_auth_state("minimax-oauth") raw and stubs when
   access_token + inference_base_url are present, skipping the refresh
   (mirrors credential_pool.py::_seed_minimax_singleton).

Nits: the arm body lives directly in auxiliary_client_registry.py (one new
module, agent/auxiliary_client_minimax.py deleted), the in-tree
try/except ImportError wrappers are gone (only the build_anthropic_client
SDK-absent boundary remains, matching _try_anthropic), and the misnamed
..._with_oauth_semantics test is now ..._third_party_wire.

Tests: concurrent loopback-portal refresh race (1 POST, 0 errors, tokens
intact), aux refresh preserves active_provider, login still sets it,
logged-out resolutions are debug-once without traceback, probe mode with an
expired token makes 0 HTTP calls.

Co-authored-by: Ubxty <ubxty@users.noreply.github.com>
2026-10-05 22:38:27 -05:00
..
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…