Skip to content

fix(auth): preserve selected chat accounts when credentials disappear - #166985

Merged
vincentkoc merged 4 commits into
mainfrom
fix/missing-chat-auth-profile-pin
Oct 8, 2026
Merged

vincentkoc merged 4 commits into
mainfrom
fix/missing-chat-auth-profile-pin

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Chats could lose an explicitly selected account when its credentials were temporarily missing, even while another account for the same provider remained available.

User Impact

Compatible explicit selections now survive temporary credential absence and restoration in the same session. Automatic selections, incompatible-provider pins, and confirmed credential removal retain their existing cleanup behavior.

Why This Change Was Made

Reply selection now uses the canonical session-auth preservation policy. It prepares missing-account provider facts through the existing worker-backed auth-store owner, preserving credential-source precedence without synchronous SQLite reads on the Gateway thread. After the await, operator authority and selection identity are rechecked; canonical snapshot checks protect any later clear.

This narrow successor replaces the closed #155849. The change has net +96 production lines, +197 test lines, and one removed mock-baseline entry across ten files. Production growth is limited to asynchronous provider preparation, required exports, prepared-fact policy input, and selection currentness.

Evidence

  • The original baseline fails all three explicit-selection regression cases by deleting the selected account.
  • Focused native owner proof passed 78 cases across three whole-file runs: policy 12, worker 22, and chat 44. Coverage includes same-session restoration, automatic/incompatible cleanup, provider precedence, prepared absence without synchronous fallback, and selection or authority changes during the await. The final eight-brace-only cleanup preserves all production code and assertions.
  • Native mock-export guard, targeted formatting, diff checks, and the final exact curly diagnostic pass. The mock-baseline change removes one obsolete allowance.
  • Independent source/proof review and scoped autoreview cover the substantive repair. This is owner-level regression proof; no live-provider recovery is claimed. Final-head CI 37739068940 passed with 56 successful jobs, 24 skipped, and no failures. The final exact-head ClawSweeper review is ready with no actionable findings or remaining rank-up moves.

Review Follow-up

The synchronous-read finding is resolved through worker-owned provider preparation. Broader extraction of the already oversized auth store and chat tests is deferred to separate maintenance work to keep this fix within the requested narrow scope. Hosted line-cap diagnostics were warnings; no limit or baseline was raised. The separate full-config local lint refusal is retained and is not represented as a green full-lint result.

Observed single-worker native file durations: chat 6.376s/44 cases, policy 1.907s/12, worker 0.120s/22. The chat runner took 39.74s including setup. These are retained test costs, not benchmarks.

The successful CI run tested merge e83190b2168773777340bd29110453b9f51f0513, whose actual parents are base 8413457b09e654616de422f50ea2b5f3794ef53d and PR head e1c369527e98d58ee129a56c1eb396edcb6b56fb. Its tree is d49135f71d71c7bb787ce10b457a9ecb34dc775e.

@vincentkoc vincentkoc self-assigned this Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@vincentkoc
vincentkoc marked this pull request as ready for review October 8, 2026 05:37
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. 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. labels Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 8, 2026, 2:59 AM ET / 06:59 UTC (Revision 3).

ClawSweeper review

What this changes

The branch preserves compatible, explicitly selected chat accounts during credential absence and prepares missing-account provider facts through the existing asynchronous auth-store owner.

Example: A user sends a message with openai:account-b selected while only openai:account-a is available.

  • Before: Reply model selection clears openai:account-b from the chat.
  • After: The chat retains openai:account-b and keeps that selection when its credentials return.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The repair is focused and source-correct, with useful regression coverage, but its behavioral evidence remains unit-level.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate. Its reported after-fix evidence exercises the session policy, mocked worker reads, and reply-selection owner; it does not establish live-provider recovery. No stored schema, serializer, or credential representation changes are introduced.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A chat forgets the account the user selected when its credentials temporarily disappear.
Reason: The patch restores the documented same-provider account-selection contract through existing owners without adding a new product surface.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still clears missing shared-account selections. The prior synchronous-read finding is resolved, and this review found no actionable functional or security defect. Maintainer authorship also prevents automatic closure.

Priority: P2
Reviewed head: e1c369527e98d58ee129a56c1eb396edcb6b56fb

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped chat flow demonstrates credential disappearance and restoration with the original account retained; the supplied evidence is owner-level regression testing, and reported baseline failures were not rerun in this read-only review.
Agent review details

How this fits together

Reply preparation combines the chat's saved model and account selections with available credentials before authentication runs. The session policy decides whether to retain the account, while the auth store supplies recorded credential-provider facts.

flowchart TD
  A[Chat message] --> B[Reply model selection]
  C[Saved account selection] --> B
  B --> D[Worker-backed credential facts]
  D --> E[Canonical session policy]
  E --> F[Retain compatible explicit selection]
  E --> G[Clear automatic or incompatible selection]
  F --> H[Authentication and recovery]
  G --> H
Loading

Technical review

Best possible solution:

Keep account-preservation decisions in the canonical session policy and consume worker-prepared credential facts before authentication handles recovery.

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

Yes, source provides a high-confidence path: select openai:account-b, remove its credentials while account-a remains, then run reply model selection; current main clears the selected pin. No runtime reproduction was executed during this review.

Is this the best way to solve the issue?

Yes, the patch repairs the destructive caller using the existing preservation policy and worker-backed read owner, with focused concurrency guards and no new configuration or stored format.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6fc16a80b9fb.

Provenance checked

  • src/sessions/auth-profile-preservation.ts keeps the original intent (fix(model-picker): preserve compatible auth profiles #117550: Centralize model-change account preservation, prefer recorded credential metadata, and clear incompatible selections.)
  • src/auto-reply/reply/model-selection.ts keeps the original intent (feat(multi-user): add provider-neutral connected accounts #134970: Keep chat account selections session-sticky and prevent missing personal credentials from silently selecting another participant's account.)
  • src/agents/auth-profiles/session-override.ts keeps the original intent (9c85b63: Keep running turns on their original session store; the existing writer already supports snapshot-checked persistence.)

Testing

Proof path: unit tests only. Added test files: 3.

Security

None.

Evidence

What I checked:

  • Current main still contains the defect: Current main clears an ineligible missing shared profile; only missing personal accounts receive the existing preservation exception. (src/auto-reply/reply/model-selection.ts:511, 6fc16a80b9fb)
  • Introduced patch and resolved prior finding: The introduced delta uses prepared worker reads for missing explicit shared pins, passes completed absence into the existing preservation policy, and rechecks operator authority and selection identity after the await. (src/agents/auth-profiles/store.ts:1125, e1c369527e98)
  • Existing account-selection contract: The credential semantics documentation already specifies retaining explicit same-provider selections when credentials disappear, while clearing stale automatic and incompatible selections. Public docs: docs/auth-credential-semantics.md. (docs/auth-credential-semantics.md:233, e1c369527e98)
  • Current-main integration assessment: Inspected production changes since the merge base are separate refactors in session mutation, store composition/publication, and model selection; they do not overlap the introduced preservation hunks. Live GitHub reports the exact head cleanly mergeable. The supplied test merge has stale parents and is not used as merged-tree proof. (src/auto-reply/reply/model-selection.ts, e1c369527e98)
  • Focused regression coverage: Added cases check same-session restoration for user, user-link, and legacy explicit selections, automatic/incompatible cleanup, provider precedence without synchronous reads, and selection or authority changes during preparation. The PR body reports three baseline failures and 78 passing owner-level cases; this read-only review did not execute them. (src/auto-reply/reply/model-selection.test.ts:876, e1c369527e98)
  • Prior rank-up dispositions: The updated body records single-worker file durations of 6.376s for chat, 1.907s for policy, and 0.120s for worker cases, with 39.74s chat runner wall time. It explicitly defers broader oversized-file extraction without raising limits; that optional extraction would expand this focused repair. (e1c369527e98)

Likely related people:

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

PR surface

Source +96, Tests +197, Other -1. Total +292 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 6 104 8 +96
Tests 3 199 2 +197
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 10 303 11 +292

Root-cause cluster

Relationship: canonical
Canonical: #166985
Summary: This narrow successor owns the chat-selection repair previously proposed in a broader closed, unmerged branch.

Members:

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

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove merge-risk: 🚨 availability: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This fixes a bounded account-selection persistence bug when credentials are temporarily unavailable.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-08T05:44:09.984Z sha bf4352f :: needs changes before merge. :: [P2] Keep missing-pin provider reads off the Gateway thread
  • reviewed 2026-10-08T06:21:20.912Z sha 0aa5ab1 :: blocked before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M and removed size: S labels Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: e1c369527e98d58ee129a56c1eb396edcb6b56fb
  • Maintainer: @vincentkoc
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/auth-profiles.runtime.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/session-override.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/store-runtime.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/store.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper status

@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper status:

  • Current PR: 166985
  • Branch: fix/missing-chat-auth-profile-pin
  • ClawSweeper PR: no
  • Automerge: not-enabled
  • Automerge job: jobs/openclaw/inbox/automerge-openclaw-openclaw-166985.md
  • Merge state: CLEAN
  • Checks: SKIPPED:51 SUCCESS:76 NEUTRAL:1

@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 8, 2026
@vincentkoc
vincentkoc merged commit af55058 into main Oct 8, 2026
143 checks passed
@vincentkoc
vincentkoc deleted the fix/missing-chat-auth-profile-pin branch October 8, 2026 07:05
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 9, 2026
…openclaw#166985)

* fix(auth): retain selected chat account while credentials are missing

* fix(auth): prepare missing-profile providers off-thread

* test(auth): preserve runtime mock exports

* test(auth): brace conditional fixture setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: M 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.

1 participant