Skip to content

fix(onboard): propagate context window, max tokens, and reasoning to sandbox image#1956

Open
javlund wants to merge 2 commits intoNVIDIA:mainfrom
javlund:fix-context-window
Open

fix(onboard): propagate context window, max tokens, and reasoning to sandbox image#1956
javlund wants to merge 2 commits intoNVIDIA:mainfrom
javlund:fix-context-window

Conversation

@javlund
Copy link
Copy Markdown

@javlund javlund commented Apr 16, 2026

Summary

The NEMOCLAW_CONTEXT_WINDOW, NEMOCLAW_MAX_TOKENS and NEMOCLAW_REASONING variables were not sent all the way to the openclaw.json file (and thus the agent configuration), I've tried to fix that. As the Dockerfile is altered, this will likely require a sandbox re-creation to kick in.

There were a few tests I couldn't get green as they were timing out, but they don't seem to be related to the files changed in this PR.

Changes

  • adds 3 ARGs to the Dockerfile with the same defaults as before, promotes them to ENV, and the Python script reads from os.environ instead of literals
  • patchStagedDockerfile() in onboard.ts reads the 3 env vars from the host and patches the ARG lines before image build
  • Unit tests to verify

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Verification

  • npx prek run --all-files passes
  • npm test passes
  • Tests added or updated for new or changed behavior
  • No secrets, API keys, or credentials committed
  • Docs updated for user-facing behavior changes
  • make docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

AI Disclosure

  • AI-assisted — tool: GitHub Copilot

Signed-off-by: Jacob Avlund jacob@avlund.dk

Summary by CodeRabbit

  • New Features

    • Context window size, maximum token limits, and reasoning mode can now be configured via environment variables for more flexible deployments.
  • Tests

    • Added automated test coverage to verify environment-based configuration is applied correctly during build staging.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fca1c053-215a-4aec-90cb-700f82994318

📥 Commits

Reviewing files that changed from the base of the PR and between cfe4d69 and ea0d3cf.

📒 Files selected for processing (1)
  • src/lib/onboard.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lib/onboard.ts

📝 Walkthrough

Walkthrough

Added three Nemoclaw build args/env vars—NEMOCLAW_CONTEXT_WINDOW, NEMOCLAW_MAX_TOKENS, NEMOCLAW_REASONING—and threaded them into the generated OpenClaw config. The onboard patcher now validates and injects these values into staged Dockerfiles; a test verifies the behavior.

Changes

Cohort / File(s) Summary
Docker Configuration
Dockerfile
Introduced ARG and ENV for NEMOCLAW_CONTEXT_WINDOW, NEMOCLAW_MAX_TOKENS, NEMOCLAW_REASONING. Python config generation reads context_window and max_tokens from env (with defaults) and converts NEMOCLAW_REASONING string to boolean; replaced previous hard-coded values.
Dockerfile Patching Logic
src/lib/onboard.ts
patchStagedDockerfile() updated to read host process.env for the three NEMOCLAW variables and conditionally replace corresponding ARG defaults in staged Dockerfiles. Validates context/max as positive integers and reasoning as exact "true"/"false" strings; leaves ARG lines unchanged if validations fail.
Tests
test/onboard.test.ts
Added test that sets up a temp staged Dockerfile, mutates process.env values for the three vars, runs patchStagedDockerfile(...), and asserts ARG lines reflect the env-provided values; restores env and cleans up in finally.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I nibbled ARGs in a Dockerfile glade,
Tuned context and tokens, then bravely I bade,
"Reason true or false, the builder decide,"
I hopped, I patched, and watched configs abide. 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically summarizes the main change: propagating three environment variables (context window, max tokens, reasoning) into the sandbox image configuration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/lib/onboard.ts`:
- Around line 1027-1040: POSITIVE_INT_RE currently permits "0", so update the
validation used for contextWindow and maxTokens to only accept positive integers
> 0 (e.g., change POSITIVE_INT_RE to a regex that requires a non-zero leading
digit like /^[1-9][0-9]*$/ or replace the regex check with numeric parsing and a
> 0 check); ensure the same updated validation is applied before calling
dockerfile.replace for NEMOCLAW_CONTEXT_WINDOW and NEMOCLAW_MAX_TOKENS so zero
values are rejected.
🪄 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: Pro Plus

Run ID: 3b708133-f82e-494c-9ea6-bfbead0d0142

📥 Commits

Reviewing files that changed from the base of the PR and between ec4d058 and cfe4d69.

📒 Files selected for processing (3)
  • Dockerfile
  • src/lib/onboard.ts
  • test/onboard.test.ts

Comment thread src/lib/onboard.ts Outdated
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@wscurran wscurran added the fix label Apr 16, 2026
@wscurran
Copy link
Copy Markdown
Contributor

✨ Thanks for submitting this PR that proposes a fix to propagate context window, max tokens, and reasoning to the sandbox image, which could help improve the functionality of NemoClaw.

@wscurran wscurran added the NemoClaw CLI Use this label to identify issues with the NemoClaw command-line interface (CLI). label Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix NemoClaw CLI Use this label to identify issues with the NemoClaw command-line interface (CLI).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants