Skip to content

fix(status): ignore stale context after model switch#93306

Merged
clawsweeper[bot] merged 2 commits into
mainfrom
codex/status-context-window-model-switch
Jun 16, 2026
Merged

fix(status): ignore stale context after model switch#93306
clawsweeper[bot] merged 2 commits into
mainfrom
codex/status-context-window-model-switch

Conversation

@hxy91819

@hxy91819 hxy91819 commented Jun 15, 2026

Copy link
Copy Markdown
Member

Purpose

Manual session model switches should make /status report the context window for the newly selected model. The current status formatter can still trust a transcript/runtime snapshot from the previous model, so a session pinned to ollama-cloud/glm-5.1 can continue to display the old ollama-cloud/deepseek-v4-pro 1.0m context window.

Summary

  • Keep /status context-window display aligned with the session-selected model after manual model switches.
  • Trust explicit runtime context tokens only when the runtime snapshot has fallback or equivalent-runtime provenance.
  • Add regression coverage for both the stale-runtime case and config-backed runtime aliases that should still keep their runtime window.

Root Cause

src/status/status-message.ts treated runtimeContextTokens as authoritative whenever the runtime model differed from the selected model. That is correct for real fallback or equivalent runtime alias paths, but wrong after a manual session model switch because the runtime snapshot can describe the previous transcript model.

Real Behavior Proof

Behavior addressed: /status now uses the session-selected model's configured context window after a manual model switch instead of pinning the display to stale runtime context tokens from the previous model.

Real environment tested: Crabbox Docker provider, lease cbx_9a713b50341d, clean synced PR branch checkout in node:22-bookworm.

Exact steps or command run after this patch: node scripts/crabbox-wrapper.mjs run --provider docker --docker-image node:22-bookworm --idle-timeout 90m --ttl 240m --timing-json --shell -- "corepack enable && corepack pnpm install --frozen-lockfile && node scripts/run-vitest.mjs src/status/status-message.test.ts"

Evidence after fix: src/status/status-message.test.ts builds the stale manual-switch status input where the selected model is ollama-cloud/glm-5.1, the previous runtime snapshot is ollama-cloud/deepseek-v4-pro, and the stale runtime context is 1_000_000.

Observed result after fix: Crabbox passed src/status/status-message.test.ts with 1 test file and 4 tests. The regression test asserts Session selected: ollama-cloud/glm-5.1, Context: 128k/200k, and not Context: 128k/1.0m.

What was not tested: No live Telegram/openclaw2 package upgrade was rerun from this PR branch; the focused proof covers the status-message decision path that formats the incorrect context window.

Verification

  • pnpm check:test-types
  • node scripts/run-vitest.mjs src/status/status-message.test.ts
  • .agents/skills/autoreview/scripts/autoreview --mode local
  • git diff --check
  • Crabbox Docker proof: provider docker, lease cbx_9a713b50341d, exit 0.

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Jun 15, 2026
@clawsweeper

clawsweeper Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: passed. Reviewed June 15, 2026, 3:32 PM ET / 19:32 UTC.

Summary
The PR changes /status context-window selection to ignore stale runtime snapshots after manual model switches while preserving fallback/runtime-alias context windows.

PR surface: Source +6, Tests +128. Total +134 across 2 files.

Reproducibility: yes. source-reproducible: current main trusts explicit runtime context before checking fallback provenance when active and selected models differ. I did not run a local failing repro, but the PR fixture models the stale prior-runtime state directly.

Review metrics: none identified.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🌊 off-meta tidepool
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Next step before merge

  • [P2] No repair lane is needed; the PR has no actionable review finding and can continue through normal maintainer/automerge gates.

Security
Cleared: The diff only changes TypeScript status-formatting logic and colocated tests; it does not touch dependencies, workflows, packaging, secrets, or code-execution surfaces.

Review details

Best possible solution:

Land the focused status formatter guard with its regression coverage once the normal maintainer and automerge gates accept the exact head SHA.

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

Yes, source-reproducible: current main trusts explicit runtime context before checking fallback provenance when active and selected models differ. I did not run a local failing repro, but the PR fixture models the stale prior-runtime state directly.

