Skip to content

fix(sandbox): pre-validate agent passthrough selector and phase - #5671

Merged
jyaunches merged 11 commits into
mainfrom
fix/agent-passthrough-selector-and-phase-guards
Jun 25, 2026
Merged

fix(sandbox): pre-validate agent passthrough selector and phase#5671
jyaunches merged 11 commits into
mainfrom
fix/agent-passthrough-selector-and-phase-guards

Conversation

@laitingsheng

@laitingsheng laitingsheng commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

nemoclaw <name> agent deferred selector and phase validation to upstream OpenClaw and to openshell sandbox exec. Upstream OpenClaw exits 0 on its "No target session selected" path, so the wrapper inherited the wrong exit code; the phase rejection from openshell lacked the documented NemoClaw recovery commands. Both are now pre-validated host-side in the agent passthrough.

Related Issue

Fixes #5653
Fixes #5655

Changes

  • src/lib/actions/sandbox/agent/passthrough.ts: reject with exit 2 and No target session selected when none of --agent, --session-id, --session-key, --to (bare or --flag=value) is present in extraArgs; reject with exit 1 and recovery hints (recover, rebuild --yes, onboard --resume) when the resolved sandbox phase is neither Ready nor Running.
  • src/lib/actions/sandbox/agent/passthrough.test.ts: cover both new guards (no-selector, empty extraArgs, --flag=value form, non-Ready phase, no-phase-output passthrough); update prior selector-less tests to include a selector.
  • docs/reference/commands.mdx: document the host-side validation block under $$nemoclaw <name> agent.

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

  • PR description includes the DCO sign-off declaration and every commit appears as Verified in GitHub
  • Git hooks passed during commit and push, or npx prek run --from-ref main --to-ref HEAD passes
  • Targeted tests pass for changed behavior
  • Full npm test passes (broad runtime changes only)
  • Tests added or updated for new or changed behavior
  • No secrets, API keys, or credentials committed
  • Docs updated for user-facing behavior changes
  • npm run 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)

Signed-off-by: Tinson Lai tinsonl@nvidia.com

Summary by CodeRabbit

  • Improvements
    • Updated sandbox agent passthrough to require at least one target selector flag (--agent, --session-id, --session-key, or --to); missing selectors exit with code 2 with “No target session selected”.
    • Added sandbox phase gating: if the sandbox isn’t Ready/Running, it exits with code 1 and prints recovery guidance (recover, rebuild --yes, onboard --resume).
  • Tests
    • Expanded passthrough tests for selector validation (including --flag=value forwarding) and phase-dependent exit behavior.
  • Documentation
    • Refreshed sandbox agent help and reference examples to emphasize selector-based usage and supported flag formats.

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds two host-side validation guards to runAgentPassthrough before dispatching to the in-sandbox OpenClaw command: it exits with code 2 if extraArgs contains no target selector flag (--agent, --session-id, --session-key, --to), and exits with code 1 with recovery command hints if ensureLive returns a sandbox phase other than Ready or Running. Tests and documentation are updated accordingly.

Changes

Agent Passthrough Host-Side Validation

Layer / File(s) Summary
Selector and phase guard logic
src/lib/actions/sandbox/agent/passthrough.ts
Imports CLI_NAME and parseSandboxPhase; adds a target-selector flag list and two rejection helpers; modifies runAgentPassthrough to reject early on missing selector (exit 2) and to parse the phase from ensureLive's return value and reject non-Ready/Running phases (exit 1) with documented recovery commands.
Test coverage and help text
src/lib/actions/sandbox/agent/passthrough.test.ts, src/lib/actions/sandbox/agent/passthrough-help.ts
Updates ensureLiveMock default to return { output: "Phase: Ready" }; adjusts the registry-miss test to pass --agent main; adds exit-2 cases for missing and empty selectors; adds exit-1 phase-gating case with recovery-hint assertions; adds --flag=value forwarding and no-output success cases; inserts selector requirement and error-exit behavior into passthrough help output.
User-facing documentation and examples
docs/reference/commands.mdx, src/commands/sandbox/agent.ts
Documents the required "at least one selector" contract and explicit pre-dispatch validation behavior (exit 2 for missing selector, exit 1 with recovery commands for non-Ready phases) in the commands reference; updates command examples to showcase selector-focused usage.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • #5653 — The PR directly addresses this by adding a host-side selector-presence check that exits with code 2 and prints No target session selected before any sandbox dispatch, preventing the upstream OpenClaw exit-0 behavior from being inherited.
  • #5655 — The PR directly addresses this by checking the sandbox phase after ensureLive and emitting recover, rebuild --yes, and onboard --resume recovery commands in the exit-1 error output when the sandbox is not in Ready or Running.

