Skip to content

fix(anthropic): prevent setup-token failures - #187875

Merged
jalehman merged 1 commit into
openclaw:mainfrom
sasan1200:feat/anthropic-token-profile
Nov 2, 2026
Merged

jalehman merged 1 commit into
openclaw:mainfrom
sasan1200:feat/anthropic-token-profile

Conversation

@sasan1200

Copy link
Copy Markdown
Contributor

What Problem This Solves

  • Fixes setup-token login selecting an incompatible profile when the Anthropic default profile is configured for an API key.

User Impact

  • Users with this mismatch can repeat setup-token login to save a usable profile. Existing API-key declarations used by other agents are preserved.

Why This Change Was Made

  • Anthropic setup reuses compatible token or OAuth profile IDs and skips incompatible configured slots. Interactive and noninteractive setup use the same selection rule.

Evidence

  • HEAD 2767cdbdc5397eb87cda6d2ba16807c338aff699.

  • Published OpenClaw 2026.10.9 completes login but its native Gateway rejects the turn before a provider request.

  • At this head, login saves anthropic:setup-token, and a native Gateway turn completes using the same setup-token.

  • A transparent recording relay forwarded exactly one Anthropic request: HTTP 200, request ID req_011CgX5J7pApJqZpVr7FNkVX.

Native before and after

HEAD 8b18b5578f66eab1501cba4cef2310d88bfb9a41
OpenClaw 2026.10.9 (8b18b55)
[command path omitted]
{
  "ok": false,
  "runId": "ea988177-d393-4f0b-a664-37d6e93e6cd3",
  "origin": "gateway",
  "error": {
    "type": "cli_error",
    "message": "Explicit auth order for anthropic has no usable profiles."
  }
}
[openclaw] The CLI command failed.
[openclaw] For help, run `openclaw doctor`.
HEAD 2767cdbdc5397eb87cda6d2ba16807c338aff699
OpenClaw 2026.10.9 (2767cdb)
[command line omitted]
{
  "runId": "a9149573-6152-42ce-b726-e0f681ff8077",
  "status": "ok",
  "summary": "completed",
  "result": {
    "payloads": [
      {
        "text": "OAUTH_FLOW_186976_OK",
        "mediaUrl": null
      }
    ],
...
  • Command paths, credential entry, and unrelated output are omitted.

  • The upgrade check uses the published 2026.10.9 state, candidate Doctor, and repeated login.

  • Existing headers, an environment SecretRef, model settings, and the API-key declaration are unchanged; Doctor adds one empty agent entry.

  • Build, targeted typecheck, lint, and format checks pass.

  • The two regression cases fail on the original owner and pass with this change.

  • They assert returned profiles and the credential selector's results for separate API-key and token stores.

  • Focused test command: pnpm test extensions/anthropic/setup-token-auth.test.ts --maxWorkers=1; wall time 55.94 seconds.

  • Hosted CI: pending.

  • Closes [Bug]: setup-token login saves an unusable profile #187868.

@clawsweeper

clawsweeper Bot commented Oct 29, 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.

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-29T20:11:58.332130Z 2767cdb PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 29, 2026
@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Anthropic setup-token login skips incompatible configured profile IDs while preserving existing API-key declarations.

Example: anthropic:default is configured with mode api_key when a user logs in with a setup-token.

  • Before: Login saves a token as anthropic:default, which runtime selection rejects because its configured mode requires an API key.
  • After: Login saves anthropic:setup-token and preserves anthropic:default for API-key authentication.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused fix with relevant collision regressions, supplied shipped-entry-point verification, and stable-state upgrade evidence; no actionable finding remains.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Contributor-supplied output ties the reviewed Anthropic setup owner to repeated CLI login and a successful native Gateway model turn, contrasting the published-release rejection with an upstream HTTP 200 response; the regression cases also exercise real credential ordering for separate API-key and token stores.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Setup-token login reports success but saves a credential that cannot authenticate because its profile is declared API-key-only.
Reason: The patch restores documented setup-token authentication while preserving declarations used by other agents, without adding options or weakening runtime checks.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it repairs a current authentication bug with a focused change, relevant regression coverage, and supplied Gateway verification; no actionable defect was found.

Priority: P1
Reviewed head: 2767cdbdc5397eb87cda6d2ba16807c338aff699

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Anthropic plugin returns setup-token credentials to the shared login persistence and ordering owners, which make eligible credentials available to Gateway model requests.

flowchart LR
  A[Setup-token login] --> B[Anthropic profile selection]
  C[Configured profile declarations] --> B
  B --> D[Credential persistence]
  D --> E[Profile ordering and eligibility]
  E --> F[Gateway model request]
Loading

Technical review

Best possible solution:

Keep collision handling in the Anthropic setup owner and retain shared credential eligibility, persistence, and ordering contracts.

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

Current-main source establishes the collision from default profile naming to mode_mismatch rejection, and the contributor supplies matching published-release output; this read-only review executed no target code.

Is this the best way to solve the issue?

This is a small producer-side repair: both setup paths share the existing resolver, incompatible declarations remain intact, and compatible OAuth declarations retain their accepted token semantics.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 72dca273339a.

Provenance checked

  • Anthropic default setup-token profile identity changes intended behavior with a stated reason (unknown: The supplied provenance points to fix(pr): prevent parallel main refreshes from colliding #134014, which split deferred Anthropic auth execution while preserving authentication contracts; it does not establish when default naming originated. Path history, current-main blame, and the later provider refactor were inspected; git log --follow and creation-commit inspection reached unavailable historical objects, leaving earlier introduction unknown.)
  • Noninteractive setup profile declaration changes intended behavior with a stated reason (unknown: The previous path always wrote mode token; current eligibility and existing tests explicitly permit token credentials under oauth declarations, supporting preservation of the compatible global declaration.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 5c8a714 adds extensions/anthropic/auth.runtime.ts:37 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5c8a71498257; files: extensions/anthropic/auth.runtime.ts)
  • Ayaan Zaidi: Raw commit 653b1d8 adds src/commands/models/auth-profile-promotion.ts:29 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 653b1d8bba92; files: src/commands/models/auth-profile-promotion.ts)

PR surface

Source +18, Tests +70. Total +88 across 2 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 23 5 +18
Tests 1 70 0 +70
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 93 5 +88

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The supported setup-token login can report success while leaving affected existing installations unable to authenticate subsequent Gateway turns.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 execution lanes are retired.

Reviewed October 29, 2026, 4:26 PM ET / 20:26 UTC.

@roboclaw-bot roboclaw-bot added the clawtributors PR from a clawtributor label Oct 29, 2026
@jalehman
jalehman merged commit e72b356 into openclaw:main Nov 2, 2026
113 of 114 checks passed
@jalehman

jalehman commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 3, 2026
tideclaw-bot pushed a commit that referenced this pull request Nov 4, 2026
Required coverage: #189395, #187875, #186976, #182429, #184434, and remaining #180247.
Preserve stable transport and terminal-settlement owners. Include #190695 sampling parity and only the required symbol/export prerequisites. No broad Gemini transport cutover.

Source commits:
d6a1327
fe0f8d1
cd486ed
e72b356
807075d
28f5f25
ab7631a
9346376
054516f

Proof: 216 focused tests passed; dedicated pre-fix regressions failed. Scoped typechecks/lint/format passed. Fresh independent P0-P2 review clean. Live provider/native qualification remains pending.

Co-authored-by: Yiğit ERDOĞAN <[email protected]>
Co-authored-by: evomach <[email protected]>
Co-authored-by: Sasan <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: goslingmanagment <[email protected]>
Co-authored-by: Dmitriy <[email protected]>
Co-authored-by: Sukhdeep Johar <[email protected]>
Co-authored-by: Dallin Romney <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot added a commit that referenced this pull request Nov 5, 2026
Backport accepted fixes onto 2026.11.5-beta.2.

Base: bc061f9
Canonical source tree before commit: e6c0c39

These are adapted/squashed backports; do not claim each is an exact Git cherry-pick.
Source provenance (selected verified commits; other cohorts use their frozen patch/adoption manifests):

runtime-B:
b20a0cc fix(macos): connect with configured credentials despite stale app environment (#191468)
c4c0942 fix(update): failed updates from 10.7–10.9 crash in automatic migration recovery (#189713)
6aae408 fix(update): preserve recovery errors and async triage callbacks (#191495)
8910654 fix(macos): prevent first-launch Gateway failures after upgrades (#191436)
00b2ff4 fix: parent sessions miss child approvals with a custom session store (#189827)
c6142a8 fix: avoid copying managed plugin binaries during Gateway startup (#187865)
e72b356 fix(anthropic): avoid token profile collisions (#187875)
807075d fix(anthropic): set API workspace at login (#186976)
bafe92f fix(exec): preserve no-timeout results from macOS app nodes (#190729)
9b05a64 fix(imessage): use a PostgreSQL-safe recovery cursor key (#184919)
6ba197f fix: session search on PostgreSQL scans every transcript row instead of using the text index (#187909)
4f49aa5 fix(sessions): PostgreSQL session search scans every transcript row again after the 5th search on a connection (#188979)
de3936c fix(macos): Mac tab shows a blank or stale page when a load fails (#185432)
e977080 fix(macos): prevent duplicate voice sends and false sent feedback (#186271)

provider-compaction:
1b43c2e fix(compaction): preserve active request provenance (#180214)
7b0cfe3 fix(google): restore tool calls with Python keyword parameters (#191561)
9039ceb fix(ci): keep compaction attribution helpers internal
d6a1327 feat(google): use the Interactions API for Gemini Flash models (#189395)
fe0f8d1 fix(google): Gemini models ignore configured topP (#190695)

history:
c51d733 fix(sessions): stop expanding archive reads from exhausting memory (#190690)
3c8bd4d fix(sessions): page oversized earlier history instead of failing at 8 MiB (#188450)
b195f61 fix(sessions): page oversized transcript history in both directions (#188483)
b65482e fix(gateway): preserve older history across hidden message gaps (#188557)
3d4fc94 fix(sessions): avoid oversized listing and imported-history reads (#189284)
33e7baf fix(sessions): bound active accounting without blocking writers (#190182)
682ade7 fix: preserve chat history continuation metadata (#188612)

runtime-C:
7e005b0 fix(macos): keep secrets when a Gateway config save fails (#187734)
15cf738 fix(macos): keep Gateway auth when Tailscale exposure is turned off (#187664)
b53a06b perf(update): read candidate state inventory without copying the shared database (#187921)
970fc4e fix: restore CLI message sends with agent tool policies (#188058)
73ad731 fix: stop model fallback when session capability metadata changes (#179312)
32305db fix: subagent turns fail after session metadata changes (#183501)
d13bd0f fix(codex): include relay conversation instructions in trajectory (#189005)
e375530 fix: replies after a plugin reload from Control UI go to the session's last external chat (#190982)
9346376 fix: reasoning-only retry is refused by Anthropic as reasoning_extraction (#184434)

direct-auth-state:
1b15408 fix(models): keep the model list when one plugin-owned provider lacks a credential (#189014)
7d8dc60 fix: recover startup migration with retained worker index (#189023)

capacity:
41772e3 fix(worktrees): settle completed disk debt on refused postchecks (#188727)

command-once-189369:
8269137 fix(plugins): plugin commands that continue the agent run three times on native command turns (#189369)

pg-board-189564:
7232a8d fix(boards): publish widgets with PostgreSQL storage (#189564)

queued-edit-189869:
92b32ca fix: hold queued messages through inline edits (#189869)

Preserve source attribution from original commits. For a genuinely exact individual pick only, use the conventional (cherry picked from commit <sha>) line.
Full file-level provenance: coverage-manifest.json; reviewed patch hashes: artifact-registry.json.
No held136/native82 content adopted by this work. No release or full-candidate qualification claim.

Additional original-source identities (exact adapted hunk scope is in frozen artifacts):
release-guides-185258: 39c37e6 docs(release): define ledger-first hotfix routing (#185258)
UI-history: 10a6e4f fix(ui): scope provider-add discovery warning to its own provider (#188541), 3d7b4c4 fix(ui): never fail loading earlier chat history without a boundary (#188372)
obsolete-cache-188203: 90d82c2 fix: preserve completed reasoning and refill chat snapshots (#188203)
webhook-169778: b1f643f fix(startup): keep webhook decisions startup recorded for channels Doctor left pending (#169778)
schema-lease-188391: ba6cfcd fix(state): keep lease renewal independent of parent admission (#188391)
backfill-188976: c75a8a8 fix(gateway): stop session row backfill once the Gateway is closing (#188976)
canonical-disable-188846: 88b56ee fix(config): auto-enable reads and writes mixed-case plugin policy under the canonical id (#188846)
matrix-177272: 5a6d22c fix(matrix): stop seeding new thread sessions from the room transcript (#177272)
provider-hook-189059: 0588f51 fix(models): isolate every per-provider catalog failure (#189059)
unicode-189868: 87396e7 fix(oc-path): avoid reading and editing a different Unicode key (#189868)
replay-cohort: 2031044 fix(sessions): acknowledge committed input retries without duplicate turns (#188527), 9114431 fix: resume configured fallback after interrupted attempts (#188672)

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

Labels

clawtributors PR from a clawtributor extensions: anthropic P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S 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]: setup-token login saves an unusable profile

3 participants