Repository navigation
fix(auth): cooldown inline api key billing failures - #80482
MertBasar0 wants to merge 5 commits into
Conversation
|
Thanks for the contribution. I reviewed the branch, and this PR is not a good landing base for OpenClaw. Close: the current head no longer contains the advertised inline API-key billing cooldown fix and is now an unrelated workspace-capability docs/policy branch, while current main still lacks the no-profile inline cooldown path. So I’m closing this PR rather than keeping an unmergeable branch open. A new narrow PR that carries only the useful part is welcome. Review detailsBest possible solution: Close this branch, keep #39807 open for a fresh focused auth cooldown PR, and submit workspace-capability docs separately if maintainers want that convention. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main still ignores failures with no profile id and direct inline/env API-key resolution has no inline cooldown gate; the current PR diff does not touch those paths. Is this the best way to solve the issue? No. The current branch no longer solves the linked auth bug; the maintainable path is a focused auth-runtime/test PR, with the workspace-capability docs convention evaluated separately. Security review: Security review needs attention: The current diff introduces credential-discovery guidance in root AGENTS.md that needs explicit secret-safe review before any replacement docs PR lands.
AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against b9fe0894a6da. |
|
Follow-up on the earlier noisy diff: the upstream-divergent drift has been realigned back to Current PR state:
|
|
@clawsweeper re-review Requesting a fresh review after the noisy-diff cleanup. Current state:
The older review text still references unrelated churn from the polluted diff period, so this should be re-evaluated against the current head. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Real Behavior Proof — Latest Head (
|
| Scenario | Covered | Evidence |
|---|---|---|
Literal inline apiKey blocked during cooldown |
✅ | Test throws expected error |
| Env-marker / env SecretRef inline keys get failure recorded | ✅ | markInlineProviderApiKeyFailure writes cooldown without creating profile |
| No-profile runner failures now marked (was silently dropped on main) | ✅ | Failover test confirms maybeMarkAuthProfileFailure called with profileId: undefined |
| Cooled inline key falls back to healthy stored profile | ✅ | Stored profile resolution tests pass |
| Default agent directory honored | ✅ | Covered by stored-profile fallback path (uses agentDir in store operations) |
@clawsweeper re-review
|
🦞👀 Command router queued. I will update this comment with the next step. Re-review progress:
|
|
I think this P1 is a false positive. The timeout behavior is unchanged from if (!profileId || !reason || reason === "timeout") {
return;
}In this PR, the timeout guard is still present: if (!reason || reason === "timeout") {
return;
}The behavioral change is only that the old @clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
ClawSweeper applied the proposed close for this PR.
|
|
Rebased and rebuilt this branch from current upstream/main. Current state:
Validation after rebase:
|
|
GitHub would not reopen this closed PR after the branch was corrected, so I opened the clean replacement PR from the updated branch: #88709 |
Summary
models.providers.<id>.apiKeycredentials without creating synthetic auth profilesCloses #39807.
Real behavior proof
models.providers.<id>.apiKeycredentials now record provider auth/billing failures in usage state, stop immediate reuse during cooldown, and become available again after the cooldown expires without creating a synthetic auth profile.fix/inline-api-key-billing-cooldownat61ac6e93eac913fee891d3d63262518e08185c9d, using Node/tsx against the production auth profile store, usage helpers, and model auth resolution helpers.markInlineProviderApiKeyFailure(...)with reasonbilling, checked availability/resolution during cooldown, then simulated cooldown expiry and resolved the inline key again.models.json. AftermarkInlineProviderApiKeyFailure(...),usageStats["inline-api-key:demo-local"]recordsdisabledReason: "billing",disabledUntilis in the future, no synthetic profile is created,hasAvailableAuthForProvider(...)returns false, andresolveApiKeyForProvider(...)blocks immediate reuse with the temporary-disabled error. After simulated cooldown expiry, the same inline key becomes available and resolves frommodels.jsonagain.Validation
pnpm test src/agents/auth-profiles.markauthprofilefailure.test.ts src/agents/model-auth.profiles.test.ts(2 files, 66 tests passed)pnpm exec oxfmt --check --threads=1 src/agents/auth-profiles/usage.ts src/agents/auth-profiles.ts src/agents/model-auth.ts src/agents/pi-embedded-runner/run.ts src/agents/auth-profiles.markauthprofilefailure.test.ts src/agents/model-auth.profiles.test.tsgit diff --checkAdditional real behavior proof
Follow-up proof after env-backed cooldown repair
Follow-up after assistant no-profile marker repair
models.providers.<id>.apiKeybilling/auth failures to record provider-level cooldown instead of immediately reusing the exhausted inline key.handleAssistantFailovernow covers a no-profile billing rotate path and verifiesmaybeMarkAuthProfileFailure({ profileId: undefined, reason: "billing", modelId })is invoked so the runner-level inline marker can run.OPENCLAW_VITEST_INCLUDE_FILE=/tmp/openclaw-vitest-include-assistant.json node scripts/test-projects.mjs test/vitest/vitest.agents.config.ts— 1 file / 15 tests passedOPENCLAW_VITEST_INCLUDE_FILE=/tmp/openclaw-vitest-include-80482.json node scripts/test-projects.mjs test/vitest/vitest.agents.config.ts— 3 files / 89 tests passedpnpm exec vitest run --config test/vitest/vitest.e2e.config.ts src/agents/pi-embedded-runner.run-embedded-pi-agent.auth-profile-rotation.e2e.test.ts --reporter=dot— 1 file / 28 tests passedpnpm check:test-typesgit diff --checkFollow-up after auth fallback/default-agent repair
agentDir.OPENCLAW_VITEST_INCLUDE_FILE=/tmp/openclaw-vitest-include-80482-p2.json node scripts/test-projects.mjs test/vitest/vitest.agents.config.ts— 2 files / 76 tests passedpnpm check:test-typesgit diff --check