NemoClaw icon indicating copy to clipboard operation
NemoClaw copied to clipboard

Model router onboarding accepts a health response that names zero healthy endpoints

Open udsy19 opened this issue 3 months ago • 2 comments

Investigation Summary

  • The Model Router startup poll accepts any 2xx /health; the final snapshot taken after the poll additionally requires the body to name at least one healthy endpoint. Two acceptance paths in the same function apply different rules.
  • The file's own comment states the intended contract — the poll "must not accept a fast 200 that names zero healthy endpoints" — so the code does not do what the comment says it does.
  • When the routed credential is rejected, every upstream fails fast, /health answers 200 with "healthy_endpoints": [] well inside the 3-second liveness budget, the poll accepts on its first probe, and onboarding continues to sandbox creation.
  • Reproduced against the source module: with isRouterHealthy -> true and a /health body of {"healthy_endpoints": [], "unhealthy_endpoints": [{"error": "AuthenticationError: bad key"}]}, startModelRouter returns the PID instead of failing.
  • The end state matches closed issue #3580, whose reproduction records "Complete onboard (sandbox created successfully)" alongside "healthy_endpoints": [] and a 401 on every message.

Description

startModelRouter in src/lib/onboard/model-router.ts decides twice whether the router came up.

The startup poll (src/lib/onboard/model-router.ts:471-473) asks the status-only probe:

const healthy = await deps.isRouterHealthy(port, healthTimeoutMs);
const processAlive = deps.isProcessAlive(pid);
if (healthy && processAlive) return pid;

isRouterHealthy (src/lib/onboard/model-router-process.ts:91-114) resolves on the status code alone; it calls res.resume() and never reads the response body.

The final snapshot, 14 lines later (src/lib/onboard/model-router.ts:487), applies the opposite rule:

if (finalSnapshot.healthy && hasHealthyEndpoint(finalSnapshot.body) && deps.isProcessAlive(pid)) {
  return pid;
}

The comment that introduces the final-snapshot budget (src/lib/onboard/model-router.ts:62-68) states which rule was intended:

The startup poll keeps the 3-second budget: the status-only liveness probe must not accept a fast 200 that names zero healthy endpoints, so recovery for a slow-but-healthy router runs through the body-checked final snapshot after the poll exhausts its retries.

The poll does accept it. LiteLLM's /health returns 200 with {"healthy_endpoints": [], "unhealthy_endpoints": [...]} when every upstream rejects the credential, and an authentication rejection returns quickly, so that answer arrives well inside the 3-second budget the poll allows per request.

Expected: onboarding reports the Model Router started only when /health names at least one healthy endpoint, and otherwise fails with the endpoint error the startup path already collects and redacts.

Actual: onboarding prints ✓ Model router started, creates the sandbox, and every routed request then fails against a router with no usable endpoint.

Reproduction Steps

  1. Run nemoclaw onboard and select the Model Router (routed) inference provider.
  2. Supply a credential the configured upstreams reject (for example a key in the wrong format for the LiteLLM proxy, as in #3580).
  3. Onboarding reports the Model Router started and proceeds to create the sandbox.
  4. Connect to the sandbox and send any message. Every request fails with an authentication error.
  5. curl http://127.0.0.1:<router port>/health returns 200 with "healthy_endpoints": [].

The same behavior reproduces against the source module without a live router, by driving startModelRouter with a /health status probe that answers 2xx and a body that names zero healthy endpoints. The repository's own case test/onboard-model-router.test.ts — "still fails when the final snapshot is 2xx with zero healthy endpoints" — passes only because its status probe is stubbed to false; making that stub answer 2xx for the poll turns the expected rejection into a returned PID.

Environment

  • Reproduced by driving src/lib/onboard/model-router.ts directly, so the defect is platform-independent.
  • Source revision: main at 7d516f2ed.
  • Node.js v26.7.0, macOS 26.5.1 (host used for the source-level reproduction).
  • The field report of the same end state (#3580) is DGX Spark / Ubuntu 24.04 / NemoClaw v0.0.43.

Debug Output

Not applicable — this is a source-level defect in the onboarding health gate, reproduced against the module rather than a deployed installation. The relevant evidence is the two acceptance paths quoted above.

Logs

AssertionError: Missing expected rejection.

  await assert.rejects(
    startModelRouter(
      { port: 45_694, pool_config_path: "router/test-pool.yaml" },
      { ...
        isRouterHealthy: async (_port, timeoutMs) => timeoutMs !== undefined,
        getRouterHealthSnapshot: async () => ({
          healthy: true,
          body: '{"healthy_endpoints":[],"unhealthy_endpoints":[{"error":"AuthenticationError: bad key"}]}',
        }),
      },
    ),
    /failed to become healthy on port 45694/,
  );

startModelRouter returns PID 12345 instead of rejecting.

Checklist

  • [x] I confirmed this bug is reproducible
  • [x] I searched existing issues and this is not a duplicate

udsy19 avatar Aug 18 '26 07:08 udsy19

Hi @udsy19 thanks for the report. Can you clean up the beginning of this issue so it is clear if this is a draft or not?

wscurran avatar Aug 18 '26 18:08 wscurran

@wscurran thanks for the review, and apologies for not replying sooner. The opening of this report has been rewritten: the stray heading lines are gone and the body now starts at ## Investigation Summary, so there is nothing left that reads as a draft.

The report itself still holds on main at 3184db96e. startModelRouter accepts the startup poll on a status-only probe while the final snapshot additionally requires healthy_endpoints to be non-empty, so a router that answers 200 with "healthy_endpoints": [] inside the three-second budget is accepted on the first probe.

Could you clear needs: info when you get a moment? Happy to add anything else that would help.

udsy19 avatar Aug 19 '26 03:08 udsy19