Skip to content

fix(status): use selected model for usage#93348

Closed
MonkeyLeeT wants to merge 1 commit into
openclaw:mainfrom
MonkeyLeeT:codex/fix-status-selected-usage-93322
Closed

fix(status): use selected model for usage#93348
MonkeyLeeT wants to merge 1 commit into
openclaw:mainfrom
MonkeyLeeT:codex/fix-status-selected-usage-93322

Conversation

@MonkeyLeeT

@MonkeyLeeT MonkeyLeeT commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Make /status usage probes follow a user-selected session model instead of a stale active runtime snapshot.
  • Keep active-runtime usage behavior for auto fallback/runtime-alias cases.
  • Add regression coverage for an OpenAI session override with stale DeepSeek runtime state.

Fixes #93322.

Root Cause

buildStatusText chose the usage provider from the active runtime provider whenever the active runtime model differed from the selected model. After /model, the stored runtime snapshot can still describe the previous/default model until a later turn refreshes it, so /status could show the selected OpenAI model while querying and displaying DeepSeek usage.

Real behavior proof

  • Behavior or issue addressed: After a user selects openai/gpt-5.5, status usage must use the selected OpenAI profile even when the persisted active runtime snapshot still says deepseek/deepseek-v4-flash.
  • Real environment tested: Local OpenClaw source checkout on macOS, branch codex/fix-status-selected-usage-93322, commit 9229111, with isolated OPENCLAW_STATE_DIR and a local provider usage responder returning an OpenAI WHAM payload. No secrets or live account data were used.
  • Exact steps or command run after this patch: node --import tsx --input-type=module with a focused runtime probe that imports src/status/status-text.ts, persists a token auth profile in the isolated state dir, renders /status, and renders the same buildStatusText path that session_status calls from src/agents/tools/session-status-tool.ts:883.
  • Evidence after fix: Terminal transcript:
$ node --import tsx --input-type=module < status-selected-usage-probe.mts
/status selected line: 📌 Session selected: openai/gpt-5.5 · 🔑 token (openai-proof)
/status usage line: 📊 Usage: 5h 91% left ⏱59m · Week 61% left ⏱2d 23h
/status stale DeepSeek balance present: no
session_status shared renderer selected line: 📌 Session selected: openai/gpt-5.5 · 🔑 token (openai-proof)
session_status shared renderer usage line: 📊 Usage: 5h 91% left ⏱59m · Week 61% left ⏱2d 23h
session_status shared renderer stale DeepSeek balance present: no
usage endpoint calls: 2
selected model visible on both surfaces: yes
OpenAI usage visible on both surfaces: yes
stale DeepSeek balance absent on both surfaces: yes
  • Observed result after fix: Both status surfaces rendered openai/gpt-5.5 and Usage: 5h 91% left; neither output rendered the stale DeepSeek Balance ¥22.75, and the provider usage endpoint was called twice for the selected usage path.
  • What was not tested: Live Telegram Desktop capture and real provider billing endpoints were outside this draft proof; the changed behavior is the shared status usage-provider selection path.

Verification

  • node scripts/run-vitest.mjs src/auto-reply/reply/commands-status.test.ts -- --reporter=verbose
  • pnpm format:check -- src/status/status-text.ts src/auto-reply/reply/commands-status.test.ts
  • git diff --check -- src/status/status-text.ts src/auto-reply/reply/commands-status.test.ts
  • Attempted .agents/skills/autoreview/scripts/autoreview --mode local; blocked before review by local Codex CLI config error: unknown variant default, expected fast or flex in service_tier.

@openclaw-barnacle openclaw-barnacle Bot added size: S triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels Jun 15, 2026
@clawsweeper

clawsweeper Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded: #93384 is the better open landing path for the same linked /status selected-model usage bug because it covers this usage case plus provider-qualified overrides and auth/context/status-message lookup, while this draft remains a narrower usage-only patch.

Canonical path: Use #93384 as the single landing path for the linked /status selected-model bug.

So I’m closing this here and keeping the remaining discussion on #93384.

Review details

Best possible solution:

Use #93384 as the single landing path for the linked /status selected-model bug.

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

Yes at source level. The linked live report on v2026.6.6 shows OpenAI selected while DeepSeek usage is rendered, and current main's buildStatusText still resolves usage from the active/default provider when selected and active refs differ.

Is this the best way to solve the issue?

No. This PR is a plausible narrow mitigation, but #93384 is a better fix because it moves selected-provider parsing into the shared resolver boundary and covers usage, auth, context, and status-message lookup.

Security review:

Security review cleared: The diff only changes TypeScript status rendering logic and a colocated test, with no dependency, workflow, package, secret, or privileged execution change.

AGENTS.md: found and applied where relevant.

What I checked:

  • Current-main status usage path still matches the reported bug class: On current main, buildStatusText resolves selected/active refs from the passed provider/model, but then uses the active runtime auth/provider for usage when selected and active refs differ. (src/status/status-text.ts:397, 32af1c069727)
  • Shared session_status caller uses the same renderer: session_status delegates to buildStatusText, so the remaining fix should cover the shared status renderer rather than only one chat command surface. (src/agents/tools/session-status-tool.ts:883, 32af1c069727)
  • Documented model-selection contract supports selected-session status: The models docs say user session selections from /model, session_status(model=...), and related surfaces are exact for that session. Public docs: docs/concepts/models.md. (docs/concepts/models.md:63, 32af1c069727)
  • This draft is narrower than the canonical PR: The diff for this PR changes only src/status/status-text.ts usage-provider selection and one focused test, without updating selected-model parsing or status-message auth/context lookup. (src/status/status-text.ts:373, 92291111504a)
  • Canonical PR is open and proof-positive: The related PR is open, non-draft, mergeable, maintainer-editable, labeled proof: sufficient, and also closes the same linked bug report. (82295093bc33)
  • Canonical PR covers the broader status resolver boundary: The canonical diff updates resolveSelectedAndActiveModel, status-message, status-text, and tests for both separate overrides and provider-qualified modelOverride values. (src/auto-reply/model-runtime.ts:78, 82295093bc33)

Likely related people:

  • ly-wang19: git blame on the current buildStatusText selected/usage-provider path and resolveSelectedAndActiveModel points to commit 53541b2, merged through the recent status-related refactor PR. (role: introduced current status resolver wiring; confidence: high; commits: 53541b2141c6; files: src/status/status-text.ts, src/status/status-message.ts, src/auto-reply/model-runtime.ts)
  • vincentkoc: Live PR metadata shows the current status resolver wiring commit 53541b2 was merged by this account through fix(cron): resolve lastRunStatus in cron list/show human output #93245. (role: merger; confidence: medium; commits: 53541b2141c6; files: src/status/status-text.ts, src/status/status-message.ts, src/auto-reply/model-runtime.ts)
  • jalehman: Recent merged work touched the same status rendering modules, including plugin-health status changes and a transcript-reader refactor adjacent to status-message and status-text. (role: recent status-area contributor; confidence: medium; commits: 10a4c7c10b6a, 8ded75628437; files: src/status/status-text.ts, src/status/status-message.ts, src/auto-reply/reply/commands-status.test.ts)

Codex review notes: model internal, reasoning high; reviewed against 32af1c069727.

@clawsweeper clawsweeper Bot added 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. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. labels Jun 15, 2026
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels Jun 15, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 15, 2026
@MonkeyLeeT MonkeyLeeT closed this Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: /status usage should follow session-selected model after /model switch

1 participant