Skip to content

fix(ui): treat /model status|list|info as info queries, not model names - #47069

Closed
lagutinl613-alt wants to merge 2 commits into
openclaw:mainfrom
lagutinl613-alt:fix/model-status-subcommand
Closed

lagutinl613-alt wants to merge 2 commits into
openclaw:mainfrom
lagutinl613-alt:fix/model-status-subcommand

Conversation

@lagutinl613-alt

Copy link
Copy Markdown

Summary

The WebUI slash-command handler only distinguished between /model (no args) and /model <name>. Subcommands like status, list, and info were passed through as literal model names to sessions.patch, causing errors like:

GatewayRequestError: model not allowed: openai-codex/status

Changes

  • Added a MODEL_INFO_SUBCOMMANDS set (status, list, info) in slash-command-executor.ts
  • When /model receives one of these subcommands, it routes to the info display path instead of setting the model
  • Added 3 test cases confirming /model status, /model list, and /model info show model info without calling sessions.patch

Test Plan

  • /model status → shows current model + available models
  • /model list → shows current model + available models
  • /model gpt-5.2 → still sets the model as before (no regression)

Fixes #46894

The WebUI slash-command handler only distinguished between '/model' (no
args) and '/model <name>'. Subcommands like 'status', 'list', and 'info'
were passed straight through as literal model names to sessions.patch,
causing errors like 'model not allowed: openai-codex/status'.

Add a set of recognized info subcommands (status, list, info) that route
to the model-info display path instead of attempting to set the model.

Fixes openclaw#46894
@greptile-apps

greptile-apps Bot commented Mar 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a bug where /model status, /model list, and /model info were being forwarded as literal model names to sessions.patch, causing gateway errors. The fix introduces a MODEL_INFO_SUBCOMMANDS set and a single-line condition change in executeModel that routes those subcommands to the existing info-display path — consistent with how executeFast already handles its own status subcommand.

  • slash-command-executor.ts: Adds the MODEL_INFO_SUBCOMMANDS set (status, list, info) and extends the !args guard to also match these subcommands (case-insensitive, trimmed), preventing them from reaching sessions.patch.
  • slash-command-executor.node.test.ts: Adds three tests verifying the new routing for each subcommand. Each test confirms sessions.patch is never called with the subcommand as a model name and that the response contains current model info.
  • Minor gap: The new test describe block does not include a regression case for /model <name> (a real model identifier) still calling sessions.patch — worth adding for completeness.

Confidence Score: 5/5

  • Safe to merge — the change is a targeted, minimal fix with no impact on unrelated commands.
  • The change is two lines of production code and three well-structured tests. The logic is straightforward, mirrors a pattern already used in executeFast, and is fully covered on the new-behavior side. The only gap is a missing regression test for the model-setting path, which is a style concern rather than a defect.
  • No files require special attention.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: ui/src/ui/chat/slash-command-executor.node.test.ts
Line: 233-326

Comment:
**Missing regression test for the model-setting path**

The new suite verifies that `status`, `list`, and `info` no longer reach `sessions.patch`, but there is no test confirming that a real model name (e.g. `/model gpt-4.1`) *still* calls `sessions.patch` with the correct payload. Since the PR touches the branch that routes to `sessions.patch`, a complementary regression test would lock down both sides of the condition and prevent future regressions in the same function.

Consider adding a case to this describe block that passes a non-subcommand argument (e.g. `"gpt-4.1"`), confirms `sessions.patch` is called with `{ key: ..., model: "gpt-4.1" }`, and checks the returned content reads `Model set to \`gpt-4.1\`.`.

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: aa20da5

Comment on lines +233 to +326
describe("executeSlashCommand /model subcommands", () => {
it("treats /model status as an info query, not a model name", async () => {
const request = vi.fn(async (method: string, _payload?: unknown) => {
if (method === "sessions.list") {
return {
defaults: { model: "default-model" },
sessions: [
row("agent:main:main", {
model: "openai-codex/gpt-5.4",
}),
],
};
}
if (method === "models.list") {
return {
models: [{ id: "openai-codex/gpt-5.4" }],
};
}
throw new Error(`unexpected method: ${method}`);
});

const result = await executeSlashCommand(
{ request } as unknown as GatewayBrowserClient,
"main",
"model",
"status",
);

// Should show current model info, NOT try to set the model to "status"
expect(result.content).toContain("Current model:");
expect(result.content).toContain("openai-codex/gpt-5.4");
// Ensure sessions.patch was never called
expect(request).not.toHaveBeenCalledWith(
"sessions.patch",
expect.objectContaining({ model: "status" }),
);
});

it("treats /model list as an info query", async () => {
const request = vi.fn(async (method: string, _payload?: unknown) => {
if (method === "sessions.list") {
return {
defaults: { model: "default-model" },
sessions: [row("agent:main:main", { model: "gpt-4.1" })],
};
}
if (method === "models.list") {
return { models: [{ id: "gpt-4.1" }, { id: "gpt-4.1-mini" }] };
}
throw new Error(`unexpected method: ${method}`);
});

const result = await executeSlashCommand(
{ request } as unknown as GatewayBrowserClient,
"main",
"model",
"list",
);

expect(result.content).toContain("Current model:");
expect(request).not.toHaveBeenCalledWith(
"sessions.patch",
expect.objectContaining({ model: "list" }),
);
});

it("treats /model info as an info query", async () => {
const request = vi.fn(async (method: string, _payload?: unknown) => {
if (method === "sessions.list") {
return {
defaults: { model: "default-model" },
sessions: [row("agent:main:main", { model: "gpt-4.1" })],
};
}
if (method === "models.list") {
return { models: [{ id: "gpt-4.1" }] };
}
throw new Error(`unexpected method: ${method}`);
});

const result = await executeSlashCommand(
{ request } as unknown as GatewayBrowserClient,
"main",
"model",
"info",
);

expect(result.content).toContain("Current model:");
expect(request).not.toHaveBeenCalledWith(
"sessions.patch",
expect.objectContaining({ model: "info" }),
);
});
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing regression test for the model-setting path

The new suite verifies that status, list, and info no longer reach sessions.patch, but there is no test confirming that a real model name (e.g. /model gpt-4.1) still calls sessions.patch with the correct payload. Since the PR touches the branch that routes to sessions.patch, a complementary regression test would lock down both sides of the condition and prevent future regressions in the same function.

Consider adding a case to this describe block that passes a non-subcommand argument (e.g. "gpt-4.1"), confirms sessions.patch is called with { key: ..., model: "gpt-4.1" }, and checks the returned content reads Model set to \gpt-4.1`.`.

Prompt To Fix With AI
This is a comment left during a code review.
Path: ui/src/ui/chat/slash-command-executor.node.test.ts
Line: 233-326

Comment:
**Missing regression test for the model-setting path**

The new suite verifies that `status`, `list`, and `info` no longer reach `sessions.patch`, but there is no test confirming that a real model name (e.g. `/model gpt-4.1`) *still* calls `sessions.patch` with the correct payload. Since the PR touches the branch that routes to `sessions.patch`, a complementary regression test would lock down both sides of the condition and prevent future regressions in the same function.

Consider adding a case to this describe block that passes a non-subcommand argument (e.g. `"gpt-4.1"`), confirms `sessions.patch` is called with `{ key: ..., model: "gpt-4.1" }`, and checks the returned content reads `Model set to \`gpt-4.1\`.`.

How can I resolve this? If you propose a fix, please make it concise.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aa20da59c3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

args: string,
): Promise<SlashCommandResult> {
if (!args) {
if (!args || MODEL_INFO_SUBCOMMANDS.has(args.trim().toLowerCase())) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve ability to set models named reserved subcommands

/model now routes status, list, and info to the info path unconditionally, so sessions.patch is never called for those exact model IDs. Since model IDs are user/provider-defined strings (for example configured provider models can use any non-empty id), this introduces a regression for environments where a real model is named one of those values: /model status can no longer select that model and instead always prints model info.

Useful? React with 👍 / 👎.

Addresses review feedback from Greptile — ensures that real model names
(e.g. /model gpt-4.1) still correctly call sessions.patch.
@clawsweeper

clawsweeper Bot commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Workflow note: Future ClawSweeper reviews update this same comment in place.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

Summary
The PR changes Control UI /model handling to treat status, list, and info as model-info requests and adds executor tests, including a normal model-setting regression test.

Reproducibility: yes. Source inspection on current main shows /model status and /model list parse as non-empty args and executeModel sends every non-empty /model argument to sessions.patch.

PR rating
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
Summary: Not quality-ready because real behavior proof is missing and the patch returns the wrong documented command behavior.

Rank-up moves:

  • Revise /model status and /model list to use the documented status/list flows rather than the bare summary branch.
  • Remove /model info or make it an explicit shared documented contract.
  • Add redacted after-fix Control UI proof for /model status and /model list.
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Real behavior proof
Needs real behavior proof before merge: No after-fix Control UI screenshot, recording, terminal/live output, linked artifact, or redacted runtime log is present; contributors should redact private details and update the PR body so ClawSweeper re-reviews automatically, or ask a maintainer to comment @clawsweeper re-review.

Mantis proof suggestion
A short Control UI visual proof would directly show the visible slash-command output and whether the wrong sessions.patch path is avoided. A maintainer can ask Mantis to capture proof by posting a new PR comment that starts with the OpenClaw Mantis account mention, followed by:

visual task: verify Control UI /model status and /model list show the documented model status/list flows without attempting sessions.patch.

Risk before merge

  • Missing contributor real behavior proof remains a merge gate for this external PR; tests and bot comments do not show the after-fix Control UI behavior.
  • Merging as-is would make /model status and /model list return the bare model summary instead of the documented detailed status and picker/list flows.
  • The undocumented info special case reserves a possible custom model id or alias only in Control UI, creating model-selection compatibility risk.
  • The branch overlaps the still-open linked bug and sibling PR fix(slash): handle /model status locally[AI-assisted]#46894 #46895, so maintainers need one canonical revised path.

Maintainer options:

  1. Revise command routing first (recommended)
    Update this PR or a replacement branch so list and status follow the documented Control UI/shared directive behavior, remove or document info, and add after-fix real Control UI proof.
  2. Deduplicate with the sibling fix
    If fix(slash): handle /model status locally[AI-assisted]#46894 #46895 becomes the canonical implementation, close this branch after preserving any useful tests in the replacement path.
  3. Accept the keyword tradeoff deliberately
    Maintainers may reserve bare status, list, or info, but that should come with explicit docs, shared-command alignment, and upgrade compatibility acceptance.

Next step before merge
Needs contributor proof plus maintainer dedupe and command-semantics review; automation cannot supply the external contributor's after-fix UI proof.

Security
Cleared: The diff is limited to Control UI slash-command branching and colocated tests, with no dependency, workflow, secret, permission, or supply-chain surface change.

Review findings

  • [P2] Route model subcommands to documented handlers — ui/src/ui/chat/slash-command-executor.ts:125
  • [P3] Do not reserve undocumented /model info — ui/src/ui/chat/slash-command-executor.ts:118
Review details

Best possible solution:

Land or replace one canonical Control UI fix that routes /model list and /model status to the documented flows before model mutation, preserves normal model selection, removes or documents info, and includes focused tests plus redacted UI proof.

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

Yes. Source inspection on current main shows /model status and /model list parse as non-empty args and executeModel sends every non-empty /model argument to sessions.patch.

Is this the best way to solve the issue?

No. Avoiding the bad sessions.patch call is necessary, but this PR collapses documented list and status modes into the bare summary branch and adds an undocumented info keyword.

Label justifications:

  • P2: This is a normal-priority Control UI model-command regression fix with limited blast radius but open implementation and proof blockers.
  • merge-risk: 🚨 compatibility: The PR changes slash-command keyword handling and can alter documented responses or model selection for bare status, list, or info identifiers.
  • merge-risk: 🚨 auth-provider: The changed branch controls session model selection and provider/auth status visibility, so incorrect routing can affect model choice and diagnostics.
  • rating: 🧂 unranked krab: Current PR rating is 🧂 unranked krab because proof is 🧂 unranked krab, patch quality is 🧂 unranked krab, and Not quality-ready because real behavior proof is missing and the patch returns the wrong documented command behavior.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: No after-fix Control UI screenshot, recording, terminal/live output, linked artifact, or redacted runtime log is present; contributors should redact private details and update the PR body so ClawSweeper re-reviews automatically, or ask a maintainer to comment @clawsweeper re-review.

Full review comments:

  • [P2] Route model subcommands to documented handlers — ui/src/ui/chat/slash-command-executor.ts:125
    This guard sends /model status and /model list through the same bare-summary branch as /model. Current docs and shared directive handling distinguish them: list is the compact picker/models-browser path and status shows provider/auth/endpoint details, so this patch prevents the bad sessions.patch call but still returns the wrong documented response.
    Confidence: 0.91
  • [P3] Do not reserve undocumented /model info — ui/src/ui/chat/slash-command-executor.ts:118
    Adding info makes Control UI treat a real model id or alias named info as a command, but the documented and shared directive contract only defines empty, list, and status. Remove it or add a shared documented mode before reserving that token.
    Confidence: 0.82

Overall correctness: patch is incorrect
Overall confidence: 0.91

What I checked:

Likely related people:

  • BunsDev: PR metadata for the dashboard chat infrastructure slice shows this account authored the work that added slash-command-executor.ts, slash-commands.ts, and the initial executor tests. (role: introduced Control UI slash-command surface; confidence: high; commits: c5ea6134d041, 9533e0c8a39a, 38799cb5515b; files: ui/src/ui/chat/slash-command-executor.ts, ui/src/ui/chat/slash-commands.ts, ui/src/ui/chat/slash-command-executor.node.test.ts)
  • steipete: Recent commits touched Control UI model reference handling and slash-command model qualification near the affected executor branch. (role: recent model-command path contributor; confidence: high; commits: 7e8f5ca71b7d, 25d52b56a0e1; files: ui/src/ui/chat/slash-command-executor.ts, ui/src/ui/chat/slash-command-executor.node.test.ts, ui/src/ui/chat-model-ref.ts)
  • Mule-ME: Merged Control UI model metadata work touched the same model picker/catalog preservation surface, including the executor and its tests. (role: adjacent Control UI model-selection contributor; confidence: medium; commits: 4977c4ab8221, d84c96439132, 2089d42edf26; files: ui/src/ui/chat/slash-command-executor.ts, ui/src/ui/chat/slash-command-executor.node.test.ts, ui/src/ui/chat-model-ref.ts)
  • Vignesh Natarajan: History shows this author added /models and fixed /model listing UX in the shared directive path that defines the expected list behavior. (role: shared model-list contract contributor; confidence: medium; commits: 41d56c06b941; files: src/auto-reply/reply/directive-handling.model.ts, src/auto-reply/reply/directive-handling.model.test.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 3d96111a5afe.

@clawsweeper clawsweeper Bot added the P2 Normal backlog priority with limited blast radius. label May 17, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 17, 2026
@clawsweeper clawsweeper Bot added impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. and removed impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. labels May 17, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@lagutinl613-alt

Copy link
Copy Markdown
Author

Closing this in favor of a narrower, refreshed PR against current main.

Reasons:

  • Code in main has drifted since this PR was opened — the executeModel shape and surrounding model-command semantics changed, so this patch no longer applies cleanly (per ClawSweeper review, 28 Apr).
  • Public docs now differentiate /model list (picker view) and /model status (detail view), so routing both unconditionally to the bare-info path is too broad.
  • Codex P2 flagged a legitimate edge case: jamming status/list/info into a reserved-subcommand set blocks selecting a real model whose id happens to match. The replacement should consult the actual models.list before treating an arg as a subcommand.

Replacement plan (will open under a new PR):

  • Honor current docs' distinction between /model list and /model status.
  • Only treat status|list|info as info subcommands when they do not match a registered model id.
  • Add the regression test Greptile asked for (/model <real-id> still routes to sessions.patch with the correct payload).

Thanks to all reviewers for the detailed feedback.

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

Labels

app: web-ui App: web-ui merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Slash command error——WebUI treats /model status as a model name instead of a slash-command subcommand

1 participant