Skip to content

fix(cli): show the invalid --agent option error in status - #196081

Merged
obviyus merged 3 commits into
openclaw:mainfrom
wangmiao0668000666:fix/status-agent-error
Nov 10, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
wangmiao0668000666:fix/status-agent-error

Conversation

@wangmiao0668000666

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: openclaw status --agent <id> (without --usage) prints only The CLI command failed. For help, run openclaw doctor. instead of the option conflict reason. The real message (--agent is only valid with --usage) was hidden from human output.

User Impact

User impact: status now prints --agent is only valid with --usage (or --agent must not be blank for a blank value) with the same exit code 1. --json output and the exit code are unchanged; no new wording.

Why This Change Was Made

assertStatusUsageAgentScope rejects an --agent selection that does not imply a usage-scoped report by throwing a bare Error, which the CLI failure handler classifies as unexpected and replaces with the generic line in human output. Throwing an ExpectedCliError instead lets the human output carry the option-conflict reason, matching the error-classification contract used by sibling commands.

Evidence

Discriminating regression (src/commands/status-json-command.test.ts): the two existing invalid-selection cases now assert the rejection is an ExpectedCliError with the option message.

  • BASE (throw new Error(...)): 2 tests fail — rejection is a plain Error, not an ExpectedCliError.
  • HEAD (this change): 2/2 tests pass.

Real CLI proof (source entry via node --import tsx src/index.ts, Node 24, isolated HOME), same build with only the throw changed:

Before (base):

$ openclaw status --agent beta
[openclaw] The CLI command failed.
[openclaw] For help, run `openclaw doctor`.

After (head):

$ openclaw status --agent beta
--agent is only valid with --usage

Test-line budget: 3 added lines, allocated in config/test-lines-allocations/status-agent-error.txt.

Maintainer options

Scope and alternatives

Narrow change to one command-option validation plus its regression; JSON schema and exit codes unchanged.

Alternatives considered:

  • Keeping the bare throw: leaves the option-conflict reason hidden in human output.
  • Wrapping at the CLI boundary: the ExpectedCliError contract already exists for exactly this and is what sibling commands use.

status rejects --agent without --usage by throwing a bare Error, which the
CLI failure handler replaces with the generic "The CLI command failed."
line. Throw an ExpectedCliError instead so the human output carries the
option conflict message, matching the error-classification contract used by
other commands.
@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: XS labels Nov 9, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 9, 2026
@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Classify invalid status --agent selections as expected CLI errors so users see the existing validation message.

Example: Run openclaw status --agent beta without --usage.

  • Before: The CLI prints a generic failure and recommends Doctor.
  • After: The CLI prints --agent is only valid with --usage and still exits with code 1.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused fix using the established owner and error contract, supported by discriminating regressions and supplied shipped-launcher proof.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The contributor's follow-up corrects the body's older source-entry description and reports built-launcher execution on Node 24 with isolated HOME: status --agent beta now prints the option conflict, retains exit code 1, and preserves JSON output; production code is unchanged from the previously reviewed head.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Invalid status agent options produce generic failure guidance instead of explaining the option conflict or blank value.
Reason: The change restores the existing expected-error contract without changing accepted inputs, defaults, configuration, or agent selection.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current CLI diagnostic bug with a focused change and no actionable findings; exact-head CI is still pending.

Priority: P2
Reviewed head: f4c9cb790eaaa268fe403cc4e96b9204d1e43b44

Before merge

None.

Findings

None.

Agent review details

How this fits together

The shared status validator receives CLI options before text or JSON status collection, and the root CLI renderer turns its errors into human diagnostics or machine-readable failures.

flowchart TD
  A[Status CLI options] --> B[Shared agent scope validator]
  B --> C[Expected CLI error]
  C --> D[Root failure renderer]
  D --> E[Human diagnostic]
  D --> F[JSON failure envelope]
  B --> G[Valid status collection]
Loading

Technical review

Best possible solution:

Use the existing expected-error helper in the shared validator while preserving selection rules, messages, and validation order.

Do we have a high-confidence way to reproduce the issue?

Current-main validation throws ordinary errors that receive generic human failure framing; the contributor also supplies before/after CLI output, which this read-only review did not rerun.

Is this the best way to solve the issue?

This is the smallest complete fix: retain the shared validation owner and classify its two expected input failures using the existing CLI contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1d36d28610a4.

Provenance checked

  • Usage-only agent selection keeps the original intent (d5c194f: Prevent an agent selector from implying that aggregate status is agent-scoped; the introducing merged PR and patch verify this intent.)
  • Explicit blank agent rejection keeps the original intent (f2ddf6b: Reject explicitly blank selectors before they silently fall back to default-agent usage, preserving no-usage validation precedence.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +1, Tests 0. Total +1 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 3 2 +1
Tests 1 2 2 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 5 4 +1

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: Invalid status options hide actionable guidance, but valid status workflows remain available.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-09T16:09:23.639Z sha 25d0c29 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-09T23:22:57.495Z sha 25d0c29 :: needs maintainer review before merge. :: none

Reviewed November 9, 2026, 7:05 PM ET / November 10, 2026, 00:05 UTC (Revision 3).

@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Real behavior proof now runs through the supported shipped launcher (built dist, node openclaw.mjs, Node 24, isolated HOME): base prints "The CLI command failed." + exit 1; head prints "--agent is only valid with --usage" + exit 1. JSON machine output unchanged.

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 9, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The body's real behavior proof now runs through the built shipped launcher (node openclaw.mjs), not src/index.ts via tsx. Re-review the current head.

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 9, 2026
@obviyus

obviyus commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 10, 2026
@obviyus

obviyus commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

Proof on a built CLI (node openclaw.mjs), node:24.22.1 in secretless Docker, isolated HOME. main 54b8bdac0b6e vs this PR f4c9cb790eaa.

command main PR
status --agent beta stderr The CLI command failed., exit 1 stderr --agent is only valid with --usage, exit 1
status --agent beta --json stdout JSON error (same), stderr generic line, exit 1 stdout JSON error (same), stderr --agent is only valid with --usage, exit 1
status --agent "" --agent is only valid with --usage, exit 1 same
status --usage --agent "" --agent must not be blank, exit 1 same
status --usage --agent main report, exit 0 same
status report, exit 0 same

The blank --agent case already shows the right text on main; the fix matters for --agent without --usage. Removed the test-lines allocation file and kept the test change net zero.

@obviyus
obviyus merged commit 1e09ded into openclaw:main Nov 10, 2026
122 checks passed
@obviyus

obviyus commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

Landed in 1e09ded. Thanks @wangmiao0668000666. status --agent now shows the real option error.

github-actions Bot pushed a commit to kickb1049kickb10492660/openclaw that referenced this pull request Nov 10, 2026
fix(cli): show the invalid --agent option error in status

openclaw status --agent <id> without --usage threw a plain Error, so the CLI showed only the generic "The CLI command failed." line instead of the existing message "--agent is only valid with --usage". The option checks now use the existing throwExpectedCliError, as #196094 did for models status. The exit code and the JSON on stdout are unchanged, and no text is new.

Evidence: built CLIs on node:24.22.1 in secretless Docker with an isolated HOME. status --agent beta printed only the generic failure line on main (exit 1) and the existing option message with this change (exit 1). With --json, stdout and the exit code are the same on both; stderr now carries the option message instead of the generic line. Blank --agent cases, status --usage --agent main and plain status are identical on both. Details: openclaw/openclaw#196081 (comment).

Thanks @wangmiao0668000666.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Nov 10, 2026
…or (#196382)

fix(models): surface the --json/--plain conflict as an ExpectedCliError

openclaw models list --json --plain and models status --json --plain threw a plain Error, so the CLI showed only the generic "The CLI command failed." line instead of the existing message "Choose either --json or --plain, not both." The shared option check now uses ExpectedCliError, as #196094 and #196081 did for related checks. The exit code and the JSON error on stdout are unchanged, and no text is new.

Evidence: built CLIs on node 24.22.1 in secretless Docker with an isolated HOME. Both commands with --json --plain printed only the generic failure line on main (exit 1) and the existing conflict message with this change (exit 1); the JSON error on stdout is byte-identical. list --json, list --plain, status --json, status --plain and status --probe --plain are identical on both. Details: #196382 (comment).

Thanks @wangmiao0668000666.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 10, 2026
…96081)

fix(cli): show the invalid --agent option error in status

openclaw status --agent <id> without --usage threw a plain Error, so the CLI showed only the generic "The CLI command failed." line instead of the existing message "--agent is only valid with --usage". The option checks now use the existing throwExpectedCliError, as openclaw#196094 did for models status. The exit code and the JSON on stdout are unchanged, and no text is new.

Evidence: built CLIs on node:24.22.1 in secretless Docker with an isolated HOME. status --agent beta printed only the generic failure line on main (exit 1) and the existing option message with this change (exit 1). With --json, stdout and the exit code are the same on both; stderr now carries the option message instead of the generic line. Blank --agent cases, status --usage --agent main and plain status are identical on both. Details: openclaw#196081 (comment).

Thanks @wangmiao0668000666.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 10, 2026
…or (openclaw#196382)

fix(models): surface the --json/--plain conflict as an ExpectedCliError

openclaw models list --json --plain and models status --json --plain threw a plain Error, so the CLI showed only the generic "The CLI command failed." line instead of the existing message "Choose either --json or --plain, not both." The shared option check now uses ExpectedCliError, as openclaw#196094 and openclaw#196081 did for related checks. The exit code and the JSON error on stdout are unchanged, and no text is new.

Evidence: built CLIs on node 24.22.1 in secretless Docker with an isolated HOME. Both commands with --json --plain printed only the generic failure line on main (exit 1) and the existing conflict message with this change (exit 1); the JSON error on stdout is byte-identical. list --json, list --plain, status --json, status --plain and status --probe --plain are identical on both. Details: openclaw#196382 (comment).

Thanks @wangmiao0668000666.

Co-authored-by: Ayaan Zaidi <[email protected]>
@wangmiao0668000666
wangmiao0668000666 deleted the fix/status-agent-error branch November 11, 2026 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants