Skip to content

fix(agents): point a missing API key at an auth command, not at agent creation - #127011

Merged
steipete merged 1 commit into
mainfrom
steipete/provider-auth-hint
Aug 21, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/provider-auth-hint

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The generic provider-missing-auth error recommends a command that cannot fix the problem it describes:

$ openclaw memory index
Memory index failed (main): No API key found for provider "openai".
Auth store: <state>/state/openclaw.sqlite (agentDir: <state>/agents/main/agent).
Configure auth for this agent (openclaw agents add <id>) or copy only portable static
auth profiles from the main agentDir. | missing-provider-auth
$ echo $?
1

openclaw agents add <id> creates a new agent. It does nothing about a missing provider credential. An operator who follows it ends up with a second agent that also has no key.

On the install where I reproduced this there is exactly one configured agent, main, and it is correctly configured. Nothing about agents add applies.

Doctor, diagnosing the identical condition on the same install, gets it right:

◇  Memory search ───────────────────────────────────────────────────────╮
│  Memory search provider is set to "openai" but no API key was found.  │
│  - Set OPENAI_API_KEY in your environment                             │
│  - To disable: openclaw config set memory.search.enabled false        │
│  Verify: openclaw memory status --deep                                │

So the command that actually failed gives worse and more misleading guidance than the advisory check does for the same state.

Why This Change Was Made

The old sentence conflated two situations and named a command that fits neither:

  1. The provider has no credential anywhere — needs a real auth command.
  2. This agent has no profile although another does — the "copy only portable static auth profiles from the main agentDir" clause, which reads like the case the sentence was originally written for.

models auth paste-api-key --provider <id> is the suggestion rather than models auth login. login runs a provider plugin auth flow, but this generic fallback is precisely the path taken when no plugin owns the provider, when the model is inline or custom-configured, when allowAuthProfileFallback is false, or when a plugin-owned provider returns no specialized message. Pasting a key resolves every "No API key found" case this fallback can produce; login does not. The --agent <id> hint is folded in for non-default agents, and the whole thing routes through formatCliCommand so it stays correct under --profile or --container.

One message rather than two. Distinguishing situation 1 from situation 2 would require reading other agents' auth stores: the store in scope is the failing agent's, and cfg does not reveal credentials held in another agent's database. That is a real cross-agent read this resolver does not perform today, and it is not worth adding for a message. The combined sentence is correct for both cases, so it stays one sentence.

User Impact

No API key found for provider "openai". Auth store: <path> (agentDir: <path>).
Configure an API key (openclaw models auth paste-api-key --provider openai;
add --agent <id> for a non-default agent) or copy only portable static auth
profiles from the main agentDir.

Production LOC: +1/-1, net 0.

Evidence

Reproduced end to end on a real pnpm build dist in an isolated OPENCLAW_STATE_DIR + HOME, then verified the corrected output on a rebuilt binary. A container-hint probe confirms the profile/container formatting works: openclaw --container validator-box models auth paste-api-key --provider openai.

The suggested command was checked against the CLI rather than assumed — models auth paste-api-key takes a required --provider <name> and an optional --agent <id>, and is described as "Paste an API key into auth-profiles.json and update config", which matches the failure exactly.

Tests: src/agents/model-auth.profiles.test.ts failed as intended before the fix (1 failed / 79 passed) and passes after (80/80, re-run independently here). A grep-derived sweep of auth and error-consumer suites covered 20 files / 499 tests, all passing. New coverage pins the corrected command and asserts the message no longer contains openclaw agents add, so it cannot regress to advice that does not address the failure.

node scripts/check-changed.mjs: exit 0 (Testbox run 32446450654, 13m05s). pnpm build: passed (3m59s). Formatting and git diff --check: pass. $autoreview: clean, no accepted or actionable findings, correctness 0.99.

One proof note: on the worker's machine an ambient OPENAI_API_KEY masked the condition, so it explicitly set memory.search.provider=openai and unset that variable to recreate it. My original reproduction needed neither — openai is already the memory-search default on a fresh Anthropic-only install.

No second provider-auth message recommending agents add exists; the remaining openclaw agents add references in the tree are all about actually creating agents.

@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.

@steipete
steipete marked this pull request as ready for review August 21, 2026 04:39
@steipete
steipete requested a review from a team as a code owner August 21, 2026 04:39
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS maintainer Maintainer-authored PR labels Aug 21, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. 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, 1:14 AM ET / 05:14 UTC.

ClawSweeper review

What this changes

The PR changes generic missing-provider-key guidance to recommend models auth paste-api-key and adds a regression assertion for that message.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for normal maintainer review. The patch correctly replaces a recovery command that creates an agent with the existing API-key flow; the branch is behind current main and exact-head checks remain incomplete. Likely related people: steipete (medium confidence; available shallow history attributes the affected path to this work).

Priority: P2
Reviewed head: 23c1ffd0406271c802375391bf2091f80ac6267d

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) The focused correction matches the registered CLI contract and has direct regression coverage.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository context identifies a maintainer-authored PR, so the external-contributor proof gate does not apply; the PR body nevertheless supplies an isolated after-fix terminal proof claim.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository context identifies a maintainer-authored PR, so the external-contributor proof gate does not apply; the PR body nevertheless supplies an isolated after-fix terminal proof claim.
Evidence reviewed 7 items Current-main behavior: Current main still tells an operator to run openclaw agents add &lt;id> from the generic missing-provider-auth branch.
Proposed owner-boundary repair: The PR changes only the generic fallback message to point at the existing API-key command and retains agent-specific guidance.
CLI contract: paste-api-key requires a provider, accepts an agent option, stores an API-key profile in that agent directory, updates config, and refreshes gateway auth state.
Findings None None.
Security None None.

Live Verification

Command: OPENCLAW_STATE_DIR=/tmp/openclaw-auth-proof-127011 HOME=/tmp/openclaw-auth-home-127011 OPENAI_API_KEY= pnpm openclaw memory index

Result: FAIL (partial) — step 3 expect_output models auth paste-api-key --provider openai: expected terminal output was not visible within 30 seconds: "models auth paste-api-key --provider openai"

runner@runnervm76f27:/tmp/clawsweeper-live-proof-127011-tZ2BGx/target$ OPENCLAW_STATE_DIR=/tmp/openclaw-auth-proof-127011 HOME=/tmp/openclaw-auth-home-127011 OP
ENAI_API_KEY= pnpm openclaw memory index
$ node scripts/run-node.mjs memory index
OPENCLAW_STATE_DIR=/tmp/openclaw-auth-proof-127011 HOME=/tmp/openclaw-auth-home-127011 pnpm openclaw config set memory.search.provider openai
[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 106.92 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
OPENCLAW_STATE_DIR=/tmp/openclaw-auth-proof-127011 HOME=/tmp/openclaw-auth-home-127011 OPENAI_API_KEY= pnpm openclaw memory index
[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 13.1s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 3877ms (slowest: built plugin control-plane loads 3258ms)
│
◇

OpenClaw 2026.8.1 (23c1ffd) — Ah, the fruit tree company!

│


Assertions:

  • FAIL expect_output: models auth paste-api-key --provider openai

How this fits together

Provider-backed agent operations resolve credentials from the selected agent’s auth store and configuration. If none is available, the resolver emits an operator-facing recovery message before the provider request can proceed.

flowchart LR
A[Provider-backed operation] --> B[Agent auth resolver]
B --> C{Credential available?}
C -->|Yes| D[Provider request proceeds]
C -->|No| E[Missing-auth recovery message]
E --> F[API-key configuration command]
Loading

Before merge

  • Resolve merge risk (P1) - The PR is behind current main and its exact-head checks are still in progress, so it needs a refresh before landing.
  • Complete next step (P2) - Refresh against current main and wait for exact-head CI; no mechanical repair is identified.
Agent review details

Security

None.

PR surface

Source 0, Tests +4. Total +4 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 1 4 0 +4
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 5 1 +4

Review metrics

Metric Value Why it matters
Production versus regression coverage production 0 net; tests +4 The patch replaces one recovery string and adds focused coverage without expanding runtime behavior.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the generic API-key recovery hint, rebase onto current main, and land once the refreshed exact head is green.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the generic API-key recovery hint, rebase onto current main, and land once the refreshed exact head is green.

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

Yes—source establishes the generic no-key branch, and the colocated test reaches it with no OpenAI key; the PR body also describes an isolated dist reproduction.

Is this the best way to solve the issue?

Yes—the existing API-key command owns profile persistence and selected-agent targeting, whereas agent creation cannot remedy a missing credential.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: The PR corrects operator guidance on a bounded provider-auth recovery path.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository context identifies a maintainer-authored PR, so the external-contributor proof gate does not apply; the PR body nevertheless supplies an isolated after-fix terminal proof claim.

Evidence

What I checked:

Likely related people:

  • steipete: The available shallow history and blame attribute the resolver and CLI-contract snapshot to this contributor; parent history is unavailable in this checkout. (role: recent area contributor; confidence: medium; commits: 23c1ffd04062; files: src/agents/model-auth-provider.ts, src/agents/model-auth.profiles.test.ts, src/cli/models-cli.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-21T04:44:38.432Z sha a1efc0da5e277e11e39334c0a35f2f99a579ce03 :: needs maintainer review before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

CI here failed on check-lint-core-5, which is pre-existing breakage on main rather than anything in this change — ui/src/pages/cron/view.test.ts crossed the 1000 code-line max-lines cap at #126945, and runs on main itself fail the same way (for example run 32447829557 at 9bc772ba506). Local oxlint on this PR's two files is clean.

Fixing it separately in #127018 so it unblocks every other open PR too, not just this one. Will rebase here once that lands.

@steipete
steipete force-pushed the steipete/provider-auth-hint branch from a1efc0d to 23c1ffd Compare August 21, 2026 05:08
… creation

The generic provider-missing-auth error told operators to create a new agent:

    No API key found for provider "openai". Auth store: <path> (agentDir: <path>).
    Configure auth for this agent (openclaw agents add <id>) or copy only portable
    static auth profiles from the main agentDir.

`openclaw agents add <id>` creates an agent. It does nothing about a missing
provider credential, so following it leaves you with a second agent that also
has no key.

Reproduced on a real build: a fresh install with only an Anthropic key, then
`openclaw memory index`. There is exactly one configured agent, `main`, and it is
correctly configured -- nothing about `agents add` applies. Doctor, diagnosing the
identical condition on the same install, gets it right, listing how to supply the
key and how to disable memory search. The command that actually failed gave worse
advice than the advisory check.

`models auth paste-api-key --provider <id>` is the suggestion rather than
`models auth login`, because `login` requires an owning provider plugin while this
generic fallback is also reached for pluginless, inline, and custom providers, and
for a plugin-owned provider that returns no specialized message. Pasting a key
resolves every "No API key found" case the fallback can produce. The `--agent`
hint is folded in for non-default agents, and `formatCliCommand` keeps the command
correct under a profile or container.

One message rather than two: distinguishing "no credential anywhere" from "this
agent lacks a profile another agent has" would need cross-agent store reads the
resolver does not do today, and the combined sentence is correct for both.

Production +1/-1.
@steipete
steipete force-pushed the steipete/provider-auth-hint branch from 23c1ffd to 7a17b1b Compare August 21, 2026 05:24
@steipete

Copy link
Copy Markdown
Contributor Author

The checks-node-compact-large-3 failure was a flake, not this change. src/entry.run-main.test.ts > keeps expected conditions at exit 1 without crash framing asserts expect(errorSpy.mock.calls).toEqual([[message]]) against a vi.spyOn(console, "error") and received [] — the error never reached console.error at all on that run, in a 146-file shard.

Evidence it is unrelated: the test passes 2/2 locally on the exact failing branch, this PR changes one error-message string in src/agents/model-auth-provider.ts (nowhere near CLI entry or plugin-policy code), and the expected message is about openclaw workboard plugin enablement. Rerunning the failed jobs (attempt 2) came back 84 success / 16 skipped / 0 failures.

The shape — exact-equality on a console.error spy, failing only under shard co-residency — points at cross-test state leakage rather than anything in the changed code. Spun off as its own task to root-cause at the leaking test rather than paper over it here.

Rebased onto 57a2677c3cd for a clean run and gate.

@steipete
steipete merged commit 95b2cd7 into main Aug 21, 2026
225 checks passed
@steipete
steipete deleted the steipete/provider-auth-hint branch August 21, 2026 05:35
@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
… creation (openclaw#127011)

The generic provider-missing-auth error told operators to create a new agent:

    No API key found for provider "openai". Auth store: <path> (agentDir: <path>).
    Configure auth for this agent (openclaw agents add <id>) or copy only portable
    static auth profiles from the main agentDir.

`openclaw agents add <id>` creates an agent. It does nothing about a missing
provider credential, so following it leaves you with a second agent that also
has no key.

Reproduced on a real build: a fresh install with only an Anthropic key, then
`openclaw memory index`. There is exactly one configured agent, `main`, and it is
correctly configured -- nothing about `agents add` applies. Doctor, diagnosing the
identical condition on the same install, gets it right, listing how to supply the
key and how to disable memory search. The command that actually failed gave worse
advice than the advisory check.

`models auth paste-api-key --provider <id>` is the suggestion rather than
`models auth login`, because `login` requires an owning provider plugin while this
generic fallback is also reached for pluginless, inline, and custom providers, and
for a plugin-owned provider that returns no specialized message. Pasting a key
resolves every "No API key found" case the fallback can produce. The `--agent`
hint is folded in for non-default agents, and `formatCliCommand` keeps the command
correct under a profile or container.

One message rather than two: distinguishing "no credential anywhere" from "this
agent lacks a profile another agent has" would need cross-agent store reads the
resolver does not do today, and the combined sentence is correct for both.

Production +1/-1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS 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