Skip to content

fix(onboard): keep provider credentials with named first agents - #127572

Merged
steipete merged 2 commits into
mainfrom
codex/onboarding-named-agent-auth-owner
Aug 21, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/onboarding-named-agent-auth-owner

Conversation

@steipete

@steipete steipete commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users onboarding their first agent with --agent-name and a provider credential would receive a successful setup result even though the credential was saved under the unrelated main agent. The named agent then had no auth profile for its configured model.

Both openclaw onboard and openclaw setup were affected in interactive and noninteractive flows. The failure reproduces with multiple provider plugins and with both plaintext credentials and SecretRefs.

Why This Change Was Made

Onboarding prepares provider authentication before creating the first agent, which is required to avoid writing agent state when provider validation fails. Carry the authoritative pending first-agent identity and selected workspace through the existing shared setup-target owner instead of resolving the still-uncreated agent from runtime defaults.

Interactive setup determines first-agent provenance from the pre-migration source roster, so synthetic runtime main placeholders cannot steal ownership. Noninteractive setup only supplies a pending identity when the original roster is empty. Existing explicit/system-agent fleets, authored minimal main agents, staged provider-profile persistence, and provider workspace discovery keep their existing ownership contracts.

Generic API-key, token, and setup-token provider normalization now retains that same selected workspace in both interactive and noninteractive setup. Interactive legacy-provider aliases and deprecated-provider guidance also resolve against the selected workspace while retaining the existing untrusted-plugin restriction. This addresses both actionable ClawSweeper findings and removes duplicated context construction.

User Impact

Naming a first agent during onboarding now stores provider credentials in that agent's own SQLite auth-profile database. Setup no longer creates an orphaned main credential database, and existing installations retain their configured agent ownership.

Evidence

  • Before: real isolated openclaw onboard --non-interactive --accept-risk --agent-name robby --auth-choice nvidia-api-key --nvidia-api-key <fixture> ... --json exited successfully with only robby configured, but nvidia:default existed only in agents/main/agent/openclaw-agent.sqlite and the robby auth database did not exist.
  • After: the same actual CLI flow stores nvidia:default only in agents/robby/agent/openclaw-agent.sqlite; the main database is absent and the configured/JSON workspace remains the requested workspace.
  • Repeated the actual CLI and SQLite proof for both onboard and setup, NVIDIA and Gemini providers, plaintext and env-backed SecretRef profiles, normalized agent names, the default main path, and existing explicit/system-agent fleets.
  • Real interactive PTY proof starts with a synthetic runtime main roster but forwards the normalized named agent ID, its canonical agent directory, and the exact selected workspace to the real provider-auth owner.
  • A genuinely authored minimal agents.entries.main={} followed by onboarding with --agent-name robby remains owned by main, proving runtime placeholders and authored rosters are distinguished by authoritative provenance.
  • Existing owner regressions cover pending targets, synthetic/bootstrap roster forms, explicit single-agent fleets, existing legacy fleets, normalized agent IDs, auth-before-agent-creation ordering, provider workspace propagation, and staged interactive profile ownership.
  • Actual generic --auth-choice apiKey --token-provider nvidia onboarding now forwards the exact selected workspace while persisting its profile only under the named agent. Executable workspace-only provider fixtures cover generic API-key, token, and setup-token choices, plus workspace-scoped legacy/deprecated provider handling.
  • Both ClawSweeper rank-up items are addressed: interactive and noninteractive token-provider normalizers retain the target workspace, with focused caller-boundary regressions. The follow-up simplifies the owning production code by eight net lines.
  • All eight changed files pass oxfmt --check, oxlint --tsconfig tsconfig.json, git diff --check, and an offline TruffleHog scan. Independent Codex autoreview completed with no actionable findings.

AI-assisted; all source, storage effects, provider ownership, and user-visible behavior were independently reviewed.

@clawsweeper

clawsweeper Bot commented Aug 21, 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 commands Command implementations size: S maintainer Maintainer-authored PR labels Aug 21, 2026
@steipete
steipete marked this pull request as ready for review August 21, 2026 21:10
@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. 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 Aug 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 6:06 PM ET / 22:06 UTC.

ClawSweeper review

What this changes

The PR stores first-agent onboarding credentials under the named agent and forwards that agent’s workspace through provider-choice discovery in interactive and noninteractive setup.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open: current main still resolves setup auth through the default target before a named first agent exists. This branch carries the pending target and workspace through interactive and noninteractive provider setup, and it addresses both findings from the prior review; no new blocking defect was found.

Priority: P1
Reviewed head: a896a5a4aa343e0859247e5745405747c0f42587

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The owner-boundary repair and focused regression coverage address the prior findings with credible real-flow evidence.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body documents after-fix isolated CLI and SQLite checks for both setup paths, providers, plaintext and SecretRef credentials, plus interactive PTY coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body documents after-fix isolated CLI and SQLite checks for both setup paths, providers, plaintext and SecretRef credentials, plus interactive PTY coverage.
Evidence reviewed 6 items Current-main defect: Current main has no pending-agent input in setup-target resolution, so it falls through to the default resolved agent before named-agent creation.
Interactive owner boundary: The branch resolves the pending named target before auth-store creation, provider discovery, provider auth preparation, and model selection.
Noninteractive owner boundary: The branch supplies a pending target only when the original roster is empty, preserving existing configured-roster ownership.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw onboard --help

Result: PASS (completed)

pnpm openclaw onboard --help
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127572-AKC2HS/target$ pnpm openclaw onboard --help
$ node scripts/run-node.mjs onboard --help
pnpm openclaw onboard --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 111.69 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 14.6s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4452ms (slowest: built plugin control-plane loads 3709ms)

OpenClaw 2026.8.1 (a896a5a) — All your chats, one OpenClaw.

Usage: openclaw onboard [options] [command]

Guided setup for auth, models, Gateway, workspace, channels, and skills

Options:
  --accept-risk                            Acknowledge that agents are powerful and full system access is risky (required for --non-interactive) (default:
                                           false)
  --agent-name ‹name›                      Name for the first 
… output truncated …

Assertions:

  • PASS expect_output: Usage:
  • PASS expect_output: --agent-name

How this fits together

Onboarding chooses an agent and workspace before provider authentication is persisted. That target controls provider discovery and the per-agent SQLite auth-profile database consumed by later model runs.

flowchart LR
  A[Onboarding options] --> B[Pending first agent]
  B --> C[Setup target resolution]
  C --> D[Provider choice normalization]
  D --> E[Provider authentication]
  E --> F[Per-agent auth profile]
  F --> G[Configured model runs]
Loading

Before merge

  • Resolve merge risk (P1) - Credential ownership and provider lookup are upgrade-sensitive; rebase and exact-head validation should preserve the empty-roster versus existing-roster distinction.
  • Resolve merge risk (P1) - The reviewed PR delta is production +12 and tests +247; the added ownership context appears necessary, but it should not grow further without absorbing duplicated target construction.
  • Complete next step (P2) - The prior actionable findings are addressed; remaining work is normal exact-head CI and rebase validation, not an automated repair.
Agent review details

Security

None.

PR surface

Source +12, Tests +247. Total +259 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 7 45 33 +12
Tests 5 256 9 +247
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 301 42 +259

Review metrics

Metric Value Why it matters
Production versus test delta production +12, tests +247 The production growth carries the target/workspace ownership contract; the larger test delta covers target selection and provider normalization regressions.

Merge-risk options

Maintainer options:

  1. Refresh against current main (recommended)
    Rebase the clean branch and retain focused verification that named first-agent credentials and workspace-only providers resolve to the intended agent.

Technical review

Best possible solution:

Keep one canonical pending-first-agent target for empty rosters, retain existing explicit/authored roster ownership, and validate the rebased head with the focused onboarding and provider-choice tests plus the documented isolated CLI/SQLite flow.

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

Yes, from source: current main resolves the default target before named-agent creation, while the focused regressions model a workspace-only provider and named-agent auth target. The supplied PR body also describes isolated CLI and SQLite before/after runs, though this read-only review did not execute them.

Is this the best way to solve the issue?

Yes. Carrying the pending first-agent identity through the existing setup-target owner repairs both credential persistence and workspace-scoped provider discovery without changing established explicit-roster ownership.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body documents after-fix isolated CLI and SQLite checks for both setup paths, providers, plaintext and SecretRef credentials, plus interactive PTY coverage.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body documents after-fix isolated CLI and SQLite checks for both setup paths, providers, plaintext and SecretRef credentials, plus interactive PTY coverage.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Normal onboarding can otherwise report success while persisting provider credentials under an unusable agent.
  • merge-risk: 🚨 compatibility: The patch changes how setup selects an agent and workspace before first-agent creation.
  • merge-risk: 🚨 auth-provider: The patch changes provider discovery context and the agent-scoped destination for auth profiles.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body documents after-fix isolated CLI and SQLite checks for both setup paths, providers, plaintext and SecretRef credentials, plus interactive PTY coverage.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body documents after-fix isolated CLI and SQLite checks for both setup paths, providers, plaintext and SecretRef credentials, plus interactive PTY coverage.

Evidence

What I checked:

Likely related people:

  • xingzhou: Current-main blame attributes the setup-target implementation to this contributor; the available local history is shallow. (role: recent area contributor; confidence: low; commits: ee79b0a49ae4; files: src/commands/onboard-agent-target.ts, src/commands/auth-choice.apply.ts)

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 (1 earlier review cycle)
  • reviewed 2026-08-21T21:16:29.258Z sha 42d6e08 :: needs changes before merge. :: [P2] Propagate workspace to interactive provider normalization | [P2] Preserve the target workspace in noninteractive normalization

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed 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 Aug 21, 2026
@steipete
steipete merged commit c801579 into main Aug 21, 2026
246 checks passed
@steipete
steipete deleted the codex/onboarding-named-agent-auth-owner branch August 21, 2026 22:21
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 22, 2026
…claw#127572)

* fix(onboard): keep provider credentials with named first agents

* fix(onboard): preserve workspace in provider choice normalization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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