Skip to content

Commit 059bab9

Browse files
committed
fix: align auth profile provider key with openclaw.json model config
write_auth_profile() in nemoclaw-start.sh hardcoded provider: 'nvidia', but openclaw.json (generated at image build time) uses provider key 'inference' for NVIDIA providers via getSandboxInferenceConfig(). OpenClaw couldn't match credentials to the model config and fell back to Anthropic defaults. - nemoclaw-start.sh: read provider key from openclaw.json instead of hardcoding 'nvidia' - write-auth-profile.ts: same fix for the TypeScript variant - Dockerfile: align default NEMOCLAW_PROVIDER_KEY and NEMOCLAW_PRIMARY_MODEL_REF with getSandboxInferenceConfig() output Fixes #1332
1 parent aae3ccd commit 059bab9

File tree

3 files changed

+57
-14
lines changed

3 files changed

+57
-14
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ RUN chmod 755 /usr/local/bin/nemoclaw-start
4848
# Build args for config that varies per deployment.
4949
# nemoclaw onboard passes these at image build time.
5050
ARG NEMOCLAW_MODEL=nvidia/nemotron-3-super-120b-a12b
51-
ARG NEMOCLAW_PROVIDER_KEY=nvidia
52-
ARG NEMOCLAW_PRIMARY_MODEL_REF=nvidia/nemotron-3-super-120b-a12b
51+
ARG NEMOCLAW_PROVIDER_KEY=inference
52+
ARG NEMOCLAW_PRIMARY_MODEL_REF=inference/nvidia/nemotron-3-super-120b-a12b
5353
ARG CHAT_UI_URL=http://127.0.0.1:18789
5454
ARG NEMOCLAW_INFERENCE_BASE_URL=https://inference.local/v1
5555
ARG NEMOCLAW_INFERENCE_API=openai-completions

scripts/nemoclaw-start.sh

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,36 @@ write_auth_profile() {
120120
return
121121
fi
122122

123+
# Read the provider key from openclaw.json so the auth profile matches
124+
# the provider key used in the model config. Hardcoding 'nvidia' breaks
125+
# when getSandboxInferenceConfig() maps nvidia-prod/nvidia-nim to
126+
# 'inference'. See: https://github.com/NVIDIA/NemoClaw/issues/1332
123127
python3 - <<'PYAUTH'
124128
import json
125129
import os
130+
131+
# Resolve provider key from openclaw.json — must match the key in
132+
# config.models.providers so OpenClaw can find the credentials.
133+
provider_key = 'inference' # safe default matching getSandboxInferenceConfig
134+
config_path = os.path.expanduser('~/.openclaw/openclaw.json')
135+
try:
136+
with open(config_path) as f:
137+
config = json.load(f)
138+
providers = config.get('models', {}).get('providers', {})
139+
keys = list(providers.keys())
140+
if keys:
141+
provider_key = keys[0]
142+
except Exception:
143+
pass # fall through to default
144+
126145
path = os.path.expanduser('~/.openclaw/agents/main/agent/auth-profiles.json')
127146
os.makedirs(os.path.dirname(path), exist_ok=True)
128147
json.dump({
129-
'nvidia:manual': {
148+
f'{provider_key}:manual': {
130149
'type': 'api_key',
131-
'provider': 'nvidia',
150+
'provider': provider_key,
132151
'keyRef': {'source': 'env', 'id': 'NVIDIA_API_KEY'},
133-
'profileId': 'nvidia:manual',
152+
'profileId': f'{provider_key}:manual',
134153
}
135154
}, open(path, 'w'))
136155
os.chmod(path, 0o600)

scripts/write-auth-profile.ts

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,45 @@
22
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33
// SPDX-License-Identifier: Apache-2.0
44

5-
import { chmodSync, mkdirSync, writeFileSync } from "node:fs";
5+
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
66
import { dirname, join } from "node:path";
77
import { homedir } from "node:os";
88

9-
const path = join(homedir(), ".openclaw", "agents", "main", "agent", "auth-profiles.json");
9+
// Read the provider key from openclaw.json so the auth profile matches
10+
// the provider key used in the model config. Hardcoding 'nvidia' breaks
11+
// when getSandboxInferenceConfig() maps nvidia-prod/nvidia-nim to 'inference'.
12+
// See: https://github.com/NVIDIA/NemoClaw/issues/1332
13+
function resolveProviderKey(): string {
14+
const configPath = join(homedir(), ".openclaw", "openclaw.json");
15+
if (existsSync(configPath)) {
16+
try {
17+
const config = JSON.parse(readFileSync(configPath, "utf-8"));
18+
const providers = config?.models?.providers;
19+
if (providers && typeof providers === "object") {
20+
const keys = Object.keys(providers);
21+
if (keys.length > 0) {
22+
return keys[0];
23+
}
24+
}
25+
} catch {
26+
// Fall through to default
27+
}
28+
}
29+
return "inference";
30+
}
31+
32+
const providerKey = resolveProviderKey();
33+
const authPath = join(homedir(), ".openclaw", "agents", "main", "agent", "auth-profiles.json");
1034
const profile = {
11-
"nvidia:manual": {
35+
[`${providerKey}:manual`]: {
1236
type: "api_key",
13-
provider: "nvidia",
37+
provider: providerKey,
1438
keyRef: { source: "env", id: "NVIDIA_API_KEY" },
15-
profileId: "nvidia:manual",
39+
profileId: `${providerKey}:manual`,
1640
},
1741
};
1842

19-
mkdirSync(dirname(path), { recursive: true });
20-
writeFileSync(path, JSON.stringify(profile));
21-
chmodSync(path, 0o600);
22-
console.log(`Wrote auth profile to ${path}`);
43+
mkdirSync(dirname(authPath), { recursive: true });
44+
writeFileSync(authPath, JSON.stringify(profile));
45+
chmodSync(authPath, 0o600);
46+
console.log(`Wrote auth profile to ${authPath} (provider: ${providerKey})`);

0 commit comments

Comments
 (0)