Skip to content

fix: switching agents can show another agent's auth and quota - #132894

Merged
shakkernerd merged 3 commits into
mainfrom
shakkernerd/agent-quota-ownership
Aug 30, 2026
Merged

shakkernerd merged 3 commits into
mainfrom
shakkernerd/agent-quota-ownership

Conversation

@shakkernerd

Copy link
Copy Markdown
Contributor

Fixes #129215

Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.

What Problem This Solves

Fixes an issue where users switching agents in a global Control UI chat could see the previous agent's account, plan, quota, identity, or authentication warning when an earlier request completed late.

Why This Change Was Made

Auth and identity results are now bound to the selected agent and request generation. Agent changes clear prior presentation immediately, start replacement loads, and reject stale completions while preserving fixed-session routing, reconnect fencing, and non-auth sidebar attention.

User Impact

The selected agent's chat and sidebar now show only that agent's authentication and quota state, including during delayed responses and routine Gateway presence updates.

Evidence

Before

Delayed Main responses overwrite the Work view with Main identity and quota data.

Stale Main account and quota shown after selecting Work

After

Work remains selected and only Work account, plan, provider, and quota data appear.

Selected Work account and quota remain correctly bound

Recording

The recording shows the Main-to-Work switch, zero-row loading state, delayed Main settlement being ignored, and the final Work result.

selected-agent-auth-quota.webm

Exact candidate: 074347e2bead6c633b62f243267add778ea452b5

Blacksmith Testbox:

The regression fails on the frozen base and passes on the exact candidate. Test coverage was audited rather than duplicated: one obsolete sidebar case was absorbed into the stronger ownership matrix, six existing declarations were strengthened, and two runnable chat cases were added for stale success and failure.

@clawsweeper

clawsweeper Bot commented Aug 29, 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: L maintainer Maintainer-authored PR labels Aug 29, 2026
@shakkernerd shakkernerd self-assigned this Aug 29, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 29, 2026
@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 10:52 PM ET / August 30, 2026, 02:52 UTC.

ClawSweeper review

What this changes

The PR clears and reloads Control UI identity, model-authentication, quota, and sidebar-alert state when a selected or retained-session agent changes, rejecting delayed results for the previous agent.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open. This MEMBER-authored, maintainer-labeled PR is the active fix for the linked Control UI ownership bug; the final patch centralizes the agent transition and no blocking defect was found. Exact-head CI is still in progress.

Priority: P1
Reviewed head: 9f3557865bc727afc0dce54c40bd18a5a30e172e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused, source-backed repair with meaningful boundary and browser coverage; final-head CI remains the last merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable: the PR author association is MEMBER. The PR body supplies before/after browser media and a recording as supporting context, but GitHub attachments could not be fetched in this network-restricted review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable: the PR author association is MEMBER. The PR body supplies before/after browser media and a recording as supporting context, but GitHub attachments could not be fetched in this network-restricted review.
Evidence reviewed 6 items Current-main defect: Current main updates the global chat agent and metadata binding, but models.authStatus completion accepts any result from the same connected client and epoch; it has no requested-agent or request-generation fence.
Canonical chat repair: The PR introduces one owner-transition path that clears agent-owned presentation, starts replacement metadata/auth/identity loads, and fences auth completions by client, connection epoch, request version, and resolved agent.
Retained-session sibling path: A retained pane whose fixed session changes owner invokes the same transition immediately after resolving its new session key, covering the prior review cycle's fixed-route gap.
Findings None None.
Security None None.

How this fits together

The Control UI obtains agent-specific identity and model-authentication data from the Gateway, then displays it in chat and sidebar alerts. Agent selection and fixed-session routing determine which agent is allowed to publish that data.

flowchart LR
  A[Agent selection or route change] --> B[Chat ownership transition]
  B --> C[Identity and auth requests]
  C --> D[Agent and request-version fence]
  D --> E[Chat identity and quota]
  D --> F[Sidebar auth alerts]
  E --> G[Control UI operator view]
  F --> G
Loading

Before merge

  • Resolve merge risk (P1) - The shared transition adds 49 net production lines; it is justified by the two distinct ownership entry points, but the final head’s relevant UI checks are still in progress and the PR body names an earlier candidate for its Testbox run.
Agent review details

Security

None.

PR surface

Source +49, Tests +461. Total +510 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 5 55 6 +49
Tests 7 717 256 +461
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 772 262 +510

Review metrics

Metric Value Why it matters
Production versus test delta production +49 net; tests +461 net The production growth establishes one shared ownership transition and request fence; the larger test change covers delayed completion and route-change behavior.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #129215
Summary: This PR is the active candidate fix for the linked current-main Control UI ownership defect.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Verify the final head (recommended)
    Let the focused chat-state and UI E2E checks finish green on commit 9f35578 before merging this asynchronous ownership change.

