Skip to content

fix(auth): limit inline key cooldowns to credential failures - #119147

Merged
Patrick-Erichsen merged 1 commit into
openclaw:mainfrom
VACInc:fix/inline-key-auth-cooldown-scope
Aug 5, 2026
Merged

Patrick-Erichsen merged 1 commit into
openclaw:mainfrom
VACInc:fix/inline-key-auth-cooldown-scope

Conversation

@VACInc

@VACInc VACInc commented Aug 4, 2026

Copy link
Copy Markdown
Member

Summary

High Level TLDR

A transient provider timeout could disable a configured inline API key for every later session, even though inline-key cooldowns are intended only for credential auth and billing failures. Restrict the inline-key cooldown producer to those credential failures so unrelated sessions remain usable after transient provider faults.

This is deliberately scoped to inline keys. Stored auth profiles keep their existing timeout and failover accounting.

Root Cause

Commit 196d81195bf added provider-scoped cooldown persistence for inline API keys. Its controller and resolver describe that state as an auth/billing cooldown, but markInlineProviderApiKeyFailure accepted the full AuthProfileFailureReason union.

In the failing artifact, a provider-started status-only HTTP 503 followed the stock path below:

  1. The provider error classifier mapped the 503 to timeout.
  2. The failover controller passed that reason to the inline-key marker.
  3. The marker persisted inline-api-key:qa-mock with a cooldown.
  4. The resolver rejected later independent sessions before provider ingress with Inline API key ... temporarily disabled after a provider auth/billing failure.

The captured no-auto-retry and mutation/compaction scenarios therefore had no provider wire records and never planned or executed their mutation tools. A pre-regression baseline produced each expected mutation file exactly once and completed manual compaction.

Stock counterfactual: stock OpenClaw on the affected code reaches the same failure with an ordinary configured inline provider API key when a provider-started 503 precedes another session. The Nightly wrapper makes that request ordering deterministic but is not in the classifier, cooldown producer, or resolver path. openclaw update, update finalization, and doctor are not involved and do not own this per-run provider state.

Verification

  • node scripts/run-vitest.mjs src/agents/auth-profiles/usage.test.ts -t 'does not cool an inline key after a provider timeout'
    • Test Files 2 passed (2)
    • Tests 2 passed | 196 skipped (198)
  • node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run.incomplete-turn.test.ts -t 'continues from settled side-effecting tools after an empty stop without replaying them'
    • matched lifecycle variants passed
  • node scripts/run-vitest.mjs src/gateway/server.sessions.compaction.test.ts -t 'sessions.compact without maxLines runs embedded manual compaction for checkpoint-capable flows'
    • Test Files 1 passed (1)
    • Tests 1 passed | 23 skipped (24)
  • oxfmt --check src/agents/auth-profiles/usage.ts src/agents/auth-profiles/usage.test.ts
    • All matched files use the correct format.
  • git diff --check origin/main...HEAD
    • clean
  • .agents/skills/autoreview/scripts/autoreview --mode local
    • autoreview clean: no accepted/actionable findings reported
    • overall: patch is correct (0.99)

The focused tests used the existing trusted normal-checkout dependencies after remote proof backends failed preflight before source execution: Testbox was not authenticated, Proxmox had no template ID, and AWS had no configured broker.

Real behavior proof

Behavior fixed: a transient provider timeout no longer writes or locks inline-key auth state; auth, permanent-auth, and billing failures continue to use the accepted provider-scoped cooldown.

Closest feasible environment: the captured packaged Gateway run supplied the before behavior, and the focused regression invoked the production cooldown owner with the same timeout reason after the patch.

Exact after-patch result:

Test Files  2 passed (2)
     Tests  2 passed | 196 skipped (198)

The regression also asserts that usageStats remains absent and the locked auth-store updater is never called, proving the transient reason is stopped at the authoritative producer boundary.

Production delta is +4/-1; tests are +16/-0. No retry, replay, compaction, provider classifier, config, schema, or resolver behavior was changed.

What was not tested

  • The frozen Nightly suite was not rerun end-to-end.
  • No live paid provider was forced to return a post-tool 503.
  • Full repository tests and builds were not run; the change does not touch build, packaging, or published surfaces.

@VACInc
VACInc requested a review from a team as a code owner August 4, 2026 07:45
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 4, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 4, 2026
@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 7:38 AM ET / 11:38 UTC.

ClawSweeper review

What this changes

This PR prevents transient provider failures from persisting a provider-wide cooldown for configured inline API keys, while retaining cooldowns for authentication and billing failures.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking findings: the PR fixes the provider-wide inline-key state leak at its producer while retaining credential-failure cooldowns and stored-profile timeout handling. The new disposable-VM Gateway A/B evidence satisfies the prior real-behavior-proof request; refresh the exact head because the branch is behind main.

Priority: P1
Reviewed head: eb6bf36db9ca61c47d57387182294ab3c9f42c3a

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A narrow owner-boundary fix with focused regression coverage and strong after-fix Gateway A/B evidence.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The contributor supplied an exact-head disposable-VM Gateway/provider A/B report showing five formerly blocked scenarios reach the provider and pass after the state-write guard; redact private deployment details if further artifacts are posted.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The contributor supplied an exact-head disposable-VM Gateway/provider A/B report showing five formerly blocked scenarios reach the provider and pass after the state-write guard; redact private deployment details if further artifacts are posted.
Evidence reviewed 6 items Current-main defect: The inline-key writer accepts the full failure-reason union and persists provider-wide state; the resolver later treats that state as an auth/billing cooldown for every inline-key resolution.
Producer-bound repair: The PR returns before the locked state update unless the reason is auth, permanent auth, or billing, preserving the existing bypass and write behavior for credential failures.
Caller and sibling contract: The only production caller can supply provider-started timeouts for profile-less inline keys; stored-profile policy and the established inline billing end-to-end route remain unchanged.
Findings None None.
Security None None.

How this fits together

The embedded agent runner classifies provider failures and records auth health before later sessions select a credential. Inline API keys have no profile, so their provider-scoped state is read by model resolution and availability checks that can otherwise block every later session.

flowchart LR
A[Provider failure] --> B[Failure classification]
B --> C[Failover controller]
C --> D[Inline key state writer]
D --> E[Auth-state store]
E --> F[Later session resolution]
F --> G[Provider request]
Loading

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch as mergeable but behind current main, so the final merge decision should use a refreshed exact-head review or merge result.
  • Complete next step (P2) - No repair lane is needed because the patch has no actionable finding; refresh review against the exact merge head before landing.
Agent review details

Security

None.

PR surface

Source +3, Tests +16. Total +19 across 2 files.

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

Review metrics

Metric Value Why it matters
Production versus test delta production +4/-1, tests +16/-0 The small production increase implements the authoritative state-owner boundary, with focused regression coverage for the non-write path.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the narrow producer-side reason gate after refreshing the exact merge head; retain the existing resolver and stored-profile cooldown policy.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the narrow producer-side reason gate after refreshing the exact merge head; retain the existing resolver and stored-profile cooldown policy.

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

Yes: current source shows a provider-started timeout reaching a provider-wide inline-key writer, and the supplied disposable-VM Gateway A/B run reports the before-fix block and after-fix recovery on the PR head.

Is this the best way to solve the issue?

Yes: gating the producer prevents invalid shared state before it reaches every resolver, unlike a resolver-side exception, while preserving established billing/auth cooldowns and stored-profile timeout accounting.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The contributor supplied an exact-head disposable-VM Gateway/provider A/B report showing five formerly blocked scenarios reach the provider and pass after the state-write guard; redact private deployment details if further artifacts are posted.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: A transient provider failure can otherwise block later real-user agent sessions from using a configured inline provider key.
  • 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. Sufficient (logs): The contributor supplied an exact-head disposable-VM Gateway/provider A/B report showing five formerly blocked scenarios reach the provider and pass after the state-write guard; redact private deployment details if further artifacts are posted.
  • proof: sufficient: Contributor real behavior proof is sufficient. The contributor supplied an exact-head disposable-VM Gateway/provider A/B report showing five formerly blocked scenarios reach the provider and pass after the state-write guard; redact private deployment details if further artifacts are posted.

Evidence

What I checked:

  • Current-main defect: The inline-key writer accepts the full failure-reason union and persists provider-wide state; the resolver later treats that state as an auth/billing cooldown for every inline-key resolution. (src/agents/auth-profiles/usage.ts:1152, 80da61668eb6)
  • Producer-bound repair: The PR returns before the locked state update unless the reason is auth, permanent auth, or billing, preserving the existing bypass and write behavior for credential failures. (src/agents/auth-profiles/usage.ts:1153, eb6bf36db9ca)
  • Caller and sibling contract: The only production caller can supply provider-started timeouts for profile-less inline keys; stored-profile policy and the established inline billing end-to-end route remain unchanged. (src/agents/embedded-agent-runner/run/failover-retry-controller.ts:151, 80da61668eb6)
  • Regression coverage: The added test verifies that a timeout leaves inline usage state absent and does not acquire the locked auth-store updater; existing coverage retains durable inline billing behavior. (src/agents/auth-profiles/usage.test.ts:1170, eb6bf36db9ca)
  • History and routing: Current writer and caller lines were carried by the recent auth/session refactor; the original inline billing feature commit is locally identifiable as 196d811. (src/agents/auth-profiles/usage.ts:1152, 39bbd8afd338)
  • After-fix runtime proof: The contributor's 2026-08-04 comment reports a disposable-VM Gateway/mock-provider A/B run at the PR head: the baseline had five blocked scenarios after a 503/timeout, while the fixed build passed all five and reached provider ingress without persisting inline cooldown state. (eb6bf36db9ca)

Likely related people:

  • Peter Steinberger: Current writer and failover-caller lines blame to the recent auth/session refactor that carried this behavior forward. (role: recent area contributor; confidence: high; commits: 39bbd8afd338; files: src/agents/auth-profiles/usage.ts, src/agents/embedded-agent-runner/run/failover-retry-controller.ts)
  • Mert Başar: Commit metadata identifies this contributor as the author of the inline API-key billing cooldown feature that the PR narrows. (role: feature introducer; confidence: medium; commits: 196d81195bf4; files: src/agents/auth-profiles/usage.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-04T08:23:16.925Z sha eb6bf36 :: needs real behavior proof before merge. :: none

@VACInc

VACInc commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

Independent disposable-VM A/B reproduction completed on 2026-08-04.

Baseline artifact:

  • Source SHA: 8393b37779d9c732e4e0c881aec66da3339545a4
  • Tarball SHA-256: 1345328bd052d6143da2f75dda7bb378b843d4bef9ad067a9cf1ee59faa2d36e
  • Result: exactly 5 requested HARD_FAIL, 0 infra failures
Baseline id Verdict Observed failure
visible-outcome-under-provider-faults HARD_FAIL no wire records for the next fault scenario
no-auto-retry-after-mutating-tool HARD_FAIL expected mutation file absent
mutation-exactly-once-under-retry-and-compaction HARD_FAIL expected mutation file absent
private-context-conversation-isolation HARD_FAIL no wire records for the positive-control scenario
sentinel-leak-guard-all-egress HARD_FAIL no wire records for the leak-read scenario

The baseline wire recorded a successful forced tool call followed by the injected HTTP 503 sequence. Diagnostics then recorded reason=timeout window=cooldown, after which the shared inline key was rejected as temporarily disabled. The five later target scenarios did not reach provider ingress.

Fixed artifact:

  • Source SHA: 50a30b7373d78fe8a63e597bd28138b6aa805765
  • QA overlay SHA: 06c9e42e2927e0f754d51a617f90d5d39935d6de
  • Tarball SHA-256: c3cf04b7281fd7cf235988878aaec8131d17ea3bc091738b64dabc78155c37c5
  • PR head: eb6bf36db9ca61c47d57387182294ab3c9f42c3a
  • Result: 5/5 requested PASS, 0 hard failures, 0 infra failures
Fixed id Verdict
visible-outcome-under-provider-faults PASS
no-auto-retry-after-mutating-tool PASS
mutation-exactly-once-under-retry-and-compaction PASS
private-context-conversation-isolation PASS
sentinel-leak-guard-all-egress PASS

The fixed build still reached the mock provider and observed the injected HTTP 503, but it did not persist an inline-key cooldown. Wire records were present for every formerly blocked scenario.

Method: two sequential disposable Proxmox VMs, one fresh VM per artifact, fresh install from each exact build tarball, and the B3 fault-injecting OpenAI-compatible mock-provider lane. OCQA_ONLY expanded the five requested ids to their shared boot-group prerequisites, so these are subset results rather than a full gauntlet or live-provider run. Both run-owned leases were released and verified absent.

@clawsweeper clawsweeper Bot added 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 rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 5, 2026
@Patrick-Erichsen Patrick-Erichsen self-assigned this Aug 5, 2026
@Patrick-Erichsen
Patrick-Erichsen merged commit 2a83576 into openclaw:main Aug 5, 2026
206 of 222 checks passed
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling 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: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants