Repository navigation
fix(agents): point a missing API key at an auth command, not at agent creation - #127011
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 1:14 AM ET / 05:14 UTC. ClawSweeper reviewWhat this changesThe PR changes generic missing-provider-key guidance to recommend Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep 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 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 3 Assertions:
How this fits togetherProvider-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]
Before merge
Agent review detailsSecurityNone. PR surfaceSource 0, Tests +4. Total +4 across 2 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest 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. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
CI here failed on Fixing it separately in #127018 so it unblocks every other open PR too, not just this one. Will rebase here once that lands. |
a1efc0d to
23c1ffd
Compare
… 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.
23c1ffd to
7a17b1b
Compare
|
The Evidence it is unrelated: the test passes 2/2 locally on the exact failing branch, this PR changes one error-message string in The shape — exact-equality on a Rebased onto |
|
Merged via squash.
|
… 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.
What Problem This Solves
The generic provider-missing-auth error recommends a command that cannot fix the problem it describes:
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 aboutagents addapplies.Doctor, diagnosing the identical condition on the same install, gets it right:
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:
models auth paste-api-key --provider <id>is the suggestion rather thanmodels auth login.loginruns 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, whenallowAuthProfileFallbackis 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;logindoes not. The--agent <id>hint is folded in for non-default agents, and the whole thing routes throughformatCliCommandso it stays correct under--profileor--container.One message rather than two. Distinguishing situation 1 from situation 2 would require reading other agents' auth stores: the
storein scope is the failing agent's, andcfgdoes 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
Production LOC: +1/-1, net 0.
Evidence
Reproduced end to end on a real
pnpm builddist in an isolatedOPENCLAW_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-keytakes 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.tsfailed 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 containsopenclaw 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 andgit 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_KEYmasked the condition, so it explicitly setmemory.search.provider=openaiand unset that variable to recreate it. My original reproduction needed neither —openaiis already the memory-search default on a fresh Anthropic-only install.No second provider-auth message recommending
agents addexists; the remainingopenclaw agents addreferences in the tree are all about actually creating agents.