Poem

🐇 Hop hop, no more silent zeros sneak by,
The wrapper now checks before it will try.
"No selector? Exit two!" the rabbit declares,
"Wrong phase? Here's recover — someone cares!"
With hints and with codes, the path is now clear,
🥕 A well-guarded agent brought joy this year!

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(sandbox): pre-validate agent passthrough selector and phase' directly and specifically describes the main changes in the PR—adding pre-validation for both target selectors and sandbox phases.
Linked Issues check ✅ Passed The PR fully addresses both linked issues: #5653 (incorrect exit 0 for missing selectors) is fixed by the target-selector guard with exit code 2, and #5655 (missing recovery hints on non-Ready phase) is fixed by the phase guard with recovery command output.
Out of Scope Changes check ✅ Passed All changes are tightly scoped to the agent passthrough validation requirements: documentation updates clarify the selector/phase behavior, code implements the two validation guards, and tests verify the new logic without introducing unrelated modifications.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/agent-passthrough-selector-and-phase-guards

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

@github-actions

Copy link
Copy Markdown
Contributor

@github-code-quality

github-code-quality Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in the fix/agent-passthroug... branch is 96%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main fix/agent-passthroug... c5c991c +/-
nemoclaw/src/se...cret-scanner.ts 100%
nemoclaw/src/commands/slash.ts 100%
nemoclaw/src/li...bprocess-env.ts 100%
nemoclaw/src/bl...eprint/state.ts 98%
nemoclaw/src/onboard/config.ts 98%
nemoclaw/src/bl...int/snapshot.ts 97%
nemoclaw/src/bl...print/runner.ts 95%
nemoclaw/src/co...ration-state.ts 94%
nemoclaw/src/bl...ate-networks.ts 94%
nemoclaw/src/index.ts 94%

TypeScript / code-coverage/cli

The overall coverage in the fix/agent-passthroug... branch is 46%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main fix/agent-passthroug... c5c991c +/-
src/lib/state/o...oard-session.ts 91%
src/lib/inference/local.ts 76%
src/lib/sandbox/config.ts 72%
src/lib/actions...dbox/rebuild.ts 67%
src/lib/onboard/preflight.ts 64%
src/lib/actions...licy-channel.ts 56%
src/lib/state/sandbox.ts 55%
src/lib/onboard...er-gpu-patch.ts 50%
src/lib/policy/index.ts 49%
src/lib/onboard.ts 18%

Updated June 23, 2026 18:12 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@laitingsheng laitingsheng added integration: openclaw OpenClaw integration behavior area: cli Command line interface, flags, terminal UX, or output bug-fix PR fixes a bug or regression labels Jun 23, 2026
@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — No blocking findings

Merge posture: No blocking advisor findings
Primary next action: Add or justify PRA-T1 and any related test follow-ups.
Open items: 0 required · 0 warnings · 0 suggestions · 4 test follow-ups
Since last review: 1 prior item resolved · 0 still apply · 0 new items found

Action checklist

  • PRA-T1 Add or justify test follow-up: Runtime validation
  • PRA-T2 Add or justify test follow-up: Runtime validation
  • PRA-T3 Add or justify test follow-up: Runtime validation
  • PRA-T4 Add or justify test follow-up: Runtime validation
