Skip to content

fix(openclaw_agent): install a Node runtime OpenClaw actually supports - #3621

Merged
yuhezhang-ai merged 9 commits into
NVIDIA-NeMo:mainfrom
larroy:fix/openclaw-node-runtime
Oct 6, 2026
Merged

yuhezhang-ai merged 9 commits into
NVIDIA-NeMo:mainfrom
larroy:fix/openclaw-node-runtime

Conversation

@larroy

@larroy larroy commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

The local Node.js fallback in setup_openclaw fetched Node 22.15.0, which no
published openclaw release accepts:

openclaw declared engines.node satisfied by 22.15.0?
2026.6.11 (previous pin) >=22.19.0 no
2026.9.4 (upgrade candidate) >=24.16.0 <25 || >=26.1.0 no

Any host without a system npm therefore ended up with a Node runtime OpenClaw
refuses to start on. This PR makes that fallback path actually work.

Changes

  1. Pin Node 24.21.0 — newest release of the Node 24 LTS line ("Krypton"),
    which is the line OpenClaw's own installer provisions on Linux
    (NODE_LINUX_DEFAULT_MAJOR=24). It satisfies the engine range of both the old
    and the new openclaw pin.
  2. Keep the pinned openclaw package at 2026.6.11 — 2026.9.4 was evaluated
    and rolled back: it stores session history in SQLite, which this agent's JSONL
    session reader cannot parse, so tool-using and interrupted rollouts lose their
    transcripts. The installer machinery stays version-parameterized (both engine
    ranges in OPENCLAW_ENGINES_NODE; OPENCLAW_VERSION still overrides per
    process), so the bump reduces to flipping DEFAULT_OPENCLAW_VERSION and the config
    pin once the session reader supports SQLite. Tracked separately.
  3. Allow per-process overrides via OPENCLAW_VERSION and
    OPENCLAW_NODE_VERSION, so an operator can retarget a run without editing the
    config.
  4. Drop the @latest fallback — a version is now always resolved explicitly,
    preserving the reproducibility invariant that OpenClawAgentConfig.openclaw_version
    documents.
  5. Split ensure_openclaw (37 lines, three duplicated PATH-prepends, three
    repeated which() probes) into single-concern helpers for version resolution,
    PATH mutation, discovery, npm install, and Node provisioning. The three
    ad-hoc PATH-recovery attempts collapse into one loop.

Two incidental fixes fall out of the refactor:

  • The Node tarball is removed via try/finally instead of leaking when the
    download or extraction fails.
  • npm's global bin is checked with is_dir() before PATH is mutated, rather
    than after.

Related issue: N/A — reported directly; the failure is reproducible from the
version metadata above.

Validation

# formatting / lint
pre-commit run --files responses_api_agents/openclaw_agent/**/*

# unit tests for the agent
gym env test --responses-api-agent openclaw_agent

Version claims were checked against the upstream sources of truth:

curl -s https://registry.npmjs.org/openclaw | jq '.versions["2026.9.4"].engines'
# {"node": ">=24.16.0 <25 || >=26.1.0"}

curl -s https://nodejs.org/dist/index.json | jq -r '[.[]|select(.version|startswith("v24."))][0]'
# v24.21.0, lts: "Krypton"

Rollouts

Rollouts validating the retained 2026.6.11 pin at 5d354d168 (the validation
@yuhezhang-ai requested: tool-using and interrupted rollouts retain commands/results)
are at the end of this section.

Smoke rollouts on a host without a usable system npm, run at dda454d66 against
environments/openclaw_math/config.yaml (dataset data/example.jsonl, limit 3,
OPENCLAW_VERSION=2026.9.4, policy = qwen3-5-397b-a17b via
https://inference-api.nvidia.com/v1).

Scenario A — incompatible system Node (v18.19.1) on PATH. The engine-range check
rejects it, so ensure_openclaw provisions the private toolchain from scratch:
.openclaw_node/ created at server start (Node v24.21.0), npm install -g [email protected] into an isolated prefix, the new launcher verified via
openclaw --version and selected ahead of any other on PATH. All four servers came up
healthy.

gym env start --config environments/openclaw_math/config.yaml --model-type openai_model
gym eval run --no-serve --agent openclaw_math_agent \
  --input environments/openclaw_math/data/example.jsonl --limit 3
# 3/3 rollouts, mean reward 0.33 (rewards 0/1/0), all finished naturally, 1 turn each

Scenario B — no node/npm/openclaw anywhere on PATH, caches removed (cold path).
_install_node_locally downloads node-v24.21.0-linux-x64.tar.xz from nodejs.org,
extracts and flattens it, and the same install/verify flow follows. All four servers
came up healthy.

# same commands, PATH curated to contain no node/npm/openclaw
# 3/3 rollouts, mean reward 0.67 (rewards 1/0/1), all finished naturally, 1 turn each

Example trajectory (Scenario B, task 1, reward 1.0): the model derives
$\frac{333}{1997}$ and the verifier matches it against expected_answer.

Override check (review thread r4087043384, live probes). With openclaw 2026.6.11
already installed and first on PATH, OPENCLAW_VERSION=2026.9.4 triggers a reinstall;
_expose_installed_openclaw puts npm's global bin first, so the newly installed
launcher (not the old one) is selected and reports 2026.9.4. Conversely, with a
compatible system Node (v24.18.0, satisfies >=24.16.0 <25) the system npm is
reused and no private Node is downloaded.

Before/after against the merge-base. The pre-PR setup_openclaw.py on the same
node-free PATH downloads Node 22.15.0, and openclaw's preinstall script
hard-fails on every retry: `this OpenClaw release requires Node >=24.16.0 <25 ||

=26.1.0. — detected Node 22.15.0. It also resolves openclaw@latest(2026.9.8), confirming the reproducibility problem this PR removes. At head, the same environment provisions Node24.21.0and installs2026.9.4` exactly.

Pre-existing, not a regression (checked at both versions): with this provider,
agentMeta.usage is absent from the CLI envelope, so token counts are 0 — the old pin
exposes agentMeta.lastCallUsage (also all zeros here) and the new pin has no usage
key at all; parse_openclaw_output was untouched by this PR. One row returned
"Agent couldn't generate a response" (stopReason=length from the endpoint) and the
identical failure reproduces on 2026.6.11, so it is model/endpoint behavior.

Retained-pin validation at 5d354d168 (2026.6.11, requested in review). Same
node-free host setup (no node/npm/openclaw on PATH, cold caches): setup provisioned
Node 24.21.0 against the >=22.19.0 engine range of 2026.6.11 and installed exactly
2026.6.11; all four servers healthy. Then:

  • Tool-using rollout (--limit 3): 3/3 rollouts, mean reward 0.33, mean
    turns_used 3.3 — up to 7 exec tool calls per trajectory with every command and
    result retained in the response output (read from the JSONL session transcript).
    The 1000-digit task went 6 turns / 7 tool calls and scored reward 1.0.
  • Interrupted rollout (timeout=45 on the hardest task): the partial session was
    salvaged from disk — the in-flight exec call and its result are present in the
    returned output, so commands/results survive interruption rather than vanishing.

Unit tests and lint at 5d354d168: pytest responses_api_agents/openclaw_agent/tests
133 passed; pre-commit run --files on the changed files passes.

Compatibility and benchmark impact

  • Behavioral: on hosts that already have a system npm, nothing changes —
    the local Node download path is not taken.
  • Config: openclaw_version remains required. New env vars
    OPENCLAW_VERSION / OPENCLAW_NODE_VERSION are optional and take precedence
    over the config value when set.
  • Benchmark results: unchanged from main — the pin stays 2026.6.11 in
    configs/openclaw_agent.yaml and as DEFAULT_OPENCLAW_VERSION. Scores remain
    comparable to existing baselines.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally, or N/A for docs-only / non-code changes.
  • Documentation added or updated, or N/A with justification. (README.md documents both env vars.)
  • Pre-commit checks pass locally (pre-commit run --all-files).
  • New source files include the required Apache-2.0 SPDX header. (No new files.)
  • All commits have DCO sign-off (git commit -s).

The local Node.js fallback in setup_openclaw fetched 22.15.0, which
OpenClaw rejects: it declares engines.node ">=24.16.0 <25 || >=26.1.0".
Any host without a system npm therefore ended up with an unusable
runtime. Pin 24.21.0, the newest release of the Node 24 LTS line that
OpenClaw's own installer provisions on Linux (NODE_LINUX_DEFAULT_MAJOR).

Bump the pinned openclaw package to 2026.9.4 and let the environment
override both versions via OPENCLAW_VERSION and OPENCLAW_NODE_VERSION,
so an operator can retarget a run without editing the config. Version
resolution no longer falls back to "@latest": an explicit version is
always resolved, keeping the reproducibility invariant that the config
field documents.

Split the 37-line ensure_openclaw into single-concern helpers for
version resolution, PATH mutation, discovery, npm install and Node
provisioning. This drops the triplicated PATH-prepend, the repeated
which() probing, and collapses the three PATH-recovery attempts into
one loop. Two incidental fixes fall out: the Node tarball is now
removed via try/finally instead of leaking when download or extraction
fails, and npm's global bin is checked with is_dir() before PATH is
mutated rather than after.

Signed-off-by: Pedro Larroy <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Sep 22, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@nemo-automation-bot nemo-automation-bot Bot added the community-request Issue reported or requested by someone from the community label Sep 22, 2026
@larroy larroy changed the title Fix/openclaw node runtime fix(openclaw_agent): install a Node runtime OpenClaw actually supports Sep 22, 2026
_node_dist_url hardcoded node-vX.Y.Z-linux-x64.tar.xz, so the local Node
fallback only ever worked on Linux x64. On macOS or Windows, and on any
arm64 host, it downloaded a Linux x64 tarball and the install failed
obscurely well after the point the mistake was made.

Derive the archive from the running interpreter instead. _node_platform
maps sys.platform to nodejs.org's OS token (linux/darwin/win) and a
lowercased platform.machine() to its arch token (x64/arm64), accepting the
spellings CPython actually reports: x86_64, AMD64, x64, aarch64, arm64.
Unsupported combinations now raise naming the offending value and pointing
at the manual workaround, rather than 404ing on a URL nobody constructed
deliberately.

Getting the URL right is not sufficient on its own, because Windows differs
in two further ways:

  - it ships a .zip rather than a .tar.xz, so _extract_node_archive
    dispatches on the suffix;
  - its launchers sit at the root of the extracted tree with no bin/
    subdirectory, so _node_bin_dir resolves the launcher directory per
    platform. That also fixes _adopt_npm_global_bin, which appended "bin"
    to npm's global prefix unconditionally.

Probe for executables with shutil.which(..., path=...) rather than
Path.is_file(), so node.exe and openclaw.cmd resolve through PATHEXT.

_flatten_extracted_node raised a bare StopIteration when an archive did not
contain the expected node-* directory; it now raises RuntimeError naming the
prefix.

Verified: all six URLs the mapping can produce return HTTP 200 and match
SHASUMS256.txt for v24.21.0. The win-x64 zip was downloaded and inspected to
confirm node.exe and npm.cmd sit at the tree root with no top-level bin/.

Add tests/test_setup_openclaw.py, which the module previously lacked
entirely: all six platform pairs, zip-versus-tar selection, both error
paths, real tar.xz and zip extraction round-trips, the flatten helper, and
the version resolvers.

Signed-off-by: Pedro Larroy <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Signed-off-by: Pedro Larroy <[email protected]>
@yaoyu-33 yaoyu-33 added area:agent Agent harnesses and Responses API agent behavior bug Something isn't working complexity:medium Single-domain change with interacting parts or a moderate review surface needs-review PR is ready for code review and waiting on a reviewer labels Sep 22, 2026
@github-actions github-actions Bot added the sla:triage-overdue Review assignment is over the one-business-day SLA label Sep 23, 2026
platform.machine() reports the architecture of the running interpreter,
not the host: an x64 python.exe under emulation on ARM64 silicon gets
AMD64. CPython 3.13+ makes it worse by consulting WMI first and silently
falling back to PROCESSOR_ARCHITECTURE (the emulated image) when the WMI
service is slow, so on one ARM64 host the value flipped between ARM64
and AMD64 across processes and the toolchain download alternated between
the win-arm64 and win-x64 zips.

Detect the host machine via kernel32.IsWow64Process2 (Windows 10+) and
fall back to platform.machine() only when the API is absent. A valid but
unmapped kernel answer raises the actionable error instead of silently
trusting platform.machine().

Signed-off-by: Pedro Larroy <[email protected]>
def _install_node_locally(node_version: str) -> Path:
"""Unpack a private Node.js toolchain and return the directory holding ``node``."""
bin_dir = _node_bin_dir(_LOCAL_PREFIX)
if shutil.which("node", path=str(bin_dir)):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we validate Node before reusing either this cache or system npm? Existing 22.15.0 caches are never upgraded; I also reproduced requesting 24.21.0 and reusing 25.9.0, which the new OpenClaw pin does not support. Please validate the cached version and provision a compatible runtime when needed.

RuntimeError: the install reported success but ``openclaw`` is still not
resolvable, or no ``npm`` could be provisioned.
"""
if _openclaw_on_path() or _adopt_user_local_bin():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This early return skips the new OPENCLAW_VERSION override whenever OpenClaw is already installed, so changing the override can silently keep running the old version. Could we resolve and check the requested version before accepting an existing executable?

@github-actions github-actions Bot removed the sla:triage-overdue Review assignment is over the one-business-day SLA label Sep 23, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-customer Waiting on the original author to respond label Sep 24, 2026
@yaoyu-33 yaoyu-33 removed the needs-review PR is ready for code review and waiting on a reviewer label Sep 24, 2026
Addresses review feedback on NVIDIA-NeMo#3621:

- _ensure_npm only reuses system npm when its node satisfies openclaw's
  engines.node range (OPENCLAW_ENGINES_NODE); otherwise a private toolchain
  is provisioned. Node 25.9.0 / 22.15.0 hosts no longer poison the install.
- _install_node_locally re-provisions the cached toolchain unless its node
  runs and reports exactly the requested version; corrupt or stale caches
  are wiped instead of reused forever.
- ensure_openclaw resolves the requested version first and only accepts an
  existing install whose 'openclaw --version' matches it, so changing
  OPENCLAW_VERSION (or the config pin) takes effect on the next startup.

Tests: TestSatisfiesRange, TestEnsureNpmValidatesNode,
TestInstallNodeLocallyValidatesCache, TestEnsureOpenclawRespectsRequestedVersion
(54 pass). Real smoke: ensure_openclaw reinstalled 2026.6.11 -> 2026.9.4 and
honored a subsequent OPENCLAW_VERSION=2026.6.11 override.

Signed-off-by: Pedro Larroy <[email protected]>
@larroy

larroy commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

Both review comments addressed in d79a153:

Comment 1 (validate Node before reusing cache / system npm):

  • _ensure_npm now probes the node first on PATH and only reuses system npm when it satisfies OpenClaw's engines.node range (setup_openclaw.OPENCLAW_ENGINES_NODE); otherwise it provisions the private toolchain. The 25.9.0 reproduction now bypasses system npm.
  • _install_node_locally re-provisions the cache unless its node runs and reports exactly the requested version — the stale 22.15.0 cache is wiped and re-downloaded, and a corrupt (non-zero-exit) cache is treated as unusable too.

Comment 2 (override skipped when openclaw already installed):

  • ensure_openclaw resolves the requested version first and only accepts an existing install when openclaw --version reports it (matched at the precision the requested spec states). Changing OPENCLAW_VERSION or the config pin now reinstalls; a launcher that fails to report a version is also reinstalled.

Validation:

  • test_setup_openclaw.py: 54 passed (new classes: TestSatisfiesRange, TestEnsureNpmValidatesNode, TestInstallNodeLocallyValidatesCache, TestEnsureOpenclawRespectsRequestedVersion).
  • Real smoke on this host (node 24.18.0, openclaw 2026.6.11 preinstalled): ensure_openclaw("2026.9.4") detected the mismatch and reinstalled to 2026.9.4; a subsequent OPENCLAW_VERSION=2026.6.11 run reinstalled back to 2026.6.11 — confirming the override is no longer silently skipped.
  • ruff check / ruff format clean on the touched files.

@svcnvidia-nemo-ci svcnvidia-nemo-ci removed the waiting-on-customer Waiting on the original author to respond label Sep 29, 2026
@cmunley1

cmunley1 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Some environments consume the implementation here - anyswe_agent for example, installs a different version, so now with this change, a reinstall will be done on every rollout, slowing down training and evaluation using this environment. I think we should either update the pins in cvdp, anyswe, anyterminal, harness_agent, and any other consumers, or allow a preinstalled different version here.

I also think we should support multi-version training/eval in environments such as above, so maybe we should consider something flexible.

@yaoyu-33 yaoyu-33 added the needs-review PR is ready for code review and waiting on a reviewer label Sep 29, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-customer Waiting on the original author to respond label Sep 29, 2026
@yaoyu-33 yaoyu-33 removed the needs-review PR is ready for code review and waiting on a reviewer label Sep 29, 2026
@larroy

larroy commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for flagging this — worth pinning down precisely, because the current code doesn't do what the comment describes.

No reinstall happens per rollout today. ensure_openclaw (d79a153) accepts an existing install when openclaw --version reports the requested version, so the per-rollout cost on the happy path is a single --version probe. I verified this: with openclaw 2026.6.11 already on PATH and requesting 2026.6.11, ensure_openclaw("2026.6.11") returns in 0.07 s with no install; the same call requesting 2026.9.4 takes ~30 s because it actually reinstalls.

The consumers' pins already match. anyswe_agent (anyswe_openclaw.yaml) requests openclaw_version: 2026.6.11, and the shared openclaw_agent_deps.sh it runs installs [email protected] (OPENCLAW_SPEC:[email protected]). Same for anyterminal_agent and the openclaw_math / openclaw_reasoning_gym environments — all 2026.6.11. So "anyswe_agent installs a different version" isn't the case in the current tree: it installs and requests the same version.

Two clarifications on lifecycle:

  • For standalone agent servers (openclaw_agent, openclaw_math, openclaw_reasoning_gym), ensure_openclaw runs once in model_post_init at server startup, not per rollout.
  • For the in-sandbox harnesses (anyswe, anyterminal, harness_agent), the agent runner does instantiate OpenClawAgent inside a fresh sandbox per rollout, so the --version check does run per rollout. That's the scenario behind this concern, and it's cheap as long as the pins agree.

The real risk the comment points at is pin drift with no shared source of truth. The deps-script pin (OPENCLAW_SPEC) and the agent-config pin (openclaw_version) are independent; nothing enforces they agree. If they drift, every rollout pays an npm reinstall (~30 s measured), and if the deps toolchain's Node is out of engines.node range, _ensure_npm also provisions a private Node toolchain inside the ephemeral sandbox (~60 s) that can never be cached across rollouts. That's a legitimate failure mode worth guarding against.

On the proposed fixes:

  • Updating the pins everywhere (cvdp, anyswe, anyterminal, harness_agent): I don't think this is needed as a fix — the pins already agree at 2026.6.11, and this PR deliberately doesn't force 2026.9.4 on consumers; each config keeps its own pin.
  • Allowing a preinstalled different version: I'd push back on this as stated — it reintroduces the bug fixed in d79a153, where a version override was silently ignored because an existing install was accepted unconditionally. Silently running openclaw X when the config pins Y breaks the reproducibility invariant openclaw_version documents and makes benchmark results non-comparable.

What I think is actually worth doing (happy to follow up in a separate issue/PR):

  1. Single source of truth for the pin: have openclaw_agent_deps.sh derive OPENCLAW_SPEC from the same config value the agent will request (or include it in the deps recipe hash), so drift becomes impossible rather than merely detected per rollout.
  2. Fail fast on mismatch in sandboxed harnesses: treat "installed ≠ requested" as a setup-time error at the first rollout rather than an inline per-rollout reinstall — a mismatch is a packaging mistake, and per-rollout npm installs are never the right recovery.
  3. Multi-version support (versioned prefixes selected per run): genuinely useful for mixed-version training/eval, but it's real machinery for a need nobody has demonstrated yet; I'd defer until there's a concrete consumer.

Happy to take (1) as a follow-up PR if that works for you.

@svcnvidia-nemo-ci svcnvidia-nemo-ci removed the waiting-on-customer Waiting on the original author to respond label Sep 29, 2026
@yaoyu-33 yaoyu-33 added the needs-review PR is ready for code review and waiting on a reviewer label Sep 29, 2026

@yuhezhang-ai yuhezhang-ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed commit d79a1535e64627d401158295d90d7738e17acae6 through independent Codex and Claude passes, followed by verification of the actionable claims. I recommend changes for the startup/version-selection issues described inline. Four correction requests and two explicitly nonblocking suggestions are included.

Validation: all 118 OpenClaw agent tests passed (two process-inspection tests required a targeted rerun outside the local sandbox); Ruff lint and formatting passed for the three changed Python files, and git diff --check passed. Reduced reproductions exercised runtime selection, PATH precedence, older-pin compatibility, and version matching. These used isolated executable fixtures, not a real npm installation or model/container rollout. Representative rollout validation remains needed after the fixes.

unknown version: not acceptable evidence of a compatible install.
"""
try:
completed = subprocess.run([openclaw_bin, "--version"], capture_output=True, text=True, timeout=120)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Use the configured Node runtime for the version probe

The anyterminal runner appends /agent_deps_mount/bin to PATH, while anyterminal_openclaw.yaml sets node_bin_dir to that directory. Rollouts honor that setting in OpenClawAgent._env(), but this new startup probe does not. If a task image has Node 20 earlier on PATH, the bundled OpenClaw 2026.6.11 launcher rejects that runtime before printing its version. Setup then attempts to provision Node under /nemo_gym_mount, which anyterminal mounts read-only, and agent construction fails. At the base commit, setup returned after finding the launcher and the rollout selected the compatible bundled Node 22.19.

Please pass the configured runtime into setup and use it consistently for probes and installation, preserving the runner's deliberate task-Python selection. A reduced reproduction with executable fixtures and the same PATH/read-only-directory arrangement succeeds at base and raises PermissionError at this head; I did not run a real container rollout. The upstream launcher's Node check is visible here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9bfe4e6. ensure_openclaw now receives node_bin_dir from the agent config. Setup searches this directory before PATH for openclaw, node and npm. Setup also uses this order in the environment of each probe and of npm. Setup does not change the process PATH, so the runner keeps the task Python first.

If the node in node_bin_dir does not satisfy the release range, setup stops with an error. It does not provision a private Node, because node_bin_dir comes first at rollout time.

The new test test_configured_runtime_is_used_for_probe uses your layout: Node 20 first on PATH, Node 22.19 and a launcher that rejects Node 20 in the appended directory, and a read-only prefix. Setup returns without an install and PATH does not change.

Comment on lines +498 to +500
for adopt in (lambda: True, lambda: _adopt_npm_global_bin(npm_bin), _adopt_user_local_bin):
if adopt() and (found := _openclaw_on_path()):
return found

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Select and verify the newly installed executable before returning

The first iteration accepts any OpenClaw already on PATH, including the old executable that caused ensure_openclaw() to reinstall. When system npm installs into a different global prefix, this returns before adopting that prefix. I reproduced a successful installation of 2026.9.4 into a separate directory while setup returned successfully and command lookup still selected 2026.6.11.

Please prioritize the npm installation directory and verify that the final selected executable satisfies the requested version. Add coverage that exercises actual PATH selection: the current upgrade tests replace _expose_installed_openclaw() with a simulated result and miss this case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9bfe4e6. After the install, setup puts the npm global bin directory first. Then it tries ~/.local/bin, then the current PATH. Setup then runs openclaw --version on the selected launcher. If the launcher does not report the requested version, setup stops with an error that gives the path and both versions.

TestRealPathSelection uses real executable files and real PATH lookup, with no replacement of _expose_installed_openclaw. One test puts an old 2026.6.11 launcher first on PATH and an npm that installs 2026.9.4 into a separate prefix. The new launcher is selected. A second test uses an npm that installs nothing. Setup stops with an error.

Comment on lines +424 to +426
if npm:
LOG.info("installing openclaw via system npm (%s)", npm)
_npm_install(npm, version)
else:
LOG.info("npm not found; installing local Node.js")
bin_dir = _install_node_locally()
os.environ["PATH"] = str(bin_dir) + os.pathsep + os.environ.get("PATH", "")
npm = shutil.which("npm")
if not npm:
raise RuntimeError(f"npm not found after local Node.js install in {bin_dir}")
_npm_install(npm, version)

# npm install -g may put the binary in a prefix not yet on PATH
if not shutil.which("openclaw"):
npm_bin_dir = _npm_global_bin(shutil.which("npm") or "npm")
if npm_bin_dir and Path(npm_bin_dir).is_dir():
os.environ["PATH"] = npm_bin_dir + os.pathsep + os.environ.get("PATH", "")

if not shutil.which("openclaw") and (local_bin / "openclaw").is_file():
os.environ["PATH"] = str(local_bin) + os.pathsep + os.environ.get("PATH", "")

if not shutil.which("openclaw"):
node_version = _node_on_path()
if node_version is None or _satisfies_range(node_version, OPENCLAW_ENGINES_NODE):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Check the Node requirement of the requested OpenClaw release

_ensure_npm() receives no requested package version and always uses the 2026.9.4 engine range. The runnable math/reasoning examples and sandbox configs still pin 2026.6.11, whose declared requirement is >=22.19.0. A supported system Node 22.19 is therefore rejected and replaced unnecessarily.

This becomes a startup regression when npm can install from a cache/internal registry but nodejs.org is unavailable. A reduced before/after reproduction with working npm and a simulated blocked Node download succeeds at base and fails here before npm installation. Please derive/select compatibility requirements for the requested release instead of applying the newer pin's range to every configuration. The registry confirms the older requirement and newer requirement.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9bfe4e6. Setup now uses the engines.node range of the requested release. OPENCLAW_ENGINES_NODE is now a table: 2026.6.11 is >=22.19.0, 2026.9.4 is >=24.16.0 <25 || >=26.1.0. For a release that is not in the table, setup runs npm view openclaw@<version> engines.node, so an internal registry also works. If that fails, setup logs a warning and uses the newest known range.

Real check on macOS with system Node 22.22.3: ensure_openclaw("2026.6.11") used the system npm and did not download Node. ensure_openclaw("2026.9.4") provisioned Node 24.21.0.

Comment on lines +398 to +402
monkeypatch.setattr(setup_openclaw, "_install_node_locally", lambda v: tmp_path / "local" / "bin")
monkeypatch.setattr(setup_openclaw, "_prepend_path", lambda _dir: None)
fake.install("npm", str(tmp_path / "local" / "bin" / "npm"), "10.9.0")

assert setup_openclaw._ensure_npm() == str(tmp_path / "local" / "bin" / "npm")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Make the recovery tests observe provisioning before exposing its result

fake.install("npm", ...local...) overwrites the fake system npm before _ensure_npm() runs. The incompatible-runtime and missing-runtime tests use the same arrangement, so these tests do not distinguish reuse from provisioning. In this broken-node case, production code actually accepts node_version is None and returns the already-visible fake local npm without calling _install_node_locally().

Please expose the replacement only when provisioning/PATH mutation happens and assert whether provisioning was called. Also reject a missing or failed Node version probe instead of treating it as compatible. An executable-fixture reproduction selected a broken system runtime with zero provisioning calls. This is an incomplete recovery guarantee rather than a new failure mode compared with base. Clearing the advertised version-override environment variables in these tests would also keep their expectations independent of the developer's shell.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9bfe4e6. The provisioning fixture makes the local node and npm visible only when _install_node_locally runs. Each test checks the provisioning calls: zero for reuse, one for provisioning. A missing node, or a node --version that fails, now causes provisioning. An autouse fixture removes OPENCLAW_VERSION and OPENCLAW_NODE_VERSION.

reported = _openclaw_reported_version(openclaw_bin)
if reported is None:
return False
requested_match = re.match(r"[\^~>=< ]*v?(\d+(?:\.\d+){0,2})", requested)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3, nonblocking] Implement npm-spec matching or explicitly restrict supported inputs

