Skip to content

fix(auth): prioritize round-robin over lastGood for multi-account rotation - #281

Merged
steipete merged 2 commits into
openclaw:mainfrom
mukhtharcm:fix/auth-round-robin-priority
Jan 6, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
mukhtharcm:fix/auth-round-robin-priority

Conversation

@mukhtharcm

@mukhtharcm mukhtharcm commented Jan 6, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes multi-account OAuth rotation so accounts actually alternate instead of always using the same one.

Problem

When multiple OAuth accounts are configured for a provider (e.g., 2 Google Antigravity accounts), the round-robin rotation was not working. All requests used the same account.

Root Cause

In resolveAuthProfileOrder(), the code checked lastGood after sorting and always put it first:

if (lastGood && deduped.includes(lastGood)) {
    return [lastGood, ...deduped.filter((entry) => entry !== lastGood)];
}

Once any profile succeeded (became lastGood), it would always be selected first, defeating the round-robin logic entirely.

Solution

  • Remove lastGood prioritization - let round-robin handle selection
  • Only use explicit configuredOrder when user specifies it in config
  • orderProfilesByMode() now always runs, sorting by lastUsed (oldest first)
  • preferredProfile still takes priority (for explicit user choice)

Note on clawdbot configure

Currently clawdbot configure automatically creates an auth.order key when adding multiple accounts. This explicit order takes precedence over round-robin (by design - explicit config = user intent).

Users who want round-robin should remove the order key from their clawdbot.json:

"auth": {
  "profiles": { ... },
  "order": { ... }  // <- remove this for round-robin
}

A follow-up issue could update the configure wizard to not create order by default.

Testing

Tested with 2 Google Antigravity accounts. Verified alternating usage - each request picks the account with oldest lastUsed timestamp.

Related

Follow-up fix to PR #269 (multi-account OAuth support).

…ation

When multiple OAuth accounts are configured, the round-robin rotation was
not working because lastGood was always prioritized, defeating the sort by
lastUsed.

Changes:
- Remove lastGood prioritization in resolveAuthProfileOrder
- Always apply orderProfilesByMode (sorts by lastUsed, oldest first)
- Only respect configuredOrder when explicitly set in config
- preferredProfile still takes priority for explicit user choice

Tested with 2 Google Antigravity accounts - verified alternating usage.

Follow-up to PR openclaw#269.
@steipete
steipete merged commit 9e49c76 into openclaw:main Jan 6, 2026
@steipete

steipete commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

Thanks @mukhtharcm — merged. I’m following up to (1) update the auth profile ordering tests to match the new round-robin behavior and (2) adjust so it doesn’t write by default (round-robin unless explicitly pinned).

@steipete

steipete commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

Thanks @mukhtharcm — merged.

Follow-up on main:

  • Update auth profile ordering tests to match the new round-robin behavior.
  • Adjust clawdbot configure so it doesn’t write auth.order by default (round-robin unless explicitly pinned).

dgarson added a commit to dgarson/clawdbot that referenced this pull request Feb 9, 2026
dgarson added a commit to dgarson/clawdbot that referenced this pull request Feb 22, 2026
heatherstew44-maker pushed a commit to heatherstew44-maker/openclaw that referenced this pull request Mar 8, 2026
heatherstew44-maker pushed a commit to heatherstew44-maker/openclaw that referenced this pull request Mar 8, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…ation (openclaw#281)

* fix(auth): prioritize round-robin over lastGood for multi-account rotation

When multiple OAuth accounts are configured, the round-robin rotation was
not working because lastGood was always prioritized, defeating the sort by
lastUsed.

Changes:
- Remove lastGood prioritization in resolveAuthProfileOrder
- Always apply orderProfilesByMode (sorts by lastUsed, oldest first)
- Only respect configuredOrder when explicitly set in config
- preferredProfile still takes priority for explicit user choice

Tested with 2 Google Antigravity accounts - verified alternating usage.

Follow-up to PR openclaw#269.

* style: fix formatting
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
…ation (openclaw#281)

* fix(auth): prioritize round-robin over lastGood for multi-account rotation

When multiple OAuth accounts are configured, the round-robin rotation was
not working because lastGood was always prioritized, defeating the sort by
lastUsed.

Changes:
- Remove lastGood prioritization in resolveAuthProfileOrder
- Always apply orderProfilesByMode (sorts by lastUsed, oldest first)
- Only respect configuredOrder when explicitly set in config
- preferredProfile still takes priority for explicit user choice

Tested with 2 Google Antigravity accounts - verified alternating usage.

Follow-up to PR openclaw#269.

* style: fix formatting
muneebhashone pushed a commit to muneebhashone/clawdbot that referenced this pull request Aug 25, 2026
…ation (openclaw#281)

* fix(auth): prioritize round-robin over lastGood for multi-account rotation

When multiple OAuth accounts are configured, the round-robin rotation was
not working because lastGood was always prioritized, defeating the sort by
lastUsed.

Changes:
- Remove lastGood prioritization in resolveAuthProfileOrder
- Always apply orderProfilesByMode (sorts by lastUsed, oldest first)
- Only respect configuredOrder when explicitly set in config
- preferredProfile still takes priority for explicit user choice

Tested with 2 Google Antigravity accounts - verified alternating usage.

Follow-up to PR openclaw#269.

* style: fix formatting
zeekay pushed a commit to Dream-AI-4444/bot that referenced this pull request Sep 11, 2026
…ation (openclaw#281)

* fix(auth): prioritize round-robin over lastGood for multi-account rotation

When multiple OAuth accounts are configured, the round-robin rotation was
not working because lastGood was always prioritized, defeating the sort by
lastUsed.

Changes:
- Remove lastGood prioritization in resolveAuthProfileOrder
- Always apply orderProfilesByMode (sorts by lastUsed, oldest first)
- Only respect configuredOrder when explicitly set in config
- preferredProfile still takes priority for explicit user choice

Tested with 2 Google Antigravity accounts - verified alternating usage.

Follow-up to PR openclaw#269.

* style: fix formatting
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
…ation (openclaw#281)

* fix(auth): prioritize round-robin over lastGood for multi-account rotation

When multiple OAuth accounts are configured, the round-robin rotation was
not working because lastGood was always prioritized, defeating the sort by
lastUsed.

Changes:
- Remove lastGood prioritization in resolveAuthProfileOrder
- Always apply orderProfilesByMode (sorts by lastUsed, oldest first)
- Only respect configuredOrder when explicitly set in config
- preferredProfile still takes priority for explicit user choice

Tested with 2 Google Antigravity accounts - verified alternating usage.

Follow-up to PR openclaw#269.

* style: fix formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants