fix(onboard): skip OpenClaw base resolution for agents#3858
Conversation
|
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 (2)
📝 WalkthroughWalkthroughcreateSandbox now skips base-image digest resolution and local-registry availability warnings when the Dockerfile was generated by an agent; the default build-context path retains resolution/pinning logic. Two tests verify both agent and non-agent behaviors. ChangesAgent Dockerfile Base Image Handling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
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 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 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/lib/onboard.ts (1)
5171-5451:⚠️ Potential issue | 🟠 Major | ⚡ Quick winReduce this hunk to satisfy the onboard entrypoint growth gate.
CI is currently failing because
src/lib/onboard.tsgrew by net +6 lines. Please trim this change (behavior can stay the same) so the budget check passes.Possible line-neutral rewrite (same behavior)
- let usingAgentDockerfile = false; if (fromDockerfile) { @@ } else if (agent) { const agentBuild = agentOnboard.createAgentSandbox(agent); buildCtx = agentBuild.buildCtx; stagedDockerfile = agentBuild.stagedDockerfile; - usingAgentDockerfile = true; } else { ({ buildCtx, stagedDockerfile } = stageOptimizedSandboxBuildContext(ROOT)); } @@ - const resolved = usingAgentDockerfile + const resolved = agent && !fromDockerfile ? null : pullAndResolveBaseImageDigest({ requireOpenshellSandboxAbi: isLinuxDockerDriverGatewayEnabled(), }); - if (!usingAgentDockerfile) { - if (resolved?.digest) { - console.log(` Pinning base image to ${resolved.digest.slice(0, 19)}...`); - } else if (resolved) { - console.log(` Using sandbox base image ${resolved.ref}`); - } else { + if (resolved?.digest) { + console.log(` Pinning base image to ${resolved.digest.slice(0, 19)}...`); + } else if (resolved) { + console.log(` Using sandbox base image ${resolved.ref}`); + } else if (!(agent && !fromDockerfile)) { // Check if the image exists locally before falling back to unpinned :latest. // On a first-time install behind a firewall with no cached image, warn early // so the user knows the build will likely fail. const localCheck = dockerImageInspect(`${SANDBOX_BASE_IMAGE}:${SANDBOX_BASE_TAG}`, { ignoreError: true, suppressOutput: true, }); if (localCheck.status === 0) { console.warn(" Warning: could not pull base image from registry; using cached :latest."); } else { console.warn( ` Warning: base image ${SANDBOX_BASE_IMAGE}:${SANDBOX_BASE_TAG} is not available locally.`, ); console.warn(" The build will fail unless Docker can pull the image during build."); console.warn(" If offline, pull the image manually first:"); console.warn(` docker pull ${SANDBOX_BASE_IMAGE}:${SANDBOX_BASE_TAG}`); } - } }🤖 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/onboard.ts` around lines 5171 - 5451, The file grew by a few lines in the custom-Dockerfile and cleanup logic — shrink the hunk without changing behavior by collapsing multi-line console logs and small helpers and removing redundant whitespace/comments: inside the fromDockerfile branch compress the three separate console.error/console.warn calls into single concise messages where safe (e.g. the permission/blocking messages and the "move Dockerfile" suggestions), inline the small cleanupCustomBuildCtx arrow into the catch handler (making it a one-liner try/finally usage), and remove extra blank lines around the usingAgentDockerfile assignment and the resolved/pull fallback block; target symbols to change: the fromDockerfile branch (fromResolved/buildContextDir/stagedDockerfile), cleanupCustomBuildCtx, cleanupBuildCtx, usingAgentDockerfile, and the resolved = usingAgentDockerfile ? null : pullAndResolveBaseImageDigest(...) section. Ensure behavior and exit codes remain identical.
🤖 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.
Outside diff comments:
In `@src/lib/onboard.ts`:
- Around line 5171-5451: The file grew by a few lines in the custom-Dockerfile
and cleanup logic — shrink the hunk without changing behavior by collapsing
multi-line console logs and small helpers and removing redundant
whitespace/comments: inside the fromDockerfile branch compress the three
separate console.error/console.warn calls into single concise messages where
safe (e.g. the permission/blocking messages and the "move Dockerfile"
suggestions), inline the small cleanupCustomBuildCtx arrow into the catch
handler (making it a one-liner try/finally usage), and remove extra blank lines
around the usingAgentDockerfile assignment and the resolved/pull fallback block;
target symbols to change: the fromDockerfile branch
(fromResolved/buildContextDir/stagedDockerfile), cleanupCustomBuildCtx,
cleanupBuildCtx, usingAgentDockerfile, and the resolved = usingAgentDockerfile ?
null : pullAndResolveBaseImageDigest(...) section. Ensure behavior and exit
codes remain identical.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 9c2d5632-f728-4d0f-9a94-c27597141cdc
📒 Files selected for processing (2)
src/lib/onboard.tstest/onboard.test.ts
db19946 to
6422e21
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/onboard.test.ts (1)
2249-2255: ⚡ Quick winMake these spawned tests hermetic by stripping messaging env vars.
Both new tests pass
...process.envinto the child process, which can leakDISCORD_*/TELEGRAM_*and activate unrelated channels duringcreateSandbox(). That can make these assertions flaky.Proposed patch
- env: { - ...process.env, + env: { + ...stripMessagingEnv(process.env), HOME: tmpDir, NEMOCLAW_HOME: path.join(tmpDir, ".nemoclaw"), PATH: `${fakeBin}:${process.env.PATH || ""}`, NEMOCLAW_NON_INTERACTIVE: "1", }, @@ - env: { - ...process.env, + env: { + ...stripMessagingEnv(process.env), HOME: tmpDir, NEMOCLAW_HOME: path.join(tmpDir, ".nemoclaw"), PATH: `${fakeBin}:${process.env.PATH || ""}`, NEMOCLAW_NON_INTERACTIVE: "1", },Based on learnings: “ensure spawned helper script does not inherit CI/local messaging credentials/config… delete/remove DISCORD_* and TELEGRAM_* before calling createSandbox().”
Also applies to: 2411-2417
🤖 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 `@test/onboard.test.ts` around lines 2249 - 2255, The spawned test environments leak messaging credentials because the tests spread ...process.env into the child env; before constructing the env object passed to the child (the env literal that includes HOME, NEMOCLAW_HOME, PATH, NEMOCLAW_NON_INTERACTIVE), remove any DISCORD_* and TELEGRAM_* variables so the helper script and createSandbox() cannot pick up CI/local messaging creds; update both the block around the shown env and the similar block used at the other test location (the other spawn/env at the nearby tests) to filter out keys starting with "DISCORD_" and "TELEGRAM_" from process.env when building the child env.
🤖 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.
Nitpick comments:
In `@test/onboard.test.ts`:
- Around line 2249-2255: The spawned test environments leak messaging
credentials because the tests spread ...process.env into the child env; before
constructing the env object passed to the child (the env literal that includes
HOME, NEMOCLAW_HOME, PATH, NEMOCLAW_NON_INTERACTIVE), remove any DISCORD_* and
TELEGRAM_* variables so the helper script and createSandbox() cannot pick up
CI/local messaging creds; update both the block around the shown env and the
similar block used at the other test location (the other spawn/env at the nearby
tests) to filter out keys starting with "DISCORD_" and "TELEGRAM_" from
process.env when building the child env.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 233028e2-0d7d-4ffc-b163-7cd97339bbef
📒 Files selected for processing (2)
src/lib/onboard.tstest/onboard.test.ts
Signed-off-by: Yimo Jiang <yimoj@nvidia.com>
6422e21 to
1a84ce0
Compare
|
✨ Related open issues: |
ericksoa
left a comment
There was a problem hiding this comment.
Approved. Independent adversarial review found no blockers; regression risk is low and the change is scoped to skipping OpenClaw base resolution for agent-staged Dockerfiles while preserving default/custom paths. Validation passed in the review worktree: npm run build:cli, npm run typecheck:cli, focused onboard/base-image Vitest, and git diff --check. Live checks are green on head 1a84ce0.
Summary
Hermes onboarding already stages and resolves its own agent sandbox base image, so the shared sandbox creation path should not also resolve the OpenClaw sandbox base. This PR skips OpenClaw base-image resolution for agent-staged Dockerfiles while preserving default OpenClaw pinning behavior.
Related Issue
Fixes #3645
Changes
createSandboxis using an agent-staged Dockerfile and skips the OpenClawpullAndResolveBaseImageDigest()path for that case.Type of Change
Verification
npx prek run --all-filespassesnpm testpassesmake docsbuilds without warnings (doc changes only)Focused checks run:
npm run build:clipassesnpm run typecheck:clipassesnpx vitest run test/onboard.test.ts -t "skips OpenClaw sandbox-base resolution|keeps resolving the OpenClaw sandbox base image"passesnpx vitest run test/onboard.test.tspassescd nemoclaw && npm install && npm run buildpassesnpx vitest run --project plugin nemoclaw/src/commands/migration-state.test.tspassesnpx vitest run --project cli test/ssrf-parity.test.tspassesBroad checks attempted:
npm testfailed on unrelated setup/broad-suite issues, including missing plugin install/build artifacts beforecd nemoclaw && npm install && npm run build,test/fetch-guard-patch-regression.test.tsexpecting status 0 but receiving 1, and several long-running CLI/e2e test timeouts.npx prek run --all-filesfailed only intest-cli; earlier hook stages, plugin tests, source-shape budget, and skills YAML passed. The failingtest-clicases were unrelated to this change:test/cli.test.tstimeout cases,test/fetch-guard-patch-regression.test.ts, andtest/sandbox-connect-inference.test.tsstatus mismatch.Signed-off-by: Yimo Jiang yimoj@nvidia.com
Summary by CodeRabbit
Bug Fixes
Tests