Is this the best way to solve the issue?

Yes. Moving explicit runtime-token trust behind the fallback/equivalent-runtime provenance check is the narrow formatter-side fix, and passing args.config preserves configured runtime aliases.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add status: 🚀 automerge armed: This PR is in ClawSweeper's automerge lane. Not applicable: The external-contributor proof gate is not applicable because the PR is maintainer-labeled; the body still records focused Crabbox Docker proof for the status-message test path.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: 🚀 automerge armed.

Label justifications:

  • P2: This fixes a bounded user-facing /status display bug after manual model switches with limited blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 🚀 automerge armed: This PR is in ClawSweeper's automerge lane. Not applicable: The external-contributor proof gate is not applicable because the PR is maintainer-labeled; the body still records focused Crabbox Docker proof for the status-message test path.
Evidence reviewed

PR surface:

Source +6, Tests +128. Total +134 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 19 13 +6
Tests 1 129 1 +128
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 148 14 +134

What I checked:

  • Current-main stale path: On current main, buildStatusMessage enters the runtime-diff branch and returns explicitRuntimeContextTokens before the fallback/equivalence provenance check can reject stale runtime metadata. (src/status/status-message.ts:799, b3128ba93def)
  • PR-head fix: At PR head, runtimeSnapshotHasFallbackProvenance is computed first with args.config, and explicit runtime context tokens are trusted only after fallback or equivalent-runtime provenance is established. (src/status/status-message.ts:788, f14fda427943)
  • Regression coverage: The PR adds tests for the stale manual-switch case and for config-backed runtime aliases that should retain the runtime context window. (src/status/status-message.test.ts:35, f14fda427943)
  • Caller contract: buildStatusText already filters runtime context tokens with the same fallback/equivalent-runtime provenance before delegating to buildStatusMessage, so the PR aligns the lower-level formatter with its caller. (src/status/status-text.ts:557, b3128ba93def)
  • Latest release still lacks the fix: The latest release tag still has the older status-message context branch and does not contain the PR head commits, so the requested behavior is not already shipped. (src/status/status-message.ts:697, 8c802aa68351)
  • Related merged provenance: The current status context-window branch comes from the recently merged stale-context-window repair, and this PR is a focused follow-up to that same surface. (src/status/status-message.ts:799, 4029fbd2b238)

Likely related people:

  • hxy91819: Authored the merged stale status context-window repair in fix(status): avoid stale session context windows #93220 and this focused follow-up on the same formatter path. (role: recent area contributor; confidence: high; commits: 4029fbd2b238, 570c8d1828c5, f14fda427943; files: src/status/status-message.ts, src/status/status-text.ts, src/status/status-message.test.ts)
  • Josh Lehman: Recent local history shows adjacent status module work in status-message.ts and status-text.ts, including plugin-health and transcript-reader changes. (role: recent adjacent status contributor; confidence: medium; commits: 10a4c7c10b6a, 8ded75628437; files: src/status/status-message.ts, src/status/status-text.ts)
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.

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.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. labels Jun 15, 2026
@clawsweeper clawsweeper Bot added 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 15, 2026
@hxy91819

Copy link
Copy Markdown
Member Author

@clawsweeper automerge

@clawsweeper

clawsweeper Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@hxy91819

Copy link
Copy Markdown
Member Author

@clawsweeper automerge

@clawsweeper

clawsweeper Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

🦞✅
ClawSweeper merged this PR after the passing review.

Source: clawsweeper[bot]
Feedback: structured ClawSweeper verdict: pass (sha=f14fda4279435f1407ee146bba97e03e2283255a)
Merge status: merged by ClawSweeper automerge
Merged at: 2026-06-16T15:05:52Z
Merge commit: f046d7aa23df

What merged:

  • The PR changes /status context-window selection to ignore stale runtime snapshots after manual model switches while preserving fallback/runtime-alias context windows.
  • PR surface: Source +6, Tests +128. Total +134 across 2 files.
  • Reproducibility: yes. source-reproducible: current main trusts explicit runtime context before checking fall ... fer. I did not run a local failing repro, but the PR fixture models the stale prior-runtime state directly.

Automerge notes:

  • PR branch already contained follow-up commit before automerge: test(status): make context fixtures type-correct

The automerge loop is complete.

Automerge progress:

  • 2026-06-16 00:40:51 UTC review queued f14fda427943 (queued)
  • 2026-06-16 14:10:44 UTC review passed f14fda427943 (structured ClawSweeper verdict: pass (sha=f14fda4279435f1407ee146bba97e03e22832...)
  • 2026-06-16 15:05:56 UTC merged f14fda427943 (merged by ClawSweeper automerge)

@clawsweeper clawsweeper Bot added clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge clawsweeper:human-review Needs maintainer review before ClawSweeper can continue labels Jun 16, 2026
@clawsweeper

clawsweeper Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

🦞✅
ClawSweeper is pausing this repair loop for human review.

Source: clawsweeper[bot]
Reason: - [P2] No repair lane is needed; the PR has no actionable review finding and can continue through normal maintainer/automerge gates.; Cleared: The diff only changes TypeScript status-formatting logic and colocated tests; it does not touch dependencies, workflows, packaging, secrets, or code-execution surfaces. (sha=f14fda4279435f1407ee146bba97e03e2283255a)

Why human review is needed:
This item has security-sensitive risk. ClawSweeper is pausing instead of making an autonomous change that could affect trust, credentials, permissions, or exposure.

What the maintainer can do as a next step:
If the maintainer accepts the current risk and wants ClawSweeper to continue merge gates, comment @clawsweeper approve. If the security-sensitive detail still needs changes, describe the safe path or push the fix, then comment @clawsweeper automerge. If the risk should not be automated, keep the PR paused for manual review or comment @clawsweeper stop.

I added clawsweeper:human-review and left the final call with a maintainer.

@clawsweeper clawsweeper Bot added status: 🚀 automerge armed This PR is in ClawSweeper's automerge lane. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. clawsweeper:human-review Needs maintainer review before ClawSweeper can continue labels Jun 16, 2026
@clawsweeper
clawsweeper Bot merged commit f046d7a into main Jun 16, 2026
217 of 223 checks passed
@clawsweeper
clawsweeper Bot deleted the codex/status-context-window-model-switch branch June 16, 2026 15:05
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 17, 2026
Summary:
- The PR changes `/status` context-window selection to ignore stale runtime snapshots after manual model switches while preserving fallback/runtime-alias context windows.
- PR surface: Source +6, Tests +128. Total +134 across 2 files.
- Reproducibility: yes. source-reproducible: current main trusts explicit runtime context before checking fall ... fer. I did not run a local failing repro, but the PR fixture models the stale prior-runtime state directly.

Automerge notes:
- PR branch already contained follow-up commit before automerge: test(status): make context fixtures type-correct

Validation:
- ClawSweeper review passed for head f14fda4.
- Required merge gates passed before the squash merge.

Prepared head SHA: f14fda4
Review: openclaw#93306 (comment)

Co-authored-by: Mason Huang <[email protected]>
Approved-by: hxy91819
crh-code pushed a commit to crh-code/openclaw that referenced this pull request Jun 18, 2026
Summary:
- The PR changes `/status` context-window selection to ignore stale runtime snapshots after manual model switches while preserving fallback/runtime-alias context windows.
- PR surface: Source +6, Tests +128. Total +134 across 2 files.
- Reproducibility: yes. source-reproducible: current main trusts explicit runtime context before checking fall ... fer. I did not run a local failing repro, but the PR fixture models the stale prior-runtime state directly.

Automerge notes:
- PR branch already contained follow-up commit before automerge: test(status): make context fixtures type-correct

Validation:
- ClawSweeper review passed for head f14fda4.
- Required merge gates passed before the squash merge.

Prepared head SHA: f14fda4
Review: openclaw#93306 (comment)

Co-authored-by: Mason Huang <[email protected]>
Approved-by: hxy91819
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 🚀 automerge armed This PR is in ClawSweeper's automerge lane.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant