Skip to content

fix(ui): clarify active model context in picker - #124207

Merged
Patrick-Erichsen merged 5 commits into
mainfrom
pe/fix-1m-context-binding
Aug 16, 2026
Merged

Patrick-Erichsen merged 5 commits into
mainfrom
pe/fix-1m-context-binding

Conversation

@Patrick-Erichsen

@Patrick-Erichsen Patrick-Erichsen commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • distinguish the active session context budget from the model's native maximum in the expanded picker
  • keep the compact trigger model-only
  • suppress stale budget metadata during optimistic model switches
  • preserve the session provider when slash-containing model IDs exist under multiple providers

Root cause

The picker rendered only models.list.contextWindow, which is the model's native capacity. It ignored the selected sessions.list row's effective contextTokens, so a 272k OpenClaw session appeared to have 1M active context. The first implementation also reconstructed model identity separately and dropped the provider for ambiguous slash-containing IDs; the final patch reuses the canonical server model resolver.

Tests

Visual proof

Real user-path capture completed on exact head 35779a668cc3c5165babc2fa4a12f01d7beeb20c:

  • actual production-built Control UI served by an actual OpenClaw Gateway
  • selected real session: agent:main:context-proof
  • live sessions.list: 272000 active tokens
  • live models.list: 1050000 native context, OpenClaw runtime
  • expanded picker visibly reads 272k active · 1M max · OpenClaw
  • Blacksmith Testbox: tbx_01m035f421sc6gttyc4g8jzm4v
  • Testbox Actions run
pr124207-context-budget-expanded

Agent Transcript

Sanitized, scoped Codex transcript
[user]
Use subagents to get red/green TDD matching this behavior, then open one PR for each issue with visual proof.

[assistant]
The UI lane is isolated: the picker shows native 1M capacity while the active session budget is 272k. The regression will target that owner boundary.

[assistant]
The first red assertion expects `272k active`; the expanded row must retain `1M max` and `OpenClaw`.

[assistant]
Review found two edge cases before shipping: prevent stale session budget pairing during optimistic model switches, and preserve provider identity for slash-containing model IDs by reusing the canonical resolver.

[assistant]
Proof complete: both red/green cycles passed, the full 253-test chat suite passed, i18n and formatting passed, and an exact-head production build served the real Control UI through a real Gateway. The expanded model picker visibly reads `272k active · 1M max · OpenClaw`.

@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: S maintainer Maintainer-authored PR labels Aug 15, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Aug 15, 2026
@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 15, 2026, 9:13 PM ET / August 16, 2026, 01:13 UTC.

ClawSweeper review

What this changes

The PR makes the expanded chat model picker display a selected session’s active context budget separately from the model catalog’s maximum context capacity.

Merge readiness

⚠️ Needs maintainer review before merge - 5 items remain

Keep open: the picker correctly separates active and maximum context in the demonstrated stable case, but it can still label a stale persisted budget as active after a same-model runtime change. The related producer repair remains open, so this PR needs sequencing or an equivalent provenance-based fix before merge.

Priority: P2
Reviewed head: d8655920236efcb2495d4d01c6f1ea6dc0f4c552
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong real UI proof covers the intended stable display, but a concrete session-provenance defect still blocks correctness.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The PR includes a real Gateway-backed production Control UI capture of the changed picker and a maintainer-reported exact-head production proof; the remaining blocker is a source-proven state transition not shown by that capture.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): The PR includes a real Gateway-backed production Control UI capture of the changed picker and a maintainer-reported exact-head production proof; the remaining blocker is a source-proven state transition not shown by that capture.
Evidence reviewed 7 items Current producer behavior: Current main resolves a session row’s context budget from persisted entry data before transcript or model fallback, so an older positive value remains eligible for projection.
Runtime is independently resolved: The same projection derives agentRuntime from current configured metadata unless a persisted runtime override applies; matching runtime therefore does not prove that the persisted context budget came from that runtime.
PR trusts the insufficient pair: The branch assigns contextTokens when model and runtime match, but does not receive producer provenance for the cached budget.
Findings 1 actionable finding [P2] Gate active context on producer provenance
Security None None.

How this fits together

Gateway projects a session’s resolved model/runtime alongside its cached context budget, and the Control UI combines that row with the model catalog to render picker metadata. The picker then presents the result to an operator selecting a chat model.

flowchart LR
A[Persisted session budget] --> C[Gateway session projection]
B[Current model configuration] --> C
D[Model catalog maximum] --> E[Chat model controls]
C --> E
E --> F[Runtime and model match]
F --> G[Expanded model picker]
G --> H[Operator context information]
Loading

Decision needed

Question Recommendation
Should this PR wait for the Gateway provenance repair in #124303, or should that repair be incorporated before this picker can merge? Land provenance first: Merge the producer repair first, then refresh this PR with a same-model runtime-transition proof.

Why: The remaining failure is caused by session projection ownership, so only maintainers can choose whether to sequence the linked PRs or consolidate their changes.

Before merge

  • Gate active context on producer provenance (P2) - The runtime check cannot establish that contextTokens belongs to that runtime: current Gateway projects entry.contextTokens first while independently resolving agentRuntime from current configuration. A same-model OpenClaw-to-Codex transition can therefore satisfy this condition and render the old 272k value as active. This is the still-unfixed prior finding; consume the producer provenance from fix(sessions): track context window provenance #124303 or omit active metadata until it exists.
  • Resolve merge risk (P1) - Merging before producer provenance is available can present an old 272k persisted budget as the active window after the current configuration resolves the same model to a new runtime.
  • Resolve merge risk (P1) - The bug-fix branch adds production UI inference around a producer-owned fact; its net +48 production lines remain justified only if they consume an authoritative provenance contract.
  • Complete next step (P2) - The protected maintainer PR has a concrete P2 blocker, but resolving it requires a maintainer choice about the linked producer repair’s sequencing or consolidation.

Findings

  • [P2] Gate active context on producer provenance — ui/src/pages/chat/components/chat-model-controls.ts:302-315
Agent review details

Security

None.

PR surface

Source +48, Tests +174. Total +222 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 4 57 9 +48
Tests 1 181 7 +174
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 238 16 +222

Review metrics

Metric Value Why it matters
Production versus test LOC production +57/-9 (net +48); tests +181/-7 The production growth is only warranted if it reads a producer-owned provenance fact rather than independently inferring freshness in the picker.

Merge-risk options

Maintainer options:

  1. Sequence the producer fix first (recommended)
    Land fix(sessions): track context window provenance #124303, then rebase and prove that an old same-model budget is not shown as active.
  2. Consolidate provenance with this PR
    Carry a producer-authenticated budget provenance field through Gateway and add the transition regression before merging the UI claim.

Technical review

Best possible solution:

Land or incorporate the producer-owned context-window provenance repair from #124303, then rebase this UI work and prove the same-model runtime-transition case renders no stale active budget.

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

Yes—source-reproducible: retain a positive persisted contextTokens value, switch the same model to a new configured runtime, and render the picker after Gateway projects the new runtime with the old budget.

Is this the best way to solve the issue?

No. The UI runtime/model comparison is a useful guard but cannot establish budget freshness; Gateway must publish producer provenance before the picker labels the value active.

Full review comments:

  • [P2] Gate active context on producer provenance — ui/src/pages/chat/components/chat-model-controls.ts:302-315
    The runtime check cannot establish that contextTokens belongs to that runtime: current Gateway projects entry.contextTokens first while independently resolving agentRuntime from current configuration. A same-model OpenClaw-to-Codex transition can therefore satisfy this condition and render the old 272k value as active. This is the still-unfixed prior finding; consume the producer provenance from fix(sessions): track context window provenance #124303 or omit active metadata until it exists.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add merge-risk: 🚨 session-state: The new UI metadata can associate a persisted context budget with the wrong current runtime and model state.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The PR includes a real Gateway-backed production Control UI capture of the changed picker and a maintainer-reported exact-head production proof; the remaining blocker is a source-proven state transition not shown by that capture.
  • remove merge-risk: 🚨 other: Current PR review merge-risk labels are merge-risk: 🚨 session-state.

Label justifications:

  • P2: The PR can misstate active session context after a runtime transition, but the impact is limited to picker metadata.
  • merge-risk: 🚨 session-state: The new UI metadata can associate a persisted context budget with the wrong current runtime and model state.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (screenshot): The PR includes a real Gateway-backed production Control UI capture of the changed picker and a maintainer-reported exact-head production proof; the remaining blocker is a source-proven state transition not shown by that capture.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR includes a real Gateway-backed production Control UI capture of the changed picker and a maintainer-reported exact-head production proof; the remaining blocker is a source-proven state transition not shown by that capture.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The PR includes a real Gateway-backed production Control UI capture of the changed picker and a maintainer-reported exact-head production proof; the remaining blocker is a source-proven state transition not shown by that capture.

Evidence

What I checked:

Likely related people:

  • Josh Lehman: Current main blames both the picker baseline and Gateway context projection to commit 56798ae. (role: recent area contributor; confidence: high; commits: 56798ae08505; files: ui/src/pages/chat/components/chat-model-controls.ts, ui/src/pages/chat/components/chat-model-picker-options.ts, src/gateway/session-utils-row.ts)
  • fuller-stack-dev: Owns the open session-provenance repair identified in the PR discussion as the durable fix for the remaining stale-budget state. (role: related producer-fix author; confidence: high; commits: 71c5b4eca747; files: src/gateway/session-utils-row.ts, src/gateway/session-utils-model.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (6 earlier review cycles)
  • reviewed 2026-08-15T16:42:14.548Z sha 129924e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-15T16:59:08.243Z sha 129924e :: needs changes before merge. :: [P1] Preserve the session provider for slash-containing model IDs
  • reviewed 2026-08-15T17:37:07.895Z sha 35779a6 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-15T17:42:43.002Z sha 35779a6 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-15T18:53:15.443Z sha 35779a6 :: needs changes before merge. :: [P2] Suppress active context while a model switch is pending
  • reviewed 2026-08-16T00:05:28.042Z sha d865592 :: found issues before merge. :: [P2] Gate active context on producer provenance

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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. labels Aug 15, 2026
@Patrick-Erichsen Patrick-Erichsen changed the title fix(ui): show active model context budget fix(ui): clarify active model context in picker Aug 15, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member

Maintainer review at exact head 35779a668cc3c5165babc2fa4a12f01d7beeb20c:

This is independent of the runtime fixes in #120197 and #124137. It is a UI clarification, not a compaction or model-configuration change.

The distinction is correct: sessions.list.contextTokens is the active session budget, while models.list.contextWindow is the catalog maximum. For the Codex configuration used on Rosita, the intended active context window is 1,000,000 tokens and the 700,000 value is the auto-compaction threshold. The picker should therefore describe 1,000,000 as active; it should not display 700,000 as the context window.

The latest provider-aware model matching is the right owner-layer repair for the stale-provider finding. One residual state boundary is worth covering if it is not already: before the first native Codex usage event, or immediately after a same-model OpenClaw-to-Codex runtime switch, the session can temporarily retain an older contextTokens value. The UI should avoid presenting that stale value as authoritative until the new runtime publishes usage.

Relationship to our work:

I consider this the right UI seam; it should remain separate from both runtime PRs.

@Patrick-Erichsen

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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 rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 15, 2026
@fuller-stack-dev fuller-stack-dev self-assigned this Aug 15, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed 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. labels Aug 15, 2026
@clawsweeper clawsweeper Bot added the status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. label Aug 15, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member

Updated the shared branch without rewriting contributor history. Exact head: d8655920236efcb2495d4d01c6f1ea6dc0f4c552.

  • retains the provider/model/runtime mismatch guard and adds the pending-switch guard
  • derives implicit runtime identity from the canonical catalog/default path instead of treating missing catalog metadata as a match
  • preserves provider-qualified slash model identity
  • signed-merged canonical main 5626a79cc836d95d236debd720a34fc2dcdcc685
  • full Control UI suite passed: 660 files, 9,515 tests passed, 1 skipped
  • raw ui:i18n:verify passed: 95 baseline entries, 5,071 source keys, 5,770 literal references, 48 template-prefix references
  • exact-branch autoreview clean (0.99), secret scan clean
  • source-blind production UI proof covered stable 1M active / native max labeling, missing and mismatched runtime provenance, a genuine pending selection, provider-qualified slash IDs, hard-reload persistence, and model-only collapsed trigger (run 31908348375)

The durable same-model persisted-window freshness seam is intentionally owned by separate producer PR #124303; this PR remains UI-only.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. and removed proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Aug 16, 2026
@Patrick-Erichsen
Patrick-Erichsen merged commit a73249c into main Aug 16, 2026
181 checks passed
@Patrick-Erichsen
Patrick-Erichsen deleted the pe/fix-1m-context-binding branch August 16, 2026 02:57
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 16, 2026
* fix(ui): show active model context budget

* fix(ui): simplify compact model label

* fix(ui): preserve provider when matching context budget

* fix(ui): hide stale context during model switches

---------

Co-authored-by: fuller-stack-dev <[email protected]>
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 maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M 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.

2 participants