fix(xai): scope xAI HTTP credential resolution to the active profile - #39069
Closed
jonpol01 wants to merge 1 commit into
Closed
fix(xai): scope xAI HTTP credential resolution to the active profile#39069jonpol01 wants to merge 1 commit into
jonpol01 wants to merge 1 commit into
Conversation
xAI credential probes -- the gates behind x_search, video_gen, and the xAI web-search provider -- resolved the auth store from get_hermes_home()/auth.json (the root HERMES_HOME). When a named profile is active but HERMES_HOME resolves to the root (the Docker multi-profile layout, the multi-profile dashboard process, or a lazy tool-gate re-check after the per-invocation profile env mutation is no longer in effect), the named profile's xAI credential under <root>/profiles/<name>/auth.json was missed. check_x_search_requirements() and check_video_generation_requirements() then returned False and the tools were filtered out at boot -- even though the chat model worked, because it caches its bearer at startup while still profile-scoped. Wrap resolve_xai_http_credentials() and has_xai_credentials() in a profile-home scope: when HERMES_HOME resolves to the root, recover the active profile from the sticky active_profile file and scope get_hermes_home() to it via the existing set_hermes_home_override ContextVar, so the auth layer's existing profile->global fallback resolves the right store. Also make the cheap has_xai_credentials() probe honor credential_pool["xai-oauth"] entries, not just the providers.xai-oauth.tokens singleton (parity with the heavy resolver). No-op for the standard single-home layout and the default profile. Adds tests/tools/test_xai_http.py covering the root-HERMES_HOME + active-profile cases (pool and singleton), the negative case, the classic single-home layout, and that the resolver applies the scope. Refs NousResearch#18594.
Collaborator
|
Thanks for this, @jonpol01 — same symptom, addressed at a shared chokepoint instead. This scopes Closing as superseded by #46614. Your write-up of the root-vs-profile |
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.
Problem
xAI credential probes — the boot-time gates behind
x_search,video_gen, and the xAI web-search provider — resolve the auth store fromget_hermes_home() / "auth.json", i.e. the rootHERMES_HOME.When a named profile is active but
HERMES_HOMEresolves to the root, the named profile's xAI credential at<root>/profiles/<name>/auth.jsonis missed. This happens in:HERMES_HOME=/opt/data, profiles under/opt/data/profiles/<name>, gateways launched with-p <name>),registry._check_fn_cached, ~30s TTL) that re-resolve after the per-invocation profile env mutation is no longer in effect.check_x_search_requirements()/check_video_generation_requirements()then returnFalse, so x_search and video_generate are filtered out at boot — even though the chat model works, because it caches its bearer once at startup while still profile-scoped.Fix
tools/xai_http.py:_active_profile_home_scope(): whenHERMES_HOMEresolves to the root and a non-defaultprofile is active (read from the stickyactive_profilefile), temporarily scopeget_hermes_home()to the profile dir via the existingset_hermes_home_overrideContextVar. The auth layer's existing profile→global fallback then resolves the right store. No-op when already profile-scoped, on thedefaultprofile, or on any error.resolve_xai_http_credentials()and the cheaphas_xai_credentials()probe in that scope.has_xai_credentials()also honorcredential_pool["xai-oauth"]entries (e.g.hermes auth add, sourcemanual), not just theproviders.xai-oauth.tokenssingleton — parity with the heavy resolver.No behavior change for the standard single-home layout or the
defaultprofile.Tests
Adds
tests/tools/test_xai_http.py(6 tests): root-HERMES_HOME+ active-profile credential resolution (credential_pooland singleton), the negative case (no credential anywhere), the classic single-home layout, theXAI_API_KEYshort-circuit, and that the public resolver applies the scope before delegating.All pass; existing
test_x_search_tool,test_web_providers_xai, andtest_auth_profile_fallbacksuites are unaffected.Refs #18594.