-
Notifications
You must be signed in to change notification settings - Fork 3.1k
fix(inference): narrow Hermes Provider host smoke skip #4474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
dbf6f0f
fix(inference): skip host smoke for Hermes OAuth provider
ericksoa 69a1d8a
fix(inference): keep Hermes API key smoke validation
ericksoa 8a54352
test(inference): cover Hermes smoke verifier gate
ericksoa e41c7b2
test(inference): extract smoke verifier harness
ericksoa 1f8165d
test(inference): add smoke harness hygiene
ericksoa 9a19be5
test(inference): split Hermes smoke verifier spec
ericksoa cae9cad
test(inference): use esm smoke verifier import
ericksoa 1a6e99e
Merge remote-tracking branch 'origin/main' into fix/hermes-provider-s…
ericksoa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { spawnSync } from "node:child_process"; | ||
| import path from "node:path"; | ||
|
|
||
| export type SmokeVerifierHarnessCall = [string, ...unknown[]]; | ||
|
|
||
| type VerifyOnboardSmokeInvocation = { | ||
| credentialEnv?: string; | ||
| endpointUrl?: string; | ||
| forceOpenAiLike?: boolean; | ||
| model?: string; | ||
| provider?: string; | ||
| }; | ||
|
|
||
| export function runVerifyOnboardSmokeHarness( | ||
| invocations: VerifyOnboardSmokeInvocation[], | ||
| ): SmokeVerifierHarnessCall[] { | ||
| const harness = String.raw` | ||
| const Module = require("node:module"); | ||
| const originalLoad = Module._load; | ||
| const calls = []; | ||
|
|
||
| process.env.VITEST = "false"; | ||
|
|
||
| Module._load = function patchedLoad(request, _parent, _isMain) { | ||
| if (request === "../credentials/store") { | ||
| return { | ||
| getCredential(name) { | ||
| calls.push(["getCredential", name]); | ||
| return "stored-" + name; | ||
| }, | ||
| normalizeCredentialValue(value) { | ||
| calls.push(["normalizeCredentialValue", value]); | ||
| return value; | ||
| }, | ||
| resolveProviderCredential(name) { | ||
| calls.push(["resolveProviderCredential", name]); | ||
| return "resolved-" + name; | ||
| }, | ||
| }; | ||
| } | ||
| if (request === "../hermes-provider-auth") { | ||
| return { | ||
| HERMES_PROVIDER_NAME: "hermes-provider", | ||
| HERMES_INFERENCE_CREDENTIAL_ENV: "OPENAI_API_KEY", | ||
| HERMES_NOUS_API_KEY_CREDENTIAL_ENV: "NOUS_API_KEY", | ||
| }; | ||
| } | ||
| if (request === "../adapters/http/probe") { | ||
| return { | ||
| getCurlTimingArgs() { | ||
| return []; | ||
| }, | ||
| runChatCompletionsStreamingProbe() { | ||
| throw new Error("unexpected streaming probe"); | ||
| }, | ||
| runCurlProbe(args) { | ||
| const authHeader = | ||
| args.find((arg) => String(arg).startsWith("Authorization: Bearer ")) || "no-auth"; | ||
| calls.push(["runCurlProbe", args[args.length - 1], authHeader]); | ||
| return { | ||
| ok: true, | ||
| httpStatus: 200, | ||
| curlStatus: 0, | ||
| message: "OK", | ||
| body: '{"choices":[{"message":{"content":"OK"}}]}', | ||
| }; | ||
| }, | ||
| runStreamingEventProbe() { | ||
| throw new Error("unexpected streaming event probe"); | ||
| }, | ||
| }; | ||
| } | ||
| return originalLoad.apply(this, arguments); | ||
| }; | ||
|
|
||
| const { verifyOnboardInferenceSmoke } = require(process.env.PROBES_MODULE); | ||
| const invocations = JSON.parse(process.env.SMOKE_INVOCATIONS || "[]"); | ||
| console.log = (...args) => calls.push(["log", args.join(" ")]); | ||
|
|
||
| for (const invocation of invocations) { | ||
| verifyOnboardInferenceSmoke({ | ||
| endpointUrl: "https://api.example.com/v1", | ||
| model: "nous/test-model", | ||
| provider: "hermes-provider", | ||
| ...invocation, | ||
| }); | ||
| } | ||
|
|
||
| process.stdout.write(JSON.stringify(calls)); | ||
| `; | ||
| const result = spawnSync(process.execPath, ["-e", harness], { | ||
| cwd: process.cwd(), | ||
| encoding: "utf8", | ||
| env: { | ||
| ...process.env, | ||
| PROBES_MODULE: path.join(process.cwd(), "dist/lib/inference/onboard-probes.js"), | ||
| SMOKE_INVOCATIONS: JSON.stringify(invocations), | ||
| VITEST: "false", | ||
| }, | ||
| }); | ||
|
|
||
| if (result.status !== 0) { | ||
| throw new Error(result.stderr || result.stdout || "smoke verifier harness failed"); | ||
| } | ||
| return JSON.parse(result.stdout) as SmokeVerifierHarnessCall[]; | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { describe, expect, it } from "vitest"; | ||
| import { shouldSmokeOpenAiLikeOnboardRoute } from "../dist/lib/inference/onboard-probes"; | ||
| import { runVerifyOnboardSmokeHarness } from "./helpers/onboard-smoke-verifier-harness"; | ||
|
|
||
| describe("Hermes onboard smoke verification", () => { | ||
| it("does not host-smoke Hermes Provider with the ambient OPENAI_API_KEY", () => { | ||
| expect(shouldSmokeOpenAiLikeOnboardRoute("hermes-provider", "OPENAI_API_KEY")).toBe(false); | ||
| expect(shouldSmokeOpenAiLikeOnboardRoute("hermes-provider", "NOUS_API_KEY")).toBe(true); | ||
| expect(shouldSmokeOpenAiLikeOnboardRoute("openai-api")).toBe(true); | ||
| }); | ||
|
|
||
| it("skips only the Hermes OAuth smoke path in the runtime verifier", () => { | ||
| const calls = runVerifyOnboardSmokeHarness([ | ||
| { credentialEnv: "OPENAI_API_KEY" }, | ||
| { credentialEnv: "NOUS_API_KEY" }, | ||
| { credentialEnv: "OPENAI_API_KEY", forceOpenAiLike: true }, | ||
| ]); | ||
| expect( | ||
| calls.filter((call) => | ||
| ["resolveProviderCredential", "getCredential", "runCurlProbe"].includes(call[0]), | ||
| ), | ||
| ).toEqual([ | ||
| ["resolveProviderCredential", "NOUS_API_KEY"], | ||
| [ | ||
| "runCurlProbe", | ||
| "https://api.example.com/v1/chat/completions", | ||
| "Authorization: Bearer resolved-NOUS_API_KEY", | ||
| ], | ||
| ["resolveProviderCredential", "OPENAI_API_KEY"], | ||
| [ | ||
| "runCurlProbe", | ||
| "https://api.example.com/v1/chat/completions", | ||
| "Authorization: Bearer resolved-OPENAI_API_KEY", | ||
| ], | ||
| ]); | ||
| }); | ||
| }); |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.