Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
666d8aa
fix(inference): reject encoded native NVIDIA hosts
rsliter Oct 9, 2026
4d506d0
docs(hermes): describe native NVIDIA credential reference
rsliter Oct 9, 2026
ccd2aa7
test(e2e): use local baseline for native Hermes switch
rsliter Oct 9, 2026
83776f2
test(e2e): protect native Hermes switch baseline
rsliter Oct 9, 2026
b80617d
test(e2e): verify Hermes native credential reference
rsliter Oct 9, 2026
5ea10df
fix(inference): reject native URLs with user information
rsliter Oct 9, 2026
152550f
fix(inference): reject trailing-dot native host aliases
rsliter Oct 9, 2026
d04bbf7
fix(inference): reject repeated trailing-dot native hosts
rsliter Oct 9, 2026
7f08e6c
fix: bind Hermes switch to attached credential handle
rsliter Oct 9, 2026
921053c
merge: sync main for Hermes inference repair
rsliter Oct 13, 2026
50a453f
fix(hermes): include native NVIDIA contract in image payload
rsliter Oct 13, 2026
b99b100
fix(hermes): admit native contract to portable build context
rsliter Oct 13, 2026
56cd813
fix(hermes): keep scoped handle logic out of Pi image inputs
rsliter Oct 13, 2026
2e3e85f
test(hermes): expect scoped credential after inference switch
rsliter Oct 13, 2026
acf2e70
docs(hermes): distinguish generated and switched credential references
rsliter Oct 13, 2026
f1d5db6
fix: accept scoped Hermes NVIDIA credential handles
rsliter Oct 13, 2026
2996b12
fix(inference): parse framed Hermes credential handles
rsliter Oct 13, 2026
1b3f704
Merge remote-tracking branch 'origin/main' into codex/12892-credentia…
rsliter Oct 13, 2026
696221c
fix: wait for Hermes native provider handle injection
rsliter Oct 13, 2026
4e88f84
docs: explain Hermes native switch gateway restart
rsliter Oct 13, 2026
2729417
docs: document Hermes gateway restart recovery
rsliter Oct 13, 2026
b4435e4
Merge remote-tracking branch 'origin/main' into codex/12892-credentia…
rsliter Oct 13, 2026
4aeead9
test: verify Hermes native attachment rollback
rsliter Oct 13, 2026
e92ddf1
test: expect native Hermes switch to clear endpoint metadata
rsliter Oct 13, 2026
11f107c
Merge remote-tracking branch 'origin/main' into codex/12892-credentia…
rsliter Oct 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions agents/hermes/managed_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@
import re
import stat
from pathlib import Path
from urllib.parse import urlsplit
from urllib.parse import unquote, urlsplit

MANAGED_POLICY_PATH = Path("/usr/local/share/nemoclaw/hermes-managed-policy.json")
MANAGED_POLICY_SCHEMA_VERSION = 3
HERMES_PROXY_REWRITE_SENTINEL = "sk-OPENSHELL-PROXY-REWRITE"
NVIDIA_INFERENCE_PLACEHOLDER = "${NVIDIA_INFERENCE_API_KEY}"
NVIDIA_SCOPED_CREDENTIAL_HANDLE = re.compile(
r"openshell:resolve:env:(?:v[0-9]{1,20}|s[a-f0-9]{64})_NVIDIA_INFERENCE_API_KEY"
)


class ManagedPolicyError(Exception):
Expand Down Expand Up @@ -162,10 +165,29 @@ def load_managed_policy(path: Path = MANAGED_POLICY_PATH) -> dict:
_ = url.port
except (TypeError, ValueError):
raise ManagedPolicyError("managed policy model.base_url is invalid") from None
if (
not native_nvidia
and url.scheme.lower() == "https"
and unquote(url.hostname or "").lower().rstrip(".")
== "integrate.api.nvidia.com"
and url.port in (None, 443)
):
raise ManagedPolicyError(
"Native NVIDIA inference requires https://integrate.api.nvidia.com/v1."
)
expected_key = NVIDIA_INFERENCE_PLACEHOLDER if native_nvidia else HERMES_PROXY_REWRITE_SENTINEL
api_key = policy_value(config, "model.api_key")
hosted_placeholder = None if native_nvidia else _native_hosted_placeholder(config, base_url)
if api_key != expected_key and (hosted_placeholder is None or api_key != hosted_placeholder):
scoped_nvidia_handle = (
native_nvidia
and isinstance(api_key, str)
and NVIDIA_SCOPED_CREDENTIAL_HANDLE.fullmatch(api_key) is not None
)
if (
api_key != expected_key
and (hosted_placeholder is None or api_key != hosted_placeholder)
and not scoped_nvidia_handle
):
raise ManagedPolicyError(
"managed policy model.api_key must use an OpenShell credential placeholder or proxy rewrite sentinel "
"matching its route"
Expand Down
12 changes: 10 additions & 2 deletions docs/inference/switch-providers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,16 @@ Run `$$nemoclaw <name> doctor --fix`, then retry the agent turn.

<AgentOnly variant="hermes">

For Hermes, NemoClaw updates the native `/sandbox/.hermes/config.yaml`, including the model, base URL, API-family mode, and OpenShell proxy API-key placeholder.
The gateway, CLI, TUI, and Web Dashboard all read that shared configuration; a normal runtime route change does not rebuild or restart Hermes.
For Hermes, NemoClaw updates the native `/sandbox/.hermes/config.yaml`, including the model, base URL, API-family mode, and managed API-key value.
`inference.local` uses the OpenShell proxy rewrite sentinel.
Generated NVIDIA Build configuration uses `${NVIDIA_INFERENCE_API_KEY}` for supervisor expansion.
A live switch to NVIDIA Build writes the newly attached provider's scoped OpenShell credential reference.
These values do not expose the raw provider credential.
The gateway, CLI, TUI, and Web Dashboard all read that shared configuration.
Changes between shared routes do not rebuild or restart Hermes.
A switch to or from a native hosted provider restarts the Hermes gateway after configuration sync, including a live NVIDIA Build switch.
Active agent requests can be interrupted during the restart.
If the restart fails, the route and configuration remain committed. Run `$$nemoclaw <name> gateway restart` to apply the switch.

</AgentOnly>

Expand Down
13 changes: 12 additions & 1 deletion docs/reference/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3619,7 +3619,18 @@ Switch the active inference provider or model for a NemoClaw-managed OpenClaw sa
</AgentOnly>
<AgentOnly variant="hermes">

Switch the active inference provider or model for a NemoClaw-managed Hermes sandbox. For NVIDIA Endpoints, OpenAI, Anthropic, Gemini, OpenRouter, and Hermes Provider, the command attaches or updates the selected sandbox's native provider. Custom endpoints and local providers retain their existing shared OpenShell route. It then patches the selected running agent config to match the selected inference path, recomputes the config hash, and updates the NemoClaw registry. It is also available in sandbox-first form as `$$nemoclaw <name> inference set --provider <provider> --model <model>`. For Hermes, the patch updates the shared native `/sandbox/.hermes/config.yaml` (`model.default`, `model.base_url`, `model.provider: custom`, API-family mode when needed, and the OpenShell proxy API-key placeholder) and does not rebuild or restart the gateway. The gateway, CLI, TUI, and Web Dashboard read that same configuration. Keeping the placeholder preserves dashboard and API authentication after provider switches. Under the `nemohermes` alias, the command uses the registered Hermes sandbox when exactly one exists; otherwise pass `--sandbox <name>` to target one explicitly.
Switch the active inference provider or model for a NemoClaw-managed Hermes sandbox.
For NVIDIA Endpoints, OpenAI, Anthropic, Gemini, OpenRouter, and Hermes Provider, the command attaches or updates the selected sandbox's native provider.
Custom endpoints and local providers retain their existing shared OpenShell route.
It then patches the shared native `/sandbox/.hermes/config.yaml`, recomputes the config hash, and updates the NemoClaw registry.
Changes between shared routes do not rebuild or restart Hermes.
A switch to or from a native hosted provider restarts the Hermes gateway after configuration sync, including a live NVIDIA Endpoints switch.
Active agent requests can be interrupted during the restart.
If the restart fails, the route and configuration remain committed. Run `$$nemoclaw <name> gateway restart` to apply the switch.

Shared routes use the OpenShell proxy API-key placeholder. On a live NVIDIA Endpoints switch, NemoClaw writes the newly attached provider's scoped OpenShell credential reference into the Hermes config. Other native hosted providers use their managed credential placeholders. None of these values is a raw provider credential. The gateway, CLI, TUI, and Web Dashboard read the same configuration.

The command is also available in sandbox-first form as `$$nemoclaw <name> inference set --provider <provider> --model <model>`. Under the `nemohermes` alias, it uses the registered Hermes sandbox when exactly one exists; otherwise pass `--sandbox <name>` to target one explicitly.

</AgentOnly>

Expand Down
5 changes: 4 additions & 1 deletion docs/security/credential-storage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ Those files should contain resolver placeholders, not live provider credentials.
For managed tools and messaging, NemoClaw keeps host-side auth in OpenShell providers or host brokers and writes placeholder values into `/sandbox/.hermes/config.yaml`, `/sandbox/.hermes/.env`, and process environment entries visible to the sandbox.
Hermes startup rejects raw secret-shaped values in those sandbox-visible surfaces.
The managed Hermes wrapper reads that token from `/sandbox/.hermes/.env` and supplies it only through the dashboard process environment.
The shared native inference configuration uses the OpenShell proxy rewrite sentinel instead of raw provider credentials.
For `inference.local`, Hermes stores the OpenShell proxy rewrite sentinel in its native inference configuration.
Generated NVIDIA Build configuration uses `${NVIDIA_INFERENCE_API_KEY}` for supervisor expansion.
A live switch to NVIDIA Build writes the newly attached provider's scoped OpenShell credential reference into the native configuration.
These values do not expose the raw provider credential.
</AgentOnly>
<AgentOnly variant="deepagents">
NemoClaw manages Deep Agents Code provider credentials through the same OpenShell provider boundary.
Expand Down
20 changes: 20 additions & 0 deletions scripts/nemoclaw-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,26 @@ clear_managed_inference_credentials() {
printf '%s\n' '[SECURITY] Native NVIDIA inference requires https://integrate.api.nvidia.com/v1.' >&2
return 1
fi
if ! is_managed_inference_route; then
# Parse noncanonical routes in a child without either provider credential.
local parsed_host_status=0
env -i PATH="$PATH" NEMOCLAW_INFERENCE_BASE_URL="${NEMOCLAW_INFERENCE_BASE_URL:-}" node -e '
try {
const url = new URL(process.env.NEMOCLAW_INFERENCE_BASE_URL);
if (url.protocol === "https:" &&
url.hostname.replace(/\.+$/, "") === "integrate.api.nvidia.com" &&
url.port === "") process.exit(42);
} catch {}
' || parsed_host_status=$?
if [ "$parsed_host_status" -eq 42 ]; then
unset NVIDIA_API_KEY NVIDIA_INFERENCE_API_KEY
printf '%s\n' '[SECURITY] Native NVIDIA inference requires https://integrate.api.nvidia.com/v1.' >&2
return 1
fi
if [ "$parsed_host_status" -ne 0 ]; then
return "$parsed_host_status"
fi
fi
if is_managed_inference_route; then
unset NVIDIA_API_KEY
if ! [[ "${NVIDIA_INFERENCE_API_KEY:-}" =~ ^openshell:resolve:env:(v[0-9]{1,20}|s[a-f0-9]{64})_NVIDIA_INFERENCE_API_KEY$ ]]; then
Expand Down
74 changes: 74 additions & 0 deletions src/lib/actions/inference-set-hermes-run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ vi.mock("../onboard/experimental/portable-agent-lifecycle", async (importOrigina
assertHermesPortableCommandUnavailable: portableMocks.assertUnavailable,
}));
import { HERMES_PROXY_REWRITE_SENTINEL } from "../hermes-managed-route";
import { NVIDIA_HOSTED_NATIVE_PROVIDER } from "../inference/native-nvidia/contract";
import type { ConfigObject } from "../security/credential-filter";
import { runInferenceSet } from "./inference-set";
import { baseSession, createDeps, HERMES_TARGET } from "../../../test/helpers/inference-set";
Expand All @@ -21,6 +22,79 @@ describe("runInferenceSet Hermes routing", () => {
portableMocks.assertUnavailable.mockReset();
});

it("reads the attached native handle before publishing a Hermes switch", async () => {
const config: ConfigObject = { model: { default: "local-model", provider: "custom" } };
const deps = createDeps({
config,
entry: { name: "hermes", agent: "hermes", provider: "vllm-local", model: "local-model" },
defaultSandbox: "hermes",
target: HERMES_TARGET,
session: baseSession({ agent: "hermes", sandboxName: "hermes" }),
});
await runInferenceSet(
{
provider: "nvidia-prod",
model: "nvidia/test-model",
sandboxName: "hermes",
noVerify: true,
},
deps,
);
expect(deps.calls.readNativeNvidiaCredentialHandle).toHaveBeenCalledWith("hermes", "nemoclaw");
expect(config.model).toMatchObject({
api_key: "openshell:resolve:env:v1_NVIDIA_INFERENCE_API_KEY",
});
expect(deps.calls.writeSandboxConfig).toHaveBeenCalledOnce();
});

it("leaves the Hermes config unchanged when the attached handle is unavailable", async () => {
const config: ConfigObject = { model: { default: "local-model", provider: "custom" } };
const deps = createDeps({
config,
entry: { name: "hermes", agent: "hermes", provider: "vllm-local", model: "local-model" },
defaultSandbox: "hermes",
target: HERMES_TARGET,
session: baseSession({ agent: "hermes", sandboxName: "hermes" }),
readNativeNvidiaCredentialHandle: async () => {
throw new Error("provider-bound handle unavailable");
},
});
const attachProvider = vi.spyOn(deps.providerAdapter, "attachProvider");
const detachProvider = vi.spyOn(deps.providerAdapter, "detachProvider");
await expect(
runInferenceSet(
{
provider: "nvidia-prod",
model: "nvidia/test-model",
sandboxName: "hermes",
noVerify: true,
},
deps,
),
).rejects.toThrow("provider-bound handle unavailable");
expect(config.model).toEqual({ default: "local-model", provider: "custom" });
expect(deps.calls.writeSandboxConfig).not.toHaveBeenCalled();
expect(deps.calls.updateSandbox).not.toHaveBeenCalled();
expect(attachProvider).toHaveBeenCalledWith(
expect.objectContaining({
sandboxName: "hermes",
providerName: NVIDIA_HOSTED_NATIVE_PROVIDER,
}),
);
expect(detachProvider).toHaveBeenCalledWith(
expect.objectContaining({
sandboxName: "hermes",
providerName: NVIDIA_HOSTED_NATIVE_PROVIDER,
}),
);
await expect(
deps.providerAdapter.listProviderAttachments({
target: { kind: "named", gatewayName: "nemoclaw" },
sandboxName: "hermes",
}),
).resolves.toEqual({ ok: true, value: { names: [] } });
});

it("rejects schema-5 before OpenShell or registry mutation (#9203)", async () => {
portableMocks.assertUnavailable.mockImplementation(() => {
throw new Error("schema-5 rejected");
Expand Down
56 changes: 56 additions & 0 deletions src/lib/actions/inference-set-patch-hermes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,62 @@ describe("patchHermesInferenceConfig", () => {
});
});

it("uses the attached provider handle on every Hermes native credential path", () => {
const config: ConfigObject = {};
const handle = "openshell:resolve:env:v12_NVIDIA_INFERENCE_API_KEY";
patchHermesInferenceConfig(
config,
"nvidia-prod",
"nvidia/test-model",
null,
undefined,
undefined,
true,
handle,
);
expect(config).toMatchObject({
model: { api_key: handle },
providers: { "nvidia-prod": { api_key: handle } },
custom_providers: [{ api_key: handle }],
});
expect(() =>
patchHermesInferenceConfig(
{},
"nvidia-prod",
"nvidia/test-model",
null,
undefined,
undefined,
true,
"nvapi-raw",
),
).toThrow(/provider-bound credential handle/u);
expect(() =>
patchHermesInferenceConfig(
{},
"nvidia-prod",
"nvidia/test-model",
null,
undefined,
undefined,
true,
"",
),
).toThrow(/provider-bound credential handle/u);
expect(() =>
patchHermesInferenceConfig(
{},
"vllm-local",
"local-model",
null,
undefined,
undefined,
true,
handle,
),
).toThrow(/provider-bound credential handle/u);
});

it("updates the complete Hermes route for the selected provider", () => {
const config: ConfigObject = {
model: {
Expand Down
Loading