Technical review

Best possible solution:

Retain the single transition owner for global selection and fixed-session replacement, then merge once the final head’s focused Control UI checks confirm the delayed-response flow.

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

Yes—source-reproducible with high confidence: delay current main's models.authStatus response across a global-agent switch; current main fences only client and connection epoch. This read-only review did not execute the scenario.

Is this the best way to solve the issue?

Yes. A single agent-owner transition is the narrowest maintainable repair because both global selection and retained fixed-session replacement must clear and refetch the same agent-owned presentation.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: A delayed response can show an active operator the selected agent’s wrong authentication identity, plan, or quota.
  • merge-risk: 🚨 other: The patch changes shared asynchronous UI ownership state, so final-head validation should confirm selection and retained-route transitions do not regress presentation.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable: the PR author association is MEMBER. The PR body supplies before/after browser media and a recording as supporting context, but GitHub attachments could not be fetched in this network-restricted review.

Evidence

What I checked:

  • Current-main defect: Current main updates the global chat agent and metadata binding, but models.authStatus completion accepts any result from the same connected client and epoch; it has no requested-agent or request-generation fence. (ui/src/pages/chat/chat-state-refresh.ts:186, 3322b9552df8)
  • Canonical chat repair: The PR introduces one owner-transition path that clears agent-owned presentation, starts replacement metadata/auth/identity loads, and fences auth completions by client, connection epoch, request version, and resolved agent. (ui/src/pages/chat/chat-state-refresh.ts:98, 9f3557865bc7)
  • Retained-session sibling path: A retained pane whose fixed session changes owner invokes the same transition immediately after resolving its new session key, covering the prior review cycle's fixed-route gap. (ui/src/pages/chat/chat-pane-lifecycle.ts:635, 9f3557865bc7)
  • Sidebar sibling path: The sidebar clears the previous selected agent's auth presentation before its replacement task runs, while retaining unrelated cron and inbox state. (ui/src/components/sidebar-attention.ts:350, 9f3557865bc7)
  • Regression coverage: The changed tests exercise delayed success and failure, agent identity fencing, retained fixed-session ownership, sidebar alerts, and a mocked-browser global-agent switch with delayed Gateway responses. (ui/src/pages/chat/chat-state.test.ts:3947, 9f3557865bc7)
  • Area history: Recent merged Control UI chat-state work on this owner path includes Peter Steinberger's commit immediately preceding this PR's changes; the partial clone could not complete deeper follow-up history fetches offline. (ui/src/pages/chat/chat-state-refresh.ts:83, fe403619f9fe)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Confirm the relevant focused UI checks complete green on the current head.

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 (4 earlier review cycles)
  • reviewed 2026-08-29T23:03:05.640Z sha 074347e2bead6c633b62f243267add778ea452b5 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T00:41:25.631Z sha 4063d94 :: found issues before merge. :: [P1] Clear or fence prior assistant identity during agent selection
  • reviewed 2026-08-30T01:41:49.392Z sha fde36ed1a66ddd59843d9284142f6cbde6eeb6f7 :: found issues before merge. :: [P1] Refresh fixed-session data when bypassing the global rebind
  • reviewed 2026-08-30T02:17:32.909Z sha f1d29458e4282e9ca66f600a203e1c0bff6634c0 :: needs maintainer review before merge. :: none

@shakkernerd
shakkernerd force-pushed the shakkernerd/agent-quota-ownership branch from 074347e to 4063d94 Compare August 30, 2026 00:34
@shakkernerd

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 30, 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 rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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 30, 2026
@shakkernerd

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 30, 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 the merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. label Aug 30, 2026
@shakkernerd
shakkernerd force-pushed the shakkernerd/agent-quota-ownership branch from fde36ed to f1d2945 Compare August 30, 2026 02:11
@shakkernerd

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 30, 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 merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 30, 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. labels Aug 30, 2026
@shakkernerd
shakkernerd force-pushed the shakkernerd/agent-quota-ownership branch from f1d2945 to 9f35578 Compare August 30, 2026 02:47
@shakkernerd

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 30, 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:

@shakkernerd
shakkernerd merged commit b3f0c4b into main Aug 30, 2026
154 checks passed
@shakkernerd
shakkernerd deleted the shakkernerd/agent-quota-ownership branch August 30, 2026 02:58
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: Switching agents now keeps chat identity, authentication, quota, and sidebar alerts bound to the current agent.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 30, 2026
…aw#132894)

Switching selected agents now clears and reloads agent-owned auth, identity, account, plan, and quota state. Delayed prior-agent responses and routine Gateway snapshots can no longer overwrite the current view, and sidebar authentication attention follows the same ownership while fixed sessions and reconnect behavior remain unchanged.

Fixes openclaw#129215
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: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

[Bug]: Switching agents can display and apply another agent’s auth and quota status

1 participant