refactor(auth): Disable Nous Portal legacy session key inference fallback — JWT-only - #34508
Merged
kshitijk4poor merged 5 commits intoMay 29, 2026
Merged
Conversation
The import-failure fallback returned any 3-segment token without scope/ expiry validation, a divergent reimplementation of the canonical _nous_invoke_jwt_is_usable check. The import is from the same module that provides resolve_nous_runtime_credentials, so a failure means the whole auxiliary Nous path is unavailable anyway; return "" instead so the caller falls through to the clear 'run: hermes auth add nous' guidance rather than handing back an unvalidated token.
… params After the legacy session-key path was removed, two parameters became dead surface on the Nous runtime-resolution chain: - min_key_ttl_seconds: del'd inside refresh_nous_oauth_pure and pass-through / telemetry-only in refresh_nous_oauth_from_state, _try_import_shared_nous_state, _nous_device_code_login, and resolve_nous_runtime_credentials. It controlled the now-deleted agent-key mint TTL and drives no behavior. - inference_auth_mode: with the legacy mode gone, AUTO and FRESH are behaviorally identical; the value only fed _normalize_nous_inference_auth_mode validation and oauth trace output, never a branch. Removing inference_auth_mode orphaned its whole supporting cluster (NOUS_INFERENCE_AUTH_MODE_AUTO/FRESH, NOUS_INFERENCE_AUTH_MODES, _normalize_nous_inference_auth_mode), and dropping min_key_ttl_seconds orphaned DEFAULT_AGENT_KEY_MIN_TTL_SECONDS — all deleted here. Updated every caller (run_agent, auxiliary_client, credential_pool, proxy adapter, runtime_provider, web_server, main, auth_commands, setup) and pruned the matching test kwargs. Deleted two tests that exercised the removed surface (test_legacy_auth_mode_is_rejected, test_try_refresh_..._accepts_explicit_auth_mode). No behavior change: net -134 LOC of dead code.
18 tasks
1 task
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 this PR does
Salvage of #33759 by @rewbs onto current
main, plus two follow-up cleanup commits.Removes the Nous Portal legacy opaque session-key inference fallback. Nous inference now accepts only
inference:invokeJWTs:agent_keycompatibility field, so older local config layouts (opaqueagent_key+ valid refresh token) migrate cleanly.relogin_requirederror (run: hermes auth add nous) rather than silently minting a legacy key.Deleted machinery:
_mint_agent_key,_choose_nous_inference_auth_path,NOUS_INFERENCE_AUTH_MODE_LEGACY, legacy scope constants, device-code scope fallback,HERMES_AGENT_USE_LEGACY_SESSION_KEYShandling, and the proxy retry-with-legacy-session-key path.Commits / attribution
refactor(auth): Disable Nous legacy session key fallback— @rewbsfix(auth): address Nous JWT fallback review— @rewbstest(auth): update nous jwt-only expectations— @rewbsrefactor(auth): drop weak JWT-shape fallback in auxiliary _nous_api_key— follow-up (this salvage)refactor(auth): remove vestigial Nous min_key_ttl/inference_auth_mode params— follow-up (this salvage)Follow-up 1 —
_nous_api_keyfallbackRemoved the import-failure fallback in
agent/auxiliary_client._nous_api_keythat returned any 3-segment token without scope/expiry validation — a divergent reimplementation of the canonical_nous_invoke_jwt_is_usable. Since that import comes from the same module that providesresolve_nous_runtime_credentials, an import failure means the whole auxiliary Nous path is unavailable anyway; it now returns""so the caller falls through to the clear re-auth guidance.Follow-up 2 — dead-code removal
After the legacy path was removed, two parameters became dead surface on the Nous runtime-resolution chain:
min_key_ttl_seconds—del'd insiderefresh_nous_oauth_pure, pass-through / telemetry-only everywhere else. It controlled the now-deleted agent-key mint TTL.inference_auth_mode— with the legacy mode gone,AUTOandFRESHare behaviorally identical; it only fed validation + trace output, never a branch.Removing them orphaned the supporting cluster (
NOUS_INFERENCE_AUTH_MODE_AUTO/FRESH,NOUS_INFERENCE_AUTH_MODES,_normalize_nous_inference_auth_mode,DEFAULT_AGENT_KEY_MIN_TTL_SECONDS) — all deleted. Every caller updated; two tests exercising the removed surface deleted. No behavior change; net −134 LOC of dead code. Confirmed zero remaining references to all removed symbols across the codebase.Test plan
1032 passed, 0 failed. ruff clean on changed files;
git diff --checkclean.Closes #33759