Skip to content

fix(cli): reject --agent for models fallbacks list and image-fallbacks list - #190482

Closed
yetval wants to merge 1 commit into
openclaw:mainfrom
yetval:fix/cli-models-fallbacks-agent
Closed

yetval wants to merge 1 commit into
openclaw:mainfrom
yetval:fix/cli-models-fallbacks-agent

Conversation

@yetval

@yetval yetval commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Summary

openclaw models --agent ops fallbacks list exits 0 and prints the global agents.defaults.model.fallbacks, not the ops agent's own fallback chain, with no hint that --agent was dropped. models --agent ops image-fallbacks list does the same for image fallbacks. A user checking which fallbacks an agent will use gets a confident, wrong answer whenever that agent has its own model.fallbacks.

The add, remove and clear siblings already reject --agent since #163077, and #106346 was closed with fallback management staying global by design. The two list leaves are the remaining fallback commands that still accept the inherited parent --agent and ignore it.

Root cause

src/cli/models-cli.ts registers the fallback list leaf with the plain runtime wrapper, so the inherited models --agent option is never checked, while the mutation leaves go through the global-only guard:

// before
.action(async (opts) => {
  await withModelsRuntime(async ({ defaultRuntime }) => {
    const { listFallbacksCommand } = await import("../commands/models/fallbacks-shared.js");

listFallbacksCommand only reads cfg.agents?.defaults?.[key], so whatever --agent names, the output is the global list.

Fix

The list leaf now runs through the same withGlobalModelsRuntime guard as add/remove/clear, and GlobalOnlyModelCommandName gains list for both fallback groups:

// after
.action(async (opts, command: Command) => {
  await withGlobalModelsRuntime(command, `${name} list`, async ({ defaultRuntime }) => {
    const { listFallbacksCommand } = await import("../commands/models/fallbacks-shared.js");

docs/cli/models.md lists list alongside add, remove and clear in the global-only sentence.

Why this is the right boundary

rejectAgentScopedModelCommand is the single owner of "this models leaf is global and must not accept --agent"; set, set-image, scan, refresh, all aliases leaves, and the fallback mutations already route through it. Both fallback groups are registered by one loop, so the change covers fallbacks list and image-fallbacks list together. listFallbacksCommand and its output are unchanged; without --agent the command prints exactly what it did before. Per-agent effective fallbacks remain visible through models status --agent <id>, which already resolves them. This does not add per-agent fallback editing or listing.

Verification

  • src/cli/models-cli.test.ts: the existing "rejects unsupported agent scope" table gains models --agent ops fallbacks list and models --agent ops image-fallbacks list --json, asserting exit 1 with models fallbacks list does not support --agent / models image-fallbacks list does not support --agent and that listFallbacksCommand is never called. Run with node scripts/run-vitest.mjs src/cli/models-cli.test.ts: both new cases fail on pristine main (the command resolves instead of rejecting) and the file passes 24/24 with the patch.
  • oxfmt --check clean on the changed files.
  • Local tsgo and oxlint were not run per the contributor workflow for this batch; GitHub Actions covers them.

Real behavior proof

Behavior addressed: openclaw models --agent <id> fallbacks list and image-fallbacks list silently ignored --agent and printed the global defaults as if they were that agent's fallbacks.
Real environment tested: The real openclaw CLI from source (node --import tsx/esm src/entry.ts) with an isolated OPENCLAW_STATE_DIR and OPENCLAW_CONFIG_PATH holding agents.ownership: "explicit", agents.defaults.model = { primary: "anthropic/claude-sonnet-4-6", fallbacks: ["openai/gpt-5.4"] }, and agents.entries.ops.model = { primary: "anthropic/claude-opus-4-6", fallbacks: ["google/gemini-3-pro-preview", "openrouter/qwen/qwen3-coder"] }. Pristine main e97c9d3 first, then this patch with the same config and commands. Nothing was stubbed and no network was involved.
Exact steps or command run after this patch: node --import tsx/esm src/entry.ts models --agent ops fallbacks list, ... models --agent ops image-fallbacks list --json, ... models --agent ops fallbacks clear (existing sibling, for comparison), and ... models fallbacks list (no --agent, unchanged path).
Evidence after fix:

# BEFORE (pristine main e97c9d3d741)
$ openclaw models --agent ops fallbacks list
Fallbacks (1):
- openai/gpt-5.4
[exit 0]
$ openclaw models --agent ops image-fallbacks list --json
{
  "fallbacks": []
}
[exit 0]
$ openclaw models --agent ops fallbacks clear
openclaw models fallbacks clear does not support --agent; it is global and never agent-scoped. Remove --agent, or run openclaw agents list and set the per-agent model in agent config.
[exit 1]
$ openclaw models fallbacks list
Fallbacks (1):
- openai/gpt-5.4
[exit 0]

# AFTER (this patch, identical inputs)
$ openclaw models --agent ops fallbacks list
openclaw models fallbacks list does not support --agent; it is global and never agent-scoped. Remove --agent, or run openclaw agents list and set the per-agent model in agent config.
[exit 1]
$ openclaw models --agent ops image-fallbacks list --json
{
  "ok": false,
  "error": {
    "type": "cli_error",
    "message": "openclaw models image-fallbacks list does not support --agent; it is global and never agent-scoped. Remove --agent, or run openclaw agents list and set the per-agent model in agent config."
  }
}
[openclaw] The CLI command failed.
[openclaw] For help, run `openclaw doctor`.
[exit 1]
$ openclaw models --agent ops fallbacks clear
openclaw models fallbacks clear does not support --agent; it is global and never agent-scoped. Remove --agent, or run openclaw agents list and set the per-agent model in agent config.
[exit 1]
$ openclaw models fallbacks list
Fallbacks (1):
- openai/gpt-5.4
[exit 0]

Observed result after fix: On main, --agent ops printed the global openai/gpt-5.4 chain with exit 0 even though ops is configured with google/gemini-3-pro-preview and openrouter/qwen/qwen3-coder; with the patch both list leaves reject --agent with the same message and exit code as their clear sibling, and the unscoped fallbacks list output is unchanged.
What was not tested: Per-agent fallback listing was not added (fallback management stays global per the closure of #106346); a packaged build of the CLI was not run, only the source entry point.

…s list

The fallbacks and image-fallbacks list leaves accepted the inherited models --agent option and silently printed the global agents.defaults fallbacks instead of the named agent's chain. Their add, remove and clear siblings already reject --agent through the global-only guard; the list leaves now route through the same guard.
@clawsweeper

clawsweeper Bot commented Nov 1, 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 docs Improvements or additions to documentation cli CLI command changes size: XS labels Nov 1, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 1, 2026
@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Rejects inherited --agent on both fallback-list commands instead of silently displaying global defaults.

Example: Run openclaw models --agent ops fallbacks list when global fallbacks contain openai/gpt-5.4 and ops has a different chain.

  • Before: Prints openai/gpt-5.4 and exits 0, silently ignoring ops.
  • After: Explains that the command is global, asks the user to remove --agent, and exits 1.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused repair using the existing owner, with relevant CLI proof, meaningful regressions, green exact-head validation, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The supplied terminal transcript exercises the real source CLI entry point with isolated configuration before and after the fix, showing rejection of text and JSON agent-qualified listing and unchanged unscoped output; a packaged build was not exercised.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An operator requesting an agent's fallback list receives global defaults with a successful exit and no warning that the selected agent was ignored.
Reason: The narrow rejection repair follows the existing sibling commands and the recorded decision to keep fallback management global.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes a current CLI scope bug with the existing guard, respects the recorded global-only design, and has sufficient behavior proof with green exact-head CI.

Priority: P2
Reviewed head: 94442aa14e3e46c3b004fe268b26bc0125c1ca24

Before merge

None.

Findings

None.

Agent review details

How this fits together

Commander registers model-management commands, the shared runtime validates scope, and the fallback reader returns global configuration as text or JSON.

flowchart TD
  A[CLI arguments] --> B[Models command registration]
  B --> C[Shared global scope guard]
  C -->|Agent supplied| D[Error and exit 1]
  C -->|No agent supplied| E[Global fallback reader]
  E --> F[Text or JSON output]
Loading

Technical review

Best possible solution:

Use the existing global-command guard for both list leaves while retaining unscoped output and agent-specific inspection through models status.

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

Current-main registration discards the inherited agent option and the reader returns global defaults; the contributor's before/after CLI transcript independently demonstrates that path, without reviewer execution.

Is this the best way to solve the issue?

This is the smallest complete fix: it reuses the established scope owner, covers both fallback groups, and preserves configuration, model routing, and unscoped output.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 33c6ccee1405.

Provenance checked

  • Fallback list command registration keeps the original intent (752dd2b: Consolidated repeated command registration while preserving existing flags, lazy loading, output, and errors; it did not establish agent-scoped fallback listing.)
  • Global-only fallback guard and documentation keeps the original intent (5aa4230: Prevent agent-qualified fallback mutations from silently editing global defaults by reusing one global-command guard.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 752dd2b adds src/cli/models-cli.ts:231 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 752dd2b5b860; files: src/cli/models-cli.ts)
  • Eric Curtin: Raw commit 5aa4230 adds src/cli/models-cli.ts:261 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5aa4230cc785; files: src/cli/models-cli.ts)
  • sashankh: Raw commit 93573e8 adds src/cli/models-cli.runtime.ts:32 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 93573e8fdf7a; files: src/cli/models-cli.runtime.ts)

PR surface

Source 0, Tests +15, Docs 0. Total +15 across 4 files. Added test files: 0.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Incorrect fallback inspection affects advanced multi-agent CLI workflows, with a bounded repair and an existing status command for agent-specific inspection.
  • 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.

Reviewed November 1, 2026, 11:07 AM ET / 16:07 UTC.

@yetval

yetval commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of issue #204996, which tracks models fallbacks list / image-fallbacks list silently ignoring --agent and printing global defaults against current main (4eb183a).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation 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.

1 participant