Stripping the operators and comparing numeric prefixes does not implement the npm semantics claimed by the docstring. With 2026.9.4 installed, this rejects ^2026.9.0 and >=2026.9.0, but accepts <2026.9.4 and the distinct exact pin 2026.9.4-beta.1. I checked these results directly against the helper and npm's documented range rules.

Please either support the advertised specs correctly or validate/document a narrower exact-version contract. Otherwise startup can repeatedly reinstall a satisfactory version or silently reuse an unsatisfactory one. This is nonblocking because the current repository configs use exact stable pins; it should also be considered when adding post-install verification.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 9bfe4e6. The contract is now an exact version. resolve_openclaw_version rejects values such as ^2026.9.0, >=2026.9.0, 2026.9 and <2026.9.4 with a ValueError. Setup compares the full reported version as a string, so 2026.9.4-beta.1 is not equal to 2026.9.4. All repository configs already use exact versions.

Windows distributions place them at the root of the tree; every other
platform uses a ``bin/`` subdirectory.
"""
return prefix if _node_platform()[0] == "win" else prefix / "bin"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3, nonblocking] Determine the bin layout without validating download architecture

_adopt_npm_global_bin() also calls this helper for an already-installed system npm. Calling _node_platform() makes that lookup reject architectures outside the download map, even when no Node download is needed. For example, a simulated Linux/ppc64le host with an existing npm prefix/bin raises here; the base implementation simply returned prefix/bin.

Please select the bin layout from the OS alone and reserve architecture validation for choosing a download. This is nonblocking: the helper's rejection was reproduced, but I did not test an actual OpenClaw deployment on ppc64le or FreeBSD.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 9bfe4e6. _node_bin_dir now uses only the OS. Setup checks the architecture only when it downloads Node. A new test checks Linux/ppc64le with an existing prefix.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-customer Waiting on the original author to respond label Oct 1, 2026
@yuhezhang-ai

Copy link
Copy Markdown
Contributor

/ok to test dda454d

@larroy

larroy commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Model rollout completed at dda454d66 — the ## Rollouts section in the PR body now has the full evidence. Summary:

Host without usable npm (the load-bearing scenario), openclaw_math env, 3 example tasks, qwen3-5-397b-a17b via https://inference-api.nvidia.com/v1:

  1. Incompatible system Node v18.19.1 on PATH — engine check rejects it → private Node 24.21.0 provisioned → openclaw 2026.9.4 npm-installed and verified → all 4 servers healthy → 3/3 rollouts, mean reward 0.33 (real trajectories; verifier verdicts correct).
  2. No node/npm/openclaw anywhere on PATH, cold caches — Node 24.21.0 downloaded from nodejs.org, extracted, same flow → 3/3 rollouts, mean reward 0.67, all finished naturally.

Against the merge-base, the same node-free environment reproduces the reported bug: the old code downloads Node 22.15.0, and openclaw's preinstall aborts on every retry with requires Node >=24.16.0 <25 || >=26.1.0 — detected Node 22.15.0. Base also resolves openclaw@latest → 2026.9.8, the reproducibility hole this PR closes.

Review-thread r4087043384 verified live: old 2026.6.11 installed + OPENCLAW_VERSION=2026.9.4 → reinstall, npm global bin prepended, new launcher selected and reporting 2026.9.4. Compatible system Node 24.18.0 → system npm reused, no private Node download.

Also on head dda454d66: pytest responses_api_agents/openclaw_agent/tests 133 passed; pre-commit run --files on the six changed files passes.

One pre-existing observation (not a regression; identical at 2026.6.11): token usage is 0 because the CLI envelope carries no agentMeta.usage with this provider (old pin: lastCallUsage all-zeros; new pin: no key) — parse_openclaw_output is untouched by this PR.

@yuhezhang-ai

Copy link
Copy Markdown
Contributor

Thanks for adding the rollout validation. The installer fixes and native math results look good.

I also ran additional real tool-use rollout validation at dda454d6, using Qwen3-4B for native math tasks and a public Terminal Bench task inside Enroot. The installation and bundled-runtime reuse checks passed, but the native runs exposed a compatibility issue with the bump to OpenClaw 2026.9.4:

  • OpenClaw stored the conversation history in SQLite, while Gym's session reader searches JSONL files.
  • In one math rollout, eight tool calls and their results were present in OpenClaw's records. After the run timed out, Gym returned an empty assistant message with no tool history, zero usage, finished_naturally=true, and mask_sample=false.
  • A normally completed text-only rollout preserved its answer and usage, but still reported agent_transcript_unavailable.

This goes beyond the zero-token accounting issue noted in your report. Although the reader code is unchanged, upgrading the dependency changes the format it must read.

Could we either retain the working 2026.6.11 pin for this installer fix, or add support for the new transcript format before upgrading? For the latter, please validate a real tool-using rollout and an interrupted rollout, checking that commands/results are retained and interruption is reported accurately.

I'm holding approval on the version upgrade until that is addressed.

@yaoyu-33 yaoyu-33 removed the needs-review PR is ready for code review and waiting on a reviewer label Oct 6, 2026
…readable yet

OpenClaw 2026.9.4 stores session history in SQLite, which this agent's
JSONL session reader cannot parse: tool-using and interrupted rollouts
lose commands/results from their transcripts, and completed ones report
agent_transcript_unavailable. Keep 2026.6.11 as the default and config
pin, keep the installer machinery version-parameterized (both engine
ranges stay in OPENCLAW_ENGINES_NODE, and the unknown-release fallback
keeps using the newest known range rather than the default's), and
document the constraint in README. SQLite transcript support will be
added separately.

Signed-off-by: Pedro Larroy <[email protected]>
@larroy

larroy commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Pin reverted to 2026.6.11 in 5d354d168 — the version bump is deferred, SQLite transcript support will come later.

What 5d354d168 does:

  • configs/openclaw_agent.yaml and DEFAULT_OPENCLAW_VERSION are back at 2026.6.11. The constant carries a comment explaining why 2026.9.4 is deliberately not the default yet (SQLite session history unreadable by the JSONL reader), so the bump is a one-line flip once the reader supports it.
  • The installer machinery stays version-parameterized: OPENCLAW_ENGINES_NODE keeps both ranges, and the unknown-release fallback now uses a dedicated newest-known constant (_NEWEST_KNOWN_ENGINES_NODE) rather than the default pin's range, so reverting the default didn't weaken that path.
  • README documents the constraint on openclaw_version.
  • OPENCLAW_VERSION still overrides per process, so 2026.9.4 remains reachable for experiments — with the transcript caveat spelled out.

Validation at 5d354d168, on the same node-free host (no node/npm/openclaw on PATH, cold caches): setup provisioned Node 24.21.0 against the >=22.19.0 range of 2026.6.11 and installed exactly 2026.6.11; all four servers healthy. Then the checks you asked for:

  1. Real tool-using rollout — 3 tasks, 3/3 finished, mean reward 0.33, mean turns 3.3. Up to 7 exec calls per trajectory with every command and result retained in the response output, read from the JSONL session transcript. The 1000-digit task: 6 turns, 7 tool calls, correct answer, reward 1.0.
  2. Interrupted rollout — timeout=45 on the hardest task: the partial session was salvaged from disk and the in-flight tool call plus its result are present in the returned output, so commands/results survive interruption.

pytest responses_api_agents/openclaw_agent/tests: 133 passed; pre-commit run --files on the changed files passes.

On the SQLite history support itself: agreed it's needed before any upgrade, and it needs more than a reader swap — the salvage path (_find_partial_session scans for the newest parseable .jsonl), the observability tree discovery, and token usage (2026.9.4's envelope dropped agentMeta.usage entirely) all interact with the format. I'd rather land that as its own PR with its own tool-use + interruption validation than fold it into this installer fix.

@svcnvidia-nemo-ci svcnvidia-nemo-ci removed the waiting-on-customer Waiting on the original author to respond label Oct 6, 2026
@yuhezhang-ai

Copy link
Copy Markdown
Contributor

/ok to test 5d354d1

@yuhezhang-ai yuhezhang-ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rechecked 5d354d1. Retaining OpenClaw 2026.6.11 in both the config and installer default addresses the transcript-format blocker while preserving the runtime fixes. The author's new tool-use and interrupted-rollout validation covers the missing cases.

Independently reran all 133 OpenClaw tests, plus lint and formatting checks on the changed Python files; all passed. No remaining blocking code findings. SQLite transcript support and the version upgrade can follow separately. Merge remains gated on required CI for this head.

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/37537246401

Merged via the queue into NVIDIA-NeMo:main with commit e7b4f07 Oct 6, 2026
42 checks passed

This branch was previously deployed

1 inactive deployment
public — 5d354d16 Deployed Oct 6, 2026 by copy-pr-bot[bot] via release / finalize / notify #4497
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent harnesses and Responses API agent behavior bug Something isn't working community-request Issue reported or requested by someone from the community complexity:medium Single-domain change with interacting parts or a moderate review surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants