Repository navigation
fix(cli): let nested agent exec --timeout override the parent flag - #125256
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 6:35 PM ET / 22:35 UTC. ClawSweeper reviewWhat this changesThe PR makes an explicit nested Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open: this is a focused, source-supported fix for a current-main nested CLI precedence bug. The contributor addressed the prior proof request with an exact-head real CLI transcript; no blocking correctness finding remains, pending exact-head CI completion. Priority: P2 Review scores
Verification
Live ProofRecorded live on the PR head ( How this fits togetherThe agent CLI parses parent and nested command options, merges them into an isolated embedded-agent request, and passes the selected deadline to execution. This change determines which operator-provided timeout reaches that run. flowchart LR
A[Operator command] --> B[CLI parser]
B --> C[Parent and nested timeout values]
C --> D[Source-aware inheritance]
D --> E[Embedded agent execution]
E --> F[Timeout validation and run]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +3, Tests +29. Total +32 across 2 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Merge after exact-head CI passes, keeping timeout precedence in the existing source-aware helper and its production-parser regression matrix. Do we have a high-confidence way to reproduce the issue? Yes, from source: positional parsing, the current-main merge, and the execution handoff establish the failing both-explicit case; the contributor also supplied an exact-head real CLI transcript. Is this the best way to solve the issue? Yes: this repairs the producer-side option merge with the repository’s shared default-aware inheritance helper rather than adding a downstream timeout workaround. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 27cb5d021fd1. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
@clawsweeper re-review Addressed the Before-merge items on head
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Preserve the contributor's source-aware timeout inheritance while resolving the current main registration-test conflict. Exercise every precedence case through the existing production-equivalent positional Commander harness and retain the current guided-agent creation and failed-agent exit behavior. Co-authored-by: zyw02 <[email protected]>
|
Maintainer verification on refreshed signed contributor head
Fixes #125255. Thanks @zyw02 for the original owner-boundary repair and production-parser regression. |
|
Merged via squash.
|
…penclaw#125256) * fix(cli): let nested agent exec --timeout override the parent flag * fix(cli): keep nested exec --timeout inherit comment to the option-source invariant --------- Co-authored-by: zyw02 <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>

Closes #125255
Before merge (ClawSweeper)
pnpm openclaw agent execon an isolated HOME/state dir, not a mocked executor.What Problem This Solves
Fixes an issue where operators who run
openclaw agent --timeout <parent> exec --timeout <leaf> …would still execute the nested headless turn under the parent deadline. The production CLI enables positional options, so those two flags are distinct values: the parentagent --timeoutis a Gateway/agent-turn override, andexec --timeoutis the isolated embedded-run deadline. When both are written on the same argv (copied parent flags plus an explicit longer exec budget, or a script that tightens only the nested command), the leaf flag was parsed and then discarded.The user-visible symptom is a silently wrong timeout, not a parse error.
agent exec --timeout 120alone works.agent --timeout 30 exec …correctly inherits 30 seconds onto exec because the leaf option defaults to"600". Combining them, which looks like an override, used 30 seconds. That is the worst class of CLI bug for this surface: the command starts, the operator believes they raised the deadline, and the run dies at the parent budget.This is bounded to option merge for
openclaw agent exec. It does not change Gateway RPC timeouts, cron jobs, or exec-tool child process killing.Why This Change Was Made
The exec action merged timeout with
parentOpts?.timeout ?? opts.timeout. That parent-first??exists because the leaf--timeouthas a Commander default of"600", soopts.timeout ?? parentwould never inherit a parent-only flag. The workaround over-corrected: once the parent is set, it always wins, including when the leaf source is"cli".The repo already has the owner for this contract:
inheritOptionFromParentinsrc/cli/command-options.ts. It returns an ancestor value only when the child source is missing or"default". Gateway run options use the same pattern for defaulted children (inherited ?? resolved[key]forwsLog). This patch applies that helper to exec--timeoutand keeps leaf-first??formodel/thinking/messageFile, which have no leaf default.Non-goals: changing the 600s default, changing parent
agent --timeoutunits, rewriting other nested flags, or touchingagentExecCommandtimeout parsing. Invalid--timeoutstrings still fail innormalizeTimeoutSecondsafter merge.User Impact
openclaw agent execnow treats--timeoutthe same way operators already expect from nested Commander flags and from sibling--model/--thinking:exec --timeoutis the deadline for that run.--timeoutis omitted, a parentagent --timeoutstill inherits (scripts can keep putting the flag beforeexec)."600".Operators who already pass only one of the two flags see no behavior change. Operators who pass both get the leaf value they wrote next to
exec, so long isolated turns can actually use the longer budget.Review feedback addressed
ClawSweeper reviewed
5818be1a00126c1310213153bdb37f2dab711ea2and blocked on real CLI proof (mocked parser/executor handoff only), plus keeping the inherit comment as the smallest option-source statement.This revision (
445387f8c168326ce2690da8b330623a680851c0) shortens that comment to two lines and attaches an isolatedpnpm openclawtranscript below. No other nested flags were rewritten.Evidence
Real-behavior proof
Interpretation on exact head
445387f8c168326ce2690da8b330623a680851c0:30is a legal integer. Parent-first??would have accepted it and continued. The run instead rejectednopeinnormalizeTimeoutSecondsbefore a model turn.nopewould have failed timeout validation if inherited. The leaf120passed merge; the later harness error is a prepared-run plugin gap in this isolated checkout, not timeout parsing.--timeoutstill takes a parent CLI value.pnpm openclaw), fail-before-provider for the deadline string. It does not wall-clock a live model cancellation.Evidence scope: production CLI parse + exec timeout normalize. No gateway persistence. Isolated session UUIDs omitted.
Focused regression tests
The new test failed on pre-fix code for the intended reason (
timeout: "30"vs"120") and passes after the owner-boundary repair.Local CI gates (exact tip)
Production LOC vs original base: inherit helper import + two-line invariant comment + source-aware merge (net smaller than the first tip's four-line comment). No new config, env, or protocol surface.
Permalinks:
openclaw/src/cli/program/register.agent-turn.ts
Line 190 in 8cae198
openclaw/src/cli/program/register.agent-turn.ts
Line 193 in 445387f
openclaw/src/cli/command-options.ts
Line 12 in 8cae198
openclaw/src/cli/program/build-program.ts
Line 12 in 8cae198
Remaining Risk
agent exec(--jsonOR-merge,model/thinkingleaf-first) were left as-is because they do not have a leaf default that forces a parent-first??. If a future leaf option gains a default, it should useinheritOptionFromParent, not copy this old timeout merge.agentExecCommandparses invalid timeout strings; those still throw--timeout must be a non-negative integer in secondsafter merge.check-lint-core-5failed on unrelatedsrc/config/sessions/types.tsmax-lines (701). That file is not in this diff; upstreammainalready shortened it. Not repaired here.AI-assisted development
An AI coding assistant drafted the patch, regression test, real-CLI proof, and this description. A human operator is expected to review the inherit behavior against Commander positional options before merge.