From dea94680187b8a8d5d9282655132aa94a3eebf76 Mon Sep 17 00:00:00 2001 From: Apurv Kumaria Date: Thu, 13 Aug 2026 17:12:21 -0700 Subject: [PATCH 1/2] fix(agent): reject ambiguous timeout argv Signed-off-by: Apurv Kumaria --- .../agent/passthrough-dispatch.test.ts | 14 ++++++++++++++ .../sandbox/agent/passthrough-dispatch.ts | 19 ++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/lib/actions/sandbox/agent/passthrough-dispatch.test.ts b/src/lib/actions/sandbox/agent/passthrough-dispatch.test.ts index 65636986b37..abb0909b2df 100644 --- a/src/lib/actions/sandbox/agent/passthrough-dispatch.test.ts +++ b/src/lib/actions/sandbox/agent/passthrough-dispatch.test.ts @@ -176,6 +176,14 @@ describe("requestedAgentTimeoutSeconds", () => { expect(requestedAgentTimeoutSeconds(agent("--timeout=45", "-m", "hi"))).toBe(45); }); + it("reads a timeout after documented boolean and equals-form options (#8723)", () => { + expect( + requestedAgentTimeoutSeconds( + agent("--deliver", "--agent=main", "--json=false", "--timeout", "30"), + ), + ).toBe(30); + }); + it("requests no deadline when the argv carries no --timeout (#8723)", () => { expect(requestedAgentTimeoutSeconds(agent("--agent", "main", "-m", "hi"))).toBeNull(); }); @@ -192,6 +200,12 @@ describe("requestedAgentTimeoutSeconds", () => { expect(requestedAgentTimeoutSeconds(agent("--", "--timeout", "30"))).toBeNull(); }); + it("keeps the host unbounded after an unknown option (#8723)", () => { + const argv = agent("--unknown", "--timeout", "30"); + expect(requestedAgentTimeoutSeconds(argv)).toBeNull(); + expect(agentDispatchDeadlineSeconds(argv)).toBeUndefined(); + }); + it("refuses a value that cannot be a deadline (#8723)", () => { for (const raw of ["-5", "1.5", "abc", "", "1e3"]) { expect(requestedAgentTimeoutSeconds(agent("--timeout", raw))).toBeNull(); diff --git a/src/lib/actions/sandbox/agent/passthrough-dispatch.ts b/src/lib/actions/sandbox/agent/passthrough-dispatch.ts index 8d0359d30b4..123fea76904 100644 --- a/src/lib/actions/sandbox/agent/passthrough-dispatch.ts +++ b/src/lib/actions/sandbox/agent/passthrough-dispatch.ts @@ -331,7 +331,8 @@ export const AGENT_DISPATCH_DEADLINE_BUFFER_SECONDS = 30; * for the same reason. */ export function requestedAgentTimeoutSeconds(argv: readonly string[]): number | null { - for (let index = 0; index < argv.length; index += 1) { + if (argv[0] !== "openclaw" || argv[1] !== "agent") return null; + for (let index = 2; index < argv.length; index += 1) { const arg = argv[index] as string; if (arg === "--") return null; if (arg === "--timeout") return parseDeadlineSeconds(argv[index + 1]); @@ -340,6 +341,22 @@ export function requestedAgentTimeoutSeconds(argv: readonly string[]): number | index += 1; continue; } + const equalsIndex = arg.indexOf("="); + if ( + equalsIndex > 0 && + arg.startsWith("--") && + OPENCLAW_AGENT_VALUE_FLAGS.has(arg.slice(0, equalsIndex)) + ) { + continue; + } + if ( + arg === "--json" || + arg.startsWith("--json=") || + OPENCLAW_AGENT_BOOLEAN_FLAGS.has(arg) + ) { + continue; + } + return null; } return null; } From 4aaaf7c3c2bcf86c05179ae3d26dbd73ac4b2e43 Mon Sep 17 00:00:00 2001 From: Apurv Kumaria Date: Thu, 13 Aug 2026 18:13:17 -0700 Subject: [PATCH 2/2] docs(cli): document ambiguous timeout argv Signed-off-by: Apurv Kumaria --- docs/reference/commands.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/reference/commands.mdx b/docs/reference/commands.mdx index bcf438c9679..5a6174f648e 100644 --- a/docs/reference/commands.mdx +++ b/docs/reference/commands.mdx @@ -1310,6 +1310,7 @@ These leave the OpenShell wait unbounded: - `--timeout 0`. - A value NemoClaw cannot read as a positive whole number of seconds. - An argv without `--timeout`. +- An unrecognized option before `--timeout`, because NemoClaw does not infer a host deadline outside the documented OpenClaw option grammar. - A `--timeout` after the `--` argv terminator, which OpenClaw reads as payload rather than as its own flag. When the captured output reports that the turn's deadline fired, the wrapper replays the partial output and writes deadline guidance to `stderr`.