Skip to content

fix(cli): drop unsupported --non-interactive flag from openclaw agents delete - #5663

Merged
jyaunches merged 2 commits into
mainfrom
fix/5656-agents-delete-non-interactive
Jun 23, 2026
Merged

jyaunches merged 2 commits into
mainfrom
fix/5656-agents-delete-non-interactive

Conversation

@jason-ma-nv

@jason-ma-nv jason-ma-nv commented Jun 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

openclaw agents delete in OpenClaw 2026.5.27 does not accept --non-interactive (only agents add does), so nemoclaw <name> agents apply failed to remove agents absent from the manifest: the diff/plan was correct ("1 to delete") but the delete invocation exited 1 (OpenClaw does not recognize option "--non-interactive") and the orphan agent was left in place. This drops the unsupported flag from the delete path — --force already makes the delete non-interactive — and extracts the add/delete argv into unit-tested helpers so the per-verb flag contract can't regress.

Related Issue

Fixes #5656

Changes

  • src/lib/actions/sandbox/agents/apply.ts: new pure helpers buildOpenclawAgentAddArgs (keeps --non-interactive, accepted by agents add) and buildOpenclawAgentDeleteArgs (uses --force only, drops --non-interactive); defaultAddAgent/defaultDeleteAgent now use them.
  • src/lib/actions/sandbox/agents/apply.test.ts: regression tests asserting the delete argv is ["openclaw","agents","delete",<id>,"--force"] and never contains --non-interactive, and that the add argv is unchanged.
  • Verified end-to-end on an aarch64 host (OpenClaw 2026.5.27): onboarded a sandbox with a logs-reader sub-agent, confirmed the old openclaw agents delete --non-interactive is rejected, then nemoclaw <name> agents apply -f empty.yaml --yes deleted logs-reader (final agents list shows only main).

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: Jason Ma [email protected]

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Fixed agent deletion to use correct OpenClaw command-line flags, preventing unsupported flag errors.
  • Tests

    • Added validation tests for agent add and delete commands to ensure proper flag configuration.

…s delete

nemoclaw <name> agents apply invoked openclaw agents delete <id> --force
--non-interactive, but OpenClaw 2026.5.27 agents delete does not accept
--non-interactive (only agents add does). The delete exited 1 and the orphan
agent was left in place (#5656). Drop the flag; --force already makes delete
non-interactive.

Extract buildOpenclawAgentAddArgs / buildOpenclawAgentDeleteArgs as pure,
unit-tested helpers so the per-verb flag contract is guarded against regression.

Fixes #5656

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Jason Ma <[email protected]>
@jason-ma-nv jason-ma-nv self-assigned this Jun 23, 2026
@coderabbitai

coderabbitai Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 424a79f8-cb5e-450d-9827-daca5d75dc3a

📥 Commits

Reviewing files that changed from the base of the PR and between a9f31e4 and 285abc1.

📒 Files selected for processing (2)
  • src/lib/actions/sandbox/agents/apply.test.ts
  • src/lib/actions/sandbox/agents/apply.ts

📝 Walkthrough

Walkthrough

Two exported helper functions, buildOpenclawAgentAddArgs and buildOpenclawAgentDeleteArgs, are extracted in apply.ts to centralize OpenClaw CLI flag construction. The delete helper now uses --force instead of the unsupported --non-interactive flag. Both defaultAddAgent and defaultDeleteAgent are updated to call these helpers. New tests verify the exact argv output for both helpers.

OpenClaw agent argv fix

Layer / File(s) Summary
buildOpenclawAgentAddArgs and buildOpenclawAgentDeleteArgs helpers with callers
src/lib/actions/sandbox/agents/apply.ts
Adds exported buildOpenclawAgentAddArgs (emits --non-interactive, optional --workspace) and buildOpenclawAgentDeleteArgs (emits --force, omits --non-interactive). defaultAddAgent and defaultDeleteAgent are updated to call the respective helpers instead of constructing argument arrays inline.
argv tests for both helpers
src/lib/actions/sandbox/agents/apply.test.ts
Imports the two new helpers and adds a describe("openclaw agents argv (#5656)") block asserting delete args include --force and never --non-interactive, while add args always include --non-interactive and conditionally include --workspace.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hop hop, the flag was wrong,
--non-interactive did not belong!
Now --force leads the delete command's way,
And agents vanish as the manifests say.
The rabbit fixed the CLI with glee,
No unsupported flags — just harmony! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: removing the unsupported --non-interactive flag from the OpenClaw agents delete command.
Linked Issues check ✅ Passed The PR fully addresses issue #5656 by removing the unsupported --non-interactive flag from delete commands and refactoring argv construction into tested helper functions to prevent regression.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the OpenClaw agents delete incompatibility: new helper functions for add/delete args, test coverage, and no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/5656-agents-delete-non-interactive

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

@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/5656-agents-dele... 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/5656-agents-dele... 5f8755e +/-
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/5656-agents-dele... 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/5656-agents-dele... 5f8755e +/-
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 17:05 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@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: sessions-agents-cli-e2e

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): Required because this PR changes live OpenClaw agent lifecycle argv handling. This job onboards a real sandbox and verifies host-side sessions/agents CLI flows, including secondary agent add/list/delete through the in-sandbox OpenClaw CLI.

Optional E2E

  • sessions-agents-cli-e2e (medium): Optional legacy script coverage for the same sessions/agents CLI surface. Useful if maintainers want parity with the nightly script path, but redundant with the newer vitest scenario for merge blocking.

New E2E recommendations

  • OpenClaw agents apply (high): No existing E2E found that directly runs nemoclaw <sandbox> agents apply <manifest> against a live OpenClaw sandbox and verifies that removing an agent from the manifest deletes it successfully. The current required job covers add/list/delete passthrough, but not the apply-specific diff and delete argv path changed here.
    • Suggested test: Add a live agents-apply scenario that onboards an OpenClaw sandbox, applies a manifest adding a secondary agent, then applies a manifest omitting that agent and asserts openclaw agents list --json no longer includes it.

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 E2E scenario is required: this PR changes the sandbox agents apply implementation and its unit test outside test/e2e-scenario/, and the current Vitest scenario workflow does not expose a focused live scenario that directly exercises nemoclaw <sandbox> agents apply deletion argv handling.

Optional Vitest E2E scenarios

  • None.

Relevant changed files

  • None.

@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 · 1 test follow-up
Since last review: 0 prior items resolved · 1 still applies · 0 new items found

Action checklist

  • PRA-T1 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: on an OpenClaw 2026.5.27 sandbox with an existing `logs-reader` secondary agent, run `nemoclaw <name> agents apply -f empty.yaml --yes` and verify the delete invocation succeeds with `openclaw agents delete logs-reader --force` and the final `agents list` contains only `main`.. Unit coverage is sufficient for the local argv construction and orchestration contract, but the changed behavior ultimately crosses the OpenShell/OpenClaw runtime boundary and affects final in-sandbox roster state.

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.

@jason-ma-nv

Copy link
Copy Markdown
Collaborator Author

Fixes #5656. Credit to @abhi-0906 for the confirmed root-cause diagnosis (defaultDeleteAgent passing --non-interactive, which OpenClaw 2026.5.27's agents delete rejects — only agents add accepts it). @abhi-0906 had noted a fix PR would follow; I opened this so it isn't blocked — please review or take it over, glad to defer.

Change: drop --non-interactive from the delete path (--force already makes it unattended); extract buildOpenclawAgentAddArgs / buildOpenclawAgentDeleteArgs as pure, unit-tested helpers guarding the per-verb flag contract. (The existing apply tests mock deleteAgent, so they never exercised the real argv — which is why the bug slipped through.)

Host verification (aarch64, OpenClaw 2026.5.27): onboarded a sandbox with a logs-reader sub-agent → confirmed the old openclaw agents delete --non-interactive is rejected → ran the fixed nemoclaw <name> agents apply -f empty.yaml --yes → logs-reader deleted, final agents list shows only main.

CI is green and CodeRabbit reported no actionable comments.

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

Copy link
Copy Markdown
Contributor

Vitest E2E Scenario Results — ✅ All requested jobs passed

Run: 28043313034
Workflow ref: fix/5656-agents-delete-non-interactive
Requested scenarios: (default — all supported)
Requested jobs: sessions-agents-cli-vitest
Summary: 1 passed, 0 failed, 0 cancelled, 0 skipped

Job Result
sessions-agents-cli-vitest ✅ success

@jyaunches jyaunches 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.

Approved: CI is green, required sessions-agents-cli-vitest passed on current HEAD, and the PR Review Advisor has no blocking findings.

@jyaunches
jyaunches merged commit ee0725a into main Jun 23, 2026
109 checks passed
@jyaunches
jyaunches deleted the fix/5656-agents-delete-non-interactive branch June 23, 2026 18:22
@wscurran wscurran added the NV QA Bugs found by the NVIDIA QA Team label Jun 26, 2026
cv pushed a commit that referenced this pull request Jul 8, 2026
## Summary
- harden `agents apply` parsing of `openclaw agents list --json` output
- tolerate leading warning/banner text before the JSON payload
- accept both the current bare array shape and a future `{ "agents":
[...] }` wrapper while preserving existing id filtering

## Related Issue
Related to #5656 follow-up discussion: the main delete-path bug is
covered by #5663; this PR handles the parser hardening that was
explicitly left for a separate change.

## Verification
- [x] `npm test -- src/lib/actions/sandbox/agents/apply.test.ts`
- [x] `npm run lint -- src/lib/actions/sandbox/agents/apply.ts
src/lib/actions/sandbox/agents/apply.test.ts` (passes; existing
unrelated `child-exit-tracker.test.ts` unused suppression warning
remains)
- [x] `npm run build:cli`
- [x] `npm run typecheck:cli`
- [x] `git diff --check`

Signed-off-by: WilliamK112
<[email protected]>

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

## Summary by CodeRabbit

* **Bug Fixes**
* Improved robustness of agent list retrieval to handle responses with
leading text and various JSON formats.

* **Tests**
* Added comprehensive test suite verifying agent list parsing handles
edge cases and multiple response formats.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: WilliamK112 <[email protected]>
Co-authored-by: cjagwani <[email protected]>
Hadar301 pushed a commit to Hadar301/NemoClaw-OpenShift that referenced this pull request Jul 12, 2026
## Summary
- harden `agents apply` parsing of `openclaw agents list --json` output
- tolerate leading warning/banner text before the JSON payload
- accept both the current bare array shape and a future `{ "agents":
[...] }` wrapper while preserving existing id filtering

## Related Issue
Related to NVIDIA#5656 follow-up discussion: the main delete-path bug is
covered by NVIDIA#5663; this PR handles the parser hardening that was
explicitly left for a separate change.

## Verification
- [x] `npm test -- src/lib/actions/sandbox/agents/apply.test.ts`
- [x] `npm run lint -- src/lib/actions/sandbox/agents/apply.ts
src/lib/actions/sandbox/agents/apply.test.ts` (passes; existing
unrelated `child-exit-tracker.test.ts` unused suppression warning
remains)
- [x] `npm run build:cli`
- [x] `npm run typecheck:cli`
- [x] `git diff --check`

Signed-off-by: WilliamK112
<[email protected]>

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

## Summary by CodeRabbit

* **Bug Fixes**
* Improved robustness of agent list retrieval to handle responses with
leading text and various JSON formats.

* **Tests**
* Added comprehensive test suite verifying agent list parsing handles
edge cases and multiple response formats.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: WilliamK112 <[email protected]>
Co-authored-by: cjagwani <[email protected]>
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

Development

Successfully merging this pull request may close these issues.

[Linux][Agent&Skills] nemoclaw agents apply does not remove agents absent from manifest

3 participants