From 57049f166fae0de237c42484385f7cc512b469d0 Mon Sep 17 00:00:00 2001 From: Jason Ma Date: Tue, 23 Jun 2026 16:37:23 +0800 Subject: [PATCH] fix(cli): print agent wrapper help on bare invocation instead of dispatching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `nemoclaw agent` with no further args cannot succeed in-sandbox (`openclaw agent` requires -m), but the wrapper dispatched into the sandbox anyway — paying sandbox-exec latency and UNDICI setup only to surface the upstream "Missing required option -m" error. Treat a bare no-args invocation like --help: print the wrapper summary locally and return, without an `openshell sandbox exec` round-trip. Fixes #5658 Co-Authored-By: Claude Opus 4.8 (1M context) Signed-off-by: Jason Ma --- src/commands/sandbox/agent.test.ts | 10 ++++++++++ src/commands/sandbox/agent.ts | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/commands/sandbox/agent.test.ts b/src/commands/sandbox/agent.test.ts index 5731ab9a2af..3c62fb32b3f 100644 --- a/src/commands/sandbox/agent.test.ts +++ b/src/commands/sandbox/agent.test.ts @@ -49,4 +49,14 @@ describe("SandboxAgentCommand oclif parse path", () => { await SandboxAgentCommand.run(["--help"], rootDir); expect(runAgentPassthroughMock).not.toHaveBeenCalled(); }); + + it("prints wrapper help and does not dispatch on a bare no-args invocation (#5658)", async () => { + // `nemoclaw agent` with no further args cannot succeed in-sandbox + // (openclaw agent requires -m), so short-circuit to wrapper help locally + // instead of paying sandbox-exec latency to surface an upstream error. + await SandboxAgentCommand.run(["alpha"], rootDir); + expect(runAgentPassthroughMock).not.toHaveBeenCalled(); + const help = logSpy.mock.calls.map((c: unknown[]) => String(c[0])).join("\n"); + expect(help).toMatch(/openclaw agent/); + }); }); diff --git a/src/commands/sandbox/agent.ts b/src/commands/sandbox/agent.ts index 89a4bcc349a..c841c600528 100644 --- a/src/commands/sandbox/agent.ts +++ b/src/commands/sandbox/agent.ts @@ -34,7 +34,11 @@ export default class SandboxAgentCommand extends NemoClawCommand { printAgentPassthroughHelp(); return; } - if (hasAgentPassthroughHelpToken(extraArgs)) { + // A bare ` agent` with no further args cannot succeed in-sandbox + // (`openclaw agent` requires `-m`), so treat it like a help request and + // print the wrapper summary locally instead of paying sandbox-exec latency + // only to surface an upstream "Missing required option -m" error (#5658). + if (extraArgs.length === 0 || hasAgentPassthroughHelpToken(extraArgs)) { printAgentPassthroughHelp(); return; }