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; }