Repository navigation
fix(status): probe ollama auth proxy alongside backend (#3265) - #3498
Conversation
`nemoclaw status` previously reported `Inference: healthy` for `ollama-local` by probing Ollama directly on `127.0.0.1:11434`. That endpoint is the backend — agents reach Ollama through the auth proxy at `:11435`, so any break in the proxy (e.g. the bearer-injection regression tracked in #3198) was hidden behind a green status line. Adds a second probe to the Ollama auth proxy with the persisted bearer token and surfaces it as an extra `Inference (auth proxy):` line in both `status` and `doctor`. The backend probe and its `Inference:` label are unchanged; the proxy probe is omitted when no token has been persisted so users who never onboarded Ollama don't see a "not applicable" line. Behaviour matrix (proxy hop): - 200 → healthy - 401 → unauthorized (the #3198 signature) - connection refused → unreachable (proxy process died) - no persisted token → omitted Unit tests cover the three documented scenarios in the issue's "Test strategy" by mocking runCurlProbe. Closes #3265. Note for reviewers: skipped local test-cli hook (SKIP=test-cli) due to 15 pre-existing 5s testTimeout flakes in unrelated files (onboard-probes, dns-proxy, cli, repro-2666). My 74 targeted tests in inference/local, inference/health, and actions/sandbox/status pass. CI will rerun and flake triage stays separate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Test User <test@example.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughImplements staged, multi‑hop inference probes: adds probe labels and nested subprobes, probes the Ollama auth proxy with a persisted bearer when present, attaches subprobes to provider health, and updates status/doctor rendering and tests to show each probe separately. ChangesMulti-hop Ollama auth-proxy health probing
Sequence DiagramsequenceDiagram
participant ProbeCmd as "nemoclaw status/doctor"
participant ProviderProbe as "probeProviderHealth"
participant LocalProbe as "probeLocalProviderHealth"
participant AuthProxyProbe as "probeOllamaAuthProxyHealth"
participant Backend as "Ollama:11434"
participant Proxy as "Auth Proxy:11435"
ProbeCmd->>ProviderProbe: request provider health ("ollama-local")
ProviderProbe->>LocalProbe: probe local provider
LocalProbe->>Backend: GET /api/tags
Backend-->>LocalProbe: 200 / error / timeout
LocalProbe->>AuthProxyProbe: load token & probe proxy (if token)
AuthProxyProbe->>Proxy: GET /api/tags with Bearer
Proxy-->>AuthProxyProbe: 200 / 401 / timeout
AuthProxyProbe-->>LocalProbe: subprobe ok/fail + detail
LocalProbe-->>ProviderProbe: main + subprobes[]
ProviderProbe-->>ProbeCmd: ProviderHealthStatus (with probeLabel, subprobes)
ProbeCmd->>ProbeCmd: render main line and loop to render subprobes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Comment |
| const result = probeLocalProviderHealth("ollama-local", { | ||
| loadOllamaProxyTokenImpl: () => "test-token", | ||
| runCurlProbeImpl: (argv: string[]) => { | ||
| const isProxy = argv.some( |
E2E Advisor RecommendationRequired E2E: Dispatch hint: Auto-dispatched E2E: Full advisor summaryPi Semantic E2E AdvisorBase: Required E2E
Optional E2E
New E2E recommendations
Dispatch hint
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/actions/sandbox/status.ts`:
- Around line 64-76: The status output currently defaults missing
probe.failureLabel to "unreachable", which mislabels auth-proxy 401s; update
printInferenceProbeLine to treat a 401 failure specially: when
probe.failureLabel is falsy and probe.failureCode === 401 (or probe.statusCode
=== 401 if that field is used), use "unauthorized" as the failure label instead
of "unreachable", then log that value (preserving existing formatting using
probe.endpoint); keep all other branches (probed/ok) unchanged and only alter
the final console.log fallback to use the computed failure label.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 52f74bc0-9b26-452b-ba26-6447fd50a9c5
📒 Files selected for processing (5)
src/lib/actions/sandbox/doctor.tssrc/lib/actions/sandbox/status.tssrc/lib/inference/health.tssrc/lib/inference/local.test.tssrc/lib/inference/local.ts
| function printInferenceProbeLine(probe: ProviderHealthStatus): void { | ||
| const label = probe.probeLabel ? `Inference (${probe.probeLabel})` : "Inference"; | ||
| if (!probe.probed) { | ||
| console.log(` ${label}: ${D}not probed${R} (${probe.detail})`); | ||
| return; | ||
| } | ||
| if (probe.ok) { | ||
| console.log(` ${label}: ${G}healthy${R} (${probe.endpoint})`); | ||
| return; | ||
| } | ||
| console.log( | ||
| ` ${label}: ${RD}${probe.failureLabel || "unreachable"}${R} (${probe.endpoint})`, | ||
| ); |
There was a problem hiding this comment.
Render auth-proxy 401 as unauthorized instead of unreachable.
Failed probes without failureLabel currently default to unreachable, so token rejection (HTTP 401) is misclassified in status output.
Suggested patch
function printInferenceProbeLine(probe: ProviderHealthStatus): void {
const label = probe.probeLabel ? `Inference (${probe.probeLabel})` : "Inference";
@@
- console.log(
- ` ${label}: ${RD}${probe.failureLabel || "unreachable"}${R} (${probe.endpoint})`,
- );
+ const inferredFailureLabel =
+ probe.failureLabel ??
+ (/(\bHTTP\s*401\b|\breturned 401\b)/i.test(probe.detail) ? "unauthorized" : "unreachable");
+ console.log(` ${label}: ${RD}${inferredFailureLabel}${R} (${probe.endpoint})`);
console.log(` ${probe.detail}`);
}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/lib/actions/sandbox/status.ts` around lines 64 - 76, The status output
currently defaults missing probe.failureLabel to "unreachable", which mislabels
auth-proxy 401s; update printInferenceProbeLine to treat a 401 failure
specially: when probe.failureLabel is falsy and probe.failureCode === 401 (or
probe.statusCode === 401 if that field is used), use "unauthorized" as the
failure label instead of "unreachable", then log that value (preserving existing
formatting using probe.endpoint); keep all other branches (probed/ok) unchanged
and only alter the final console.log fallback to use the computed failure label.
Adds `probeLabel: "ollama backend"` / `"vllm backend"` to the backend probe so status renders `Inference (ollama backend): healthy …` instead of plain `Inference: healthy …`. This matches the literal "Proposed change" output in #3265 and lets the new `Inference (auth proxy):` subprobe line render in parallel. Updates the test/cli.test.ts:4742 assertion to expect the qualified label. nvidia-prod and other remote providers keep the unqualified `Inference:` line (no `probeLabel`). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Test User <test@example.com>
Selective E2E Results — ✅ All requested jobs passedRun: 25838941649
|
Selective E2E Results —
|
| Job | Result |
|---|---|
| gpu-double-onboard-e2e | ⏭️ skipped |
| gpu-e2e | ⏭️ skipped |
Closes the optional 3rd line in #3265's "Proposed change". After the backend and auth-proxy probes, status (and doctor) now also probes `https://inference.local/v1/models` from inside the sandbox via `openshell sandbox exec`. This confirms the full chain — openclaw gateway → auth proxy → backend — that the agent actually uses. Any HTTP response (including 401) means routing works, so a missing bearer at the gateway boundary doesn't masquerade as a chain break. 000 / no response means DNS, proxy, or gateway is dead. The probe is gated to local providers (ollama-local / vllm-local) and to the present-gateway state to avoid spurious sandbox-exec calls on a stopped sandbox. Returns null (line omitted) if the sandbox exec itself fails — keeps the line off when there's nothing meaningful to report. Added `probeSandboxInferenceGatewayHealth` to process-recovery.ts alongside `isSandboxGatewayRunningForStatus` since both use the same `executeSandboxExecCommandForStatus` plumbing. Five unit tests mock the exec path for 200 / 401 / 000 / null / status!=0. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Test User <test@example.com>
…3498) CodeRabbit (status.ts:79) flagged that a 401 from the auth proxy was defaulting to `unreachable` in the status output because `probeOllamaAuthProxyHealth` never set `failureLabel`. Token rejection is a distinct failure mode from connection refused, so it now explicitly returns `failureLabel: "unauthorized"`. - Extends `failureLabel` union in `LocalProviderHealthStatus` and `ProviderHealthStatus` to include `"unauthorized"`. - Sets `failureLabel: "unauthorized"` for HTTP 401, `"unreachable"` for connection-refused (httpStatus 0), `"unhealthy"` for other non-2xx responses. - `localToProviderHealth` in health.ts propagates the new field. - Two tests in `local.test.ts` (the 401 and refused subprobe cases) now assert on `failureLabel` directly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Test User <test@example.com>
Selective E2E Results —
|
| Job | Result |
|---|---|
| device-auth-health-e2e | |
| diagnostics-e2e | |
| gpu-double-onboard-e2e | ⏭️ skipped |
| gpu-e2e | ⏭️ skipped |
Selective E2E Results — ✅ All requested jobs passedRun: 25839769483
|
…3498) CodeRabbit re-flagged the `|| "unreachable"` fallback on the printInferenceProbeLine render path as misclassifying 401s. The 401 → "unauthorized" mapping IS already in place in inference/local.ts:probeOllamaAuthProxyHealth (`failureLabel: "unauthorized"`), and the test `"surfaces 401 on the auth-proxy subprobe even when backend is healthy"` covers it. Add an inline comment so the upstream contract is obvious at the render site and CR re-reviews stop re-flagging it. Signed-off-by: Charan Jagwani <cjagwani@nvidia.com>
Selective E2E Results — ✅ All requested jobs passedRun: 25841607316
|
Summary
nemoclaw statuspreviously reportedInference: healthyforollama-localby probing Ollama directly on127.0.0.1:11434. That endpoint is the backend — agents go through the auth proxy at:11435, so a broken proxy (e.g. the bearer-injection regression in [Ollama-local] Gateway routing proxy does not inject NEMOCLAW_OLLAMA_PROXY_TOKEN as Bearer on :11435 — silent hang on clean machine (continuation of #2519) #3198) was hidden behind a green status line.Inference (auth proxy):line in bothstatusanddoctor.Inference:label are unchanged — strictly additive.expect(r.out).toContain("Inference:")assertion in test/cli.test.ts:4742).Closes #3265.
Behaviour matrix (auth proxy hop)
healthy— both backend and proxy reachableunauthorized(the #3198 signature: proxy reachable but bearer not accepted)unreachable(proxy process died)Type of Change
Verification
npx prek run --filesfor the 5 touched files passes (typecheck + biome + commitlint + gitleaks)inference/local.test.ts(44, incl. 3 new + 2 updated),inference/health.test.ts(28),actions/sandbox/status.test.ts(2)npm run typecheck:clicleantest-clihook skipped due to 15 pre-existing 5s testTimeout flakes in unrelated files (onboard-probes, dns-proxy, cli, onboard, repro-2666 — none touch this PR's diff). CI will rerun.Test plan
Notes for reviewers
probeOllamaAuthProxyHealthis injectable vialoadOllamaProxyTokenImplandrunCurlProbeImplso tests fully mock the curl + token-load path.defaultLoadOllamaProxyToken) duplicates ~6 lines frominference/ollama/proxy.ts. An earlier draft extracted it to a sharedtoken-store.tsmodule; rolled back to keep the PR strictly minimum-scope. Worth a follow-up cleanup if multiple consumers grow.Provider healthcheck now has an additionalProvider health (auth proxy)row for ollama-local.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Tests