Test follow-ups to resolve or justify

If these cover changed behavior, prefer adding them in this PR; otherwise state why existing coverage is enough or link the follow-up.

  • PRA-T1 Runtime validation — Runtime validation: Ready OpenClaw sandbox, `nemoclaw <name> agent -m hi` exits 2 with `No target session selected` and does not invoke the remote OpenClaw agent command.. Unit coverage is strong for local guard decisions and no-dispatch boundaries, but the changed behavior crosses oclif `strict=false` argv capture, wrapper help interception, real OpenShell phase output formatting, `process.exit`, and the actual `openshell sandbox exec` boundary.
  • PRA-T2 Runtime validation — Runtime validation: Ready or Running OpenClaw sandbox, `nemoclaw <name> agent --session-key=<key> --json -m ping` reaches `openshell sandbox exec --no-tty -- openclaw agent ...` and forwards the OpenClaw argv verbatim.. Unit coverage is strong for local guard decisions and no-dispatch boundaries, but the changed behavior crosses oclif `strict=false` argv capture, wrapper help interception, real OpenShell phase output formatting, `process.exit`, and the actual `openshell sandbox exec` boundary.
  • PRA-T3 Runtime validation — Runtime validation: Stopped or Error-phase OpenClaw sandbox, `nemoclaw <name> agent -m ping` exits 1 with `recover`, `rebuild --yes`, and `onboard --resume` guidance before selector rejection.. Unit coverage is strong for local guard decisions and no-dispatch boundaries, but the changed behavior crosses oclif `strict=false` argv capture, wrapper help interception, real OpenShell phase output formatting, `process.exit`, and the actual `openshell sandbox exec` boundary.
  • PRA-T4 Runtime validation — Runtime validation: wrapper help boundary, `nemoclaw <name> agent --help` prints wrapper help, while `nemoclaw <name> agent -- --help` does not trigger wrapper help and reaches local validation after the live-state check.. Unit coverage is strong for local guard decisions and no-dispatch boundaries, but the changed behavior crosses oclif `strict=false` argv capture, wrapper help interception, real OpenShell phase output formatting, `process.exit`, and the actual `openshell sandbox exec` boundary.

Workflow run details

This is an automated, non-binding review; it still expects maintainers and agents to respond to each required or warning item. Treat suggestions as current-PR improvements when they touch changed code; defer only with maintainer rationale or a linked follow-up. A human maintainer must make the final merge decision.

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

E2E Advisor Recommendation

Required E2E: sessions-agents-cli-vitest
Optional E2E: full-e2e-vitest, agent-turn-latency-vitest

Dispatch hint: sessions-agents-cli-vitest

Workflow run

Full advisor summary

E2E Recommendation Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E

  • sessions-agents-cli-vitest (medium): Closest existing live coverage for host-side OpenClaw sessions/agents CLI behavior: it onboards a real OpenClaw sandbox, exercises CLI argv translation, gateway dispatch, pairing/scope approval, JSON handling, and agent/session lifecycle operations adjacent to the changed agent wrapper.

Optional E2E

  • full-e2e-vitest (medium): Optional broad confidence that install/onboard, sandbox readiness, exec/connect-adjacent operations, and an OpenClaw-mediated live agent turn still work after changes to sandbox agent-facing CLI code.
  • agent-turn-latency-vitest (high): Optional high-cost validation of real OpenClaw and Hermes model-backed turns. Useful if maintainers want extra confidence in assistant runtime behavior, but it does not directly exercise the host-side nemoclaw <name> agent wrapper changed here.

New E2E recommendations

  • OpenClaw agent passthrough CLI (high): No existing live E2E appears to exercise nemoclaw <name> agent directly; adjacent tests use nemoclaw <name> exec -- openclaw agent ... or direct SSH/OpenShell paths. This PR changes exactly the host wrapper contract.
    • Suggested test: Add a live E2E for nemoclaw <name> agent covering: selector-required exit 2 without sandbox dispatch on a Ready sandbox, successful forwarding with --agent main or --session-key=..., Hermes sandbox rejection with port 8642 guidance, and non-Ready phase rejection with recover, rebuild --yes, and onboard --resume hints.

Dispatch hint

  • Workflow: .github/workflows/e2e-vitest-scenarios.yaml
  • jobs input: sessions-agents-cli-vitest

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Vitest E2E Scenario Recommendation

Required Vitest E2E scenarios: None
Optional Vitest E2E scenarios: None

Workflow run

Full Vitest E2E advisor summary

Vitest E2E Scenario Advisor

Base: origin/main
Head: HEAD
Confidence: medium

Required Vitest E2E scenarios

  • None. No Vitest scenario dispatch is required: this PR changes host-side sandbox agent passthrough source/docs/unit coverage, but no files under test/e2e-scenario or e2e-vitest-scenarios.yaml changed, and the current Vitest scenario workflow does not have a typed scenario or wired free-standing live job that directly exercises the nemoclaw <name> agent / sandbox agent wrapper. Existing agent-adjacent jobs exercise in-sandbox OpenClaw turns or plural sessions/agents commands, so they are not proof for this changed surface.

Optional Vitest E2E scenarios

  • None.

Relevant changed files

  • None.

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
docs/reference/commands.mdx (1)

567-567: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Split this bullet into one sentence per line and remove the double em-dash pattern (LLM pattern detected).

Line 567 currently has two sentences on the same source line and uses two em dashes in one sentence.
As per path instructions, “One sentence per line in source (makes diffs readable)” and “Excessive em dashes... should be flagged.”

🤖 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 `@docs/reference/commands.mdx` at line 567, The bullet point on line 567 in
docs/reference/commands.mdx contains two sentences on a single line and uses a
double em-dash pattern (em-dash before and after a phrase). Split this into two
separate lines with one sentence per line and replace the double em-dash pattern
with standard punctuation or restructure the sentence to avoid the double
em-dash (which is detected as an LLM pattern). The first sentence should cover
the target selector flags and their format, and the second sentence should cover
the behavior of invocations without a selector.

Source: Path instructions

🤖 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 `@docs/reference/commands.mdx`:
- Line 567: The bullet point on line 567 in docs/reference/commands.mdx contains
two sentences on a single line and uses a double em-dash pattern (em-dash before
and after a phrase). Split this into two separate lines with one sentence per
line and replace the double em-dash pattern with standard punctuation or
restructure the sentence to avoid the double em-dash (which is detected as an
LLM pattern). The first sentence should cover the target selector flags and
their format, and the second sentence should cover the behavior of invocations
without a selector.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: eb30afe6-2e0d-4e6f-8e2e-18d4fce68e0a

📥 Commits

Reviewing files that changed from the base of the PR and between a9f31e4 and 8dc3320.

📒 Files selected for processing (3)
  • docs/reference/commands.mdx
  • src/lib/actions/sandbox/agent/passthrough.test.ts
  • src/lib/actions/sandbox/agent/passthrough.ts

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
src/lib/actions/sandbox/agent/passthrough-help.ts (1)

26-33: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider keeping the error message on a single line for clarity.

The backtick-quoted error message "No target session selected" is split across two console.log calls (lines 30-32), which makes it harder to read in the printed output. Consider restructuring to keep the complete message on one line.

📝 Proposed fix to improve readability
   console.log(
     "  Every invocation must include exactly one target selector — --agent, --session-id,",
   );
   console.log(
-    "  --session-key, or --to. Invocations without a selector exit 2 with `No target session",
+    "  --session-key, or --to. Invocations without a selector exit 2 with",
   );
-  console.log("  selected` before any in-sandbox dispatch runs.");
+  console.log(
+    "  `No target session selected` before any in-sandbox dispatch runs.",
+  );
   console.log("");
🤖 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/actions/sandbox/agent/passthrough-help.ts` around lines 26 - 33, The
error message "No target session selected" is currently split across two
separate console.log statements (one ending with "No target session" and the
next starting with "selected"), which breaks readability in the printed output.
Consolidate the two console.log calls on lines 31 and 33 into a single
console.log statement that keeps the complete quoted message "No target session
selected" together on one line while maintaining the descriptive context around
it.
🤖 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 `@src/lib/actions/sandbox/agent/passthrough-help.ts`:
- Around line 26-33: The error message "No target session selected" is currently
split across two separate console.log statements (one ending with "No target
session" and the next starting with "selected"), which breaks readability in the
printed output. Consolidate the two console.log calls on lines 31 and 33 into a
single console.log statement that keeps the complete quoted message "No target
session selected" together on one line while maintaining the descriptive context
around it.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 00795fa4-cfd8-4f35-8d61-1cc66fdebda0

📥 Commits

Reviewing files that changed from the base of the PR and between f90400f and 6ef1c55.

📒 Files selected for processing (5)
  • docs/reference/commands.mdx
  • src/commands/sandbox/agent.ts
  • src/lib/actions/sandbox/agent/passthrough-help.ts
  • src/lib/actions/sandbox/agent/passthrough.test.ts
  • src/lib/actions/sandbox/agent/passthrough.ts
✅ Files skipped from review due to trivial changes (1)
  • src/commands/sandbox/agent.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • docs/reference/commands.mdx
  • src/lib/actions/sandbox/agent/passthrough.ts
  • src/lib/actions/sandbox/agent/passthrough.test.ts

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
Signed-off-by: Tinson Lai <tinsonl@nvidia.com>

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lib/actions/sandbox/agent/passthrough-help.ts (1)

27-32: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Clarify selector exit-code wording for non-Ready sandboxes

This text implies missing selector always exits 2, but runtime checks phase first and exits 1 on non-Ready/Running states. Please scope the sentence so it matches actual behavior (e.g., “on Ready/Running sandboxes”).

Suggested wording
-    "  --session-key, or --to. Invocations without a selector exit 2 with `No target session",
+    "  --session-key, or --to. On Ready/Running sandboxes, invocations without a selector exit 2 with `No target session",
🤖 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/actions/sandbox/agent/passthrough-help.ts` around lines 27 - 32, The
console.log statements describing the selector validation behavior (lines 27-32)
incorrectly imply that missing selectors always exit with code 2, but this only
occurs on Ready/Running sandboxes since runtime checks happen first and exit
with code 1 for non-Ready states. Update the help text in these console.log
calls to clarify that the exit code 2 behavior with "No target session selected"
only applies when the sandbox is in a Ready or Running state, to match the
actual runtime behavior.
🤖 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/actions/sandbox/agent/passthrough-help.ts`:
- Around line 27-32: The console.log statements describing the selector
validation behavior (lines 27-32) incorrectly imply that missing selectors
always exit with code 2, but this only occurs on Ready/Running sandboxes since
runtime checks happen first and exit with code 1 for non-Ready states. Update
the help text in these console.log calls to clarify that the exit code 2
behavior with "No target session selected" only applies when the sandbox is in a
Ready or Running state, to match the actual runtime behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0be6a9c3-d8e2-4fad-8753-6d25ff6001d5

📥 Commits

Reviewing files that changed from the base of the PR and between 6ef1c55 and 51c2ef3.

📒 Files selected for processing (3)
  • docs/reference/commands.mdx
  • src/lib/actions/sandbox/agent/passthrough-help.ts
  • src/lib/actions/sandbox/agent/passthrough.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • docs/reference/commands.mdx
  • src/lib/actions/sandbox/agent/passthrough.test.ts

…in boundary comment

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
…tes phase precedence

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
…ream argv boundary

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
…f silent passthrough

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
…ot tolerant path

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>

@prekshivyas prekshivyas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

CI green, parseSandboxPhase confirmed pre-existing on main at state/gateway.ts:189. Phase-before-selector ordering is correct and tested with the literal #5655 agent -m ping reproducer. -- boundary handling is correct and tested. Fail-closed on unparseable phase is the right defensive choice. Docs and examples updated consistently.

@jyaunches jyaunches added v0.0.69 and removed v0.0.68 labels Jun 25, 2026
@jyaunches
jyaunches merged commit 133a4f2 into main Jun 25, 2026
41 checks passed
@jyaunches
jyaunches deleted the fix/agent-passthrough-selector-and-phase-guards branch June 25, 2026 20:26
@wscurran wscurran added the NV QA Bugs found by the NVIDIA QA Team label Jun 26, 2026
Hadar301 pushed a commit to Hadar301/NemoClaw-OpenShift that referenced this pull request Jul 12, 2026
…IA#5671)

## Summary

`nemoclaw <name> agent` deferred selector and phase validation to
upstream OpenClaw and to `openshell sandbox exec`. Upstream OpenClaw
exits `0` on its "No target session selected" path, so the wrapper
inherited the wrong exit code; the phase rejection from openshell lacked
the documented NemoClaw recovery commands. Both are now pre-validated
host-side in the agent passthrough.

## Related Issue

Fixes NVIDIA#5653
Fixes NVIDIA#5655

## Changes

- `src/lib/actions/sandbox/agent/passthrough.ts`: reject with exit `2`
and `No target session selected` when none of `--agent`, `--session-id`,
`--session-key`, `--to` (bare or `--flag=value`) is present in
`extraArgs`; reject with exit `1` and recovery hints (`recover`,
`rebuild --yes`, `onboard --resume`) when the resolved sandbox phase is
neither `Ready` nor `Running`.
- `src/lib/actions/sandbox/agent/passthrough.test.ts`: cover both new
guards (no-selector, empty extraArgs, `--flag=value` form, non-Ready
phase, no-phase-output passthrough); update prior selector-less tests to
include a selector.
- `docs/reference/commands.mdx`: document the host-side validation block
under `$$nemoclaw <name> agent`.

## Type of Change

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

## Verification

- [x] PR description includes the DCO sign-off declaration and every
commit appears as `Verified` in GitHub
- [x] Git hooks passed during commit and push, or `npx prek run
--from-ref main --to-ref HEAD` passes
- [x] Targeted tests pass for changed behavior
- [ ] Full `npm test` passes (broad runtime changes only)
- [x] Tests added or updated for new or changed behavior
- [x] No secrets, API keys, or credentials committed
- [x] Docs updated for user-facing behavior changes
- [ ] `npm run docs` builds without warnings (doc changes only)
- [ ] Doc pages follow the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md)
(doc changes only)
- [ ] New doc pages include SPDX header and frontmatter (new pages only)

---
Signed-off-by: Tinson Lai <tinsonl@nvidia.com>

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Improvements**
* Updated `sandbox agent` passthrough to require at least one target
selector flag (`--agent`, `--session-id`, `--session-key`, or `--to`);
missing selectors exit with code `2` with “No target session selected”.
* Added sandbox phase gating: if the sandbox isn’t `Ready`/`Running`, it
exits with code `1` and prints recovery guidance (`recover`, `rebuild
--yes`, `onboard --resume`).
* **Tests**
* Expanded passthrough tests for selector validation (including
`--flag=value` forwarding) and phase-dependent exit behavior.
* **Documentation**
* Refreshed `sandbox agent` help and reference examples to emphasize
selector-based usage and supported flag formats.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli Command line interface, flags, terminal UX, or output bug-fix PR fixes a bug or regression integration: openclaw OpenClaw integration behavior NV QA Bugs found by the NVIDIA QA Team

Projects

None yet

4 participants