fix(cli): show inference health in sandbox status output#2002
fix(cli): show inference health in sandbox status output#2002
Conversation
sandboxStatus() already probed local providers (vllm-local, ollama-local) but showed no Inference line for remote providers. Add a unified probeProviderHealth() dispatcher that performs lightweight reachability checks for remote cloud endpoints (nvidia-prod, openai-api, anthropic-prod, gemini-api) and a "not probed" fallback for compatible-* providers whose URLs are unknown. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughIntroduces a unified inference-provider health-probing layer with functions to map providers to endpoints, probe remote providers via curl with timeout control, and delegate between local and remote probing strategies. Includes comprehensive test coverage and integrates the new health-probing API into nemoclaw status reporting. Changes
Sequence DiagramsequenceDiagram
participant Caller
participant probeProviderHealth
participant probeLocalProviderHealth
participant probeRemoteProviderHealth
participant getRemoteProviderHealthEndpoint
participant curl as runCurlProbeImpl<br/>(curl probe)
Caller->>probeProviderHealth: provider, options
alt Local Provider
probeProviderHealth->>probeLocalProviderHealth: Attempt local probe
probeLocalProviderHealth-->>probeProviderHealth: ProviderHealthStatus | null
else Remote Provider
probeProviderHealth->>probeRemoteProviderHealth: Delegate to remote
probeRemoteProviderHealth->>getRemoteProviderHealthEndpoint: Map provider to endpoint
getRemoteProviderHealthEndpoint-->>probeRemoteProviderHealth: endpoint URL | null
alt Compatible Endpoint
probeRemoteProviderHealth-->>probeProviderHealth: {probed: false, ok: true}
else Remote Endpoint Found
probeRemoteProviderHealth->>curl: curl with timeouts + endpoint
curl-->>probeRemoteProviderHealth: CurlProbeResult
probeRemoteProviderHealth-->>probeProviderHealth: {probed: true, ok: boolean}
end
else Unknown Provider
probeProviderHealth-->>Caller: null
end
probeProviderHealth-->>Caller: ProviderHealthStatus | null
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/nemoclaw.ts (1)
1214-1226: Extract inference rendering to keepsandboxStatuscomplexity in check.Line 1200’s function is already complexity-suppressed, and this new branch block adds more decision paths. Consider moving this rendering logic to a small helper.
♻️ Proposed refactor
+function printInferenceHealthStatus(inferenceHealth) { + if (!inferenceHealth) return; + if (!inferenceHealth.probed) { + console.log(` Inference: ${D}not probed${R} (${inferenceHealth.detail})`); + return; + } + if (inferenceHealth.ok) { + console.log(` Inference: ${G}healthy${R} (${inferenceHealth.endpoint})`); + return; + } + console.log(` Inference: ${_RD}unreachable${R} (${inferenceHealth.endpoint})`); + console.log(` ${inferenceHealth.detail}`); +} ... - if (inferenceHealth) { - if (!inferenceHealth.probed) { - console.log(` Inference: ${D}not probed${R} (${inferenceHealth.detail})`); - } else if (inferenceHealth.ok) { - console.log( - ` Inference: ${G}healthy${R} (${inferenceHealth.endpoint})`, - ); - } else { - console.log( - ` Inference: ${_RD}unreachable${R} (${inferenceHealth.endpoint})`, - ); - console.log(` ${inferenceHealth.detail}`); - } - } + printInferenceHealthStatus(inferenceHealth);As per coding guidelines,
**/*.{js,ts,tsx,jsx}: Limit cyclomatic complexity to 20 in JavaScript/TypeScript files, with target of 15.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/nemoclaw.ts` around lines 1214 - 1226, The inference rendering block inside the sandboxStatus function is increasing cyclomatic complexity; extract it into a small helper named something like renderInferenceHealth(inferenceHealth) that takes the existing inferenceHealth object and the color constants (D, R, G, _RD) and returns or prints the exact same lines (handle !probed, ok, and unreachable cases including detail and endpoint) and replace the inline branch in sandboxStatus with a single call to that helper to preserve behavior and reduce complexity.src/lib/inference-health.ts (1)
92-95: Prefernot probedovernullfor recognized-but-unmapped providers.If a provider is recognized by config but missing endpoint mapping, returning
nulldrops the Inference line entirely. Returning aprobed: falsestatus is safer and keeps output stable as providers evolve.♻️ Proposed refactor
const endpoint = getRemoteProviderHealthEndpoint(provider); if (!endpoint) { - return null; + if (config) { + return { + ok: true, + probed: false, + providerLabel, + endpoint: "", + detail: "Health probe endpoint is not defined for this provider.", + }; + } + return null; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/inference-health.ts` around lines 92 - 95, The current code in inference-health.ts calls getRemoteProviderHealthEndpoint(provider) and returns null when endpoint is missing, which removes the provider from output; change the behavior so that when endpoint is falsy you return an object indicating the provider is recognized but not probed (e.g., { provider, probed: false, status: 'not probed' } or matching the existing Inference/Health shape) instead of null. Update the branch that checks `if (!endpoint)` (the code referencing endpoint from getRemoteProviderHealthEndpoint) to construct and return the non-probed status object so downstream consumers still see the provider entry.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/lib/inference-health.ts`:
- Around line 92-95: The current code in inference-health.ts calls
getRemoteProviderHealthEndpoint(provider) and returns null when endpoint is
missing, which removes the provider from output; change the behavior so that
when endpoint is falsy you return an object indicating the provider is
recognized but not probed (e.g., { provider, probed: false, status: 'not probed'
} or matching the existing Inference/Health shape) instead of null. Update the
branch that checks `if (!endpoint)` (the code referencing endpoint from
getRemoteProviderHealthEndpoint) to construct and return the non-probed status
object so downstream consumers still see the provider entry.
In `@src/nemoclaw.ts`:
- Around line 1214-1226: The inference rendering block inside the sandboxStatus
function is increasing cyclomatic complexity; extract it into a small helper
named something like renderInferenceHealth(inferenceHealth) that takes the
existing inferenceHealth object and the color constants (D, R, G, _RD) and
returns or prints the exact same lines (handle !probed, ok, and unreachable
cases including detail and endpoint) and replace the inline branch in
sandboxStatus with a single call to that helper to preserve behavior and reduce
complexity.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: b11baa0d-7e08-4b7b-a922-78b0e2db8c65
📒 Files selected for processing (3)
src/lib/inference-health.test.tssrc/lib/inference-health.tssrc/nemoclaw.ts
Summary
nemoclaw <name> statusso all providers (not just local) show an Inference linevllm-local,ollama-local) already worked — this fills the gap for remote providers (nvidia-prod,openai-api,anthropic-prod,gemini-api)probeProviderHealth()dispatcher in newinference-health.tsmodule that handles both local and remote providerscompatible-*providers show "not probed" since their endpoint URLs aren't knownFixes #995
Test plan
inference-health.test.tscovering endpoint mapping, reachability semantics, timeouts, and unified dispatchnemoclaw <sandbox> statuswith a remote provider shows new Inference linenemoclaw <sandbox> statuswith a local provider output is unchangedSummary by CodeRabbit
New Features
Tests