Skip to content

fix(agents): stop runtime rebuild storms during auth cooldowns - #185250

Merged
steipete merged 3 commits into
mainfrom
steipete/fix-auth-availability-refresh-storm-20261026
Oct 27, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/fix-auth-availability-refresh-storm-20261026

Conversation

@steipete

@steipete steipete commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes repeated prepared-runtime rebuilds and model-catalog refresh broadcasts when provider rate limits repeatedly set and clear auth cooldowns.

User Impact

Concurrent chat turns and metadata reads keep their prepared plugins through availability changes. Model selection still sees committed cooldown, blocked, and disabled windows immediately. Credential, profile membership, explicit order, ownership, and compensation changes retain full invalidation.

Why This Change Was Made

The auth snapshot owner now distinguishes availability from catalog identity. Prepared runtimes read current usage through the existing owner-bound usage reader; chat metadata keeps availability-sensitive caches fresh while coalescing notifications without modelCatalogChanged. Shared durable state updates preserve inherited snapshots when credential bytes and explicit order are unchanged.

No config options, database changes, or migrations. Production source delta: +106 lines (+174/−68); benchmark tooling is separate. Production growth is needed to preserve immediate availability reads and security invalidation while separating their publication lifecycles.

Evidence

  • Regression: 100 alternating cooldown publications with concurrent runtime publication requests preserve the exact snapshot/plugin generation and perform zero additional plugin preparations. Credential rotation and profile insertion still retire the preceding snapshot and expose the changed profiles.
  • Gateway regressions: 100 availability flips coalesce to one scheduled refresh; current cooldown reads produce zero catalog-change broadcasts. Credential/profile changes still broadcast.
  • Focused proof: 62 gateway tests, 14 auth recovery tests, 19 auth snapshot tests, and 21 durable store-update tests passed. Targeted lint/format and core typecheck passed. The 257-owner regression ensures availability churn cannot evict catalog revision facts and spuriously announce catalog changes.
  • Durable shared blocked-window regression fails on the original publisher because it deletes the child snapshot; the fix preserves the child while exposing the committed block. Full store-update file: 21 tests passed.
  • Independent subagent review (autoreview route unavailable). The helper rejected the requested provider because it did not match the operator configuration. Both accepted findings were fixed and the scoped review is clean. Automated PR review subsequently identified a UI cached-availability consumer gap; the bounded consumer change is pending coordination with its owning lane before this PR is ready to land.

Owner-decision microbenchmark: five alternating runs per side, 4,000 availability events per run, four configured owners, 40 plugin descriptors. This excludes plugin loading, publication, and Gateway RPC work.

Metric Base Candidate
Mean main-thread CPU / 4,000 events 191.012 ms 0.503 ms
Mean sampled allocation / 4,000 events 149,005,002 B 1,684,134 B
Generation retirements / run 16,000 0

Timing GC: four collections per baseline pass (3.04–5.86 ms total), zero in candidate; sample counts are too small for tail claims. Timing host load was 30.7–42.0. The committed script documents reproduction and measurement scope.

Built-Gateway smoke proof: the isolated mock provider alternates HTTP 429 (Retry-After: 1) and success. In 60 measured seconds, 44 availability-only mutations caused zero plugin preparations and zero supersessions. All instrumentation hooks were verified. This is smoke evidence only; full 10-minute timing/allocation arms and heap captures are in progress.

CI follow-up: required listener/usage-reader test fixtures and explicitly typed credential/usage cases were corrected. The embedding lifecycle file passed 11 tests and the two catalog fixture files passed 20 tests. The inherited models.list expectation mismatch was resolved by rebasing onto #185244; that file now passes all 51 tests. Exact-head CI is running on 9a6ce5b3b1022474a1ba79e511659450a13cae92.

Remaining gates: UI cached-availability consumer coordination, full built-Gateway comparison, and exact-head CI. This PR is intentionally unmerged.

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling size: L labels Oct 27, 2026
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: a7e74a96ad975e409846a55ad37b87109ec9bb91
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/auth-profiles/runtime-snapshot-owner.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/runtime-snapshot-selection.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/runtime-snapshots.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/store-mutation.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/store-update-publication.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/store-update.worker.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/store.worker-contract.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/prepared-model-runtime-auth-publication.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/prepared-model-runtime-auth.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eed303f801

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +110 to +112
// Cooldown views still refresh, but they do not announce a changed model inventory.
const modelCatalogChanged =
!previous || !facts || !generationFactsMatch(previous, facts, "catalog");
!previous || !facts || !generationFactsMatch(previous, facts, "catalog-notification");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update catalog consumers before suppressing availability invalidations

When a connected Control UI has already cached a model catalog, an availability change now emits modelCatalogChanged: false and commandsChanged: false, but the existing UI consumers do not refresh model availability on authChanged alone. modelCatalogEventInvalidation in ui/src/lib/model-catalog-cache.ts ignores this payload, and ui/src/app/app-shell-gateway.ts consequently skips chat-metadata invalidation. A previously healthy catalog has an infinite expiry, so newly blocked or disabled models remain selectable until an unrelated refresh; conversely, an early cooldown clear leaves models disabled until the old deadline. Migrate these consumers to invalidate availability-sensitive projections without triggering inventory discovery before suppressing the existing signal.

AGENTS.md reference: AGENTS.md:L52-L52

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-27T01:49:36.649816Z a7e74a9 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 27, 2026
@steipete
steipete force-pushed the steipete/fix-auth-availability-refresh-storm-20261026 branch from eed303f to 9a6ce5b Compare October 27, 2026 00:42
@openclaw-barnacle openclaw-barnacle Bot added the extensions: memory-lancedb Extension: memory-lancedb label Oct 27, 2026
@clawsweeper clawsweeper Bot removed the clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. label Oct 27, 2026
@clawsweeper

clawsweeper Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR separates auth availability updates from catalog identity changes so cooldowns preserve prepared plugin generations.

Example: The test:primary profile enters and clears a 60-second cooldown repeatedly during concurrent runtime requests.

  • Before: Availability changes retire prepared runtimes and trigger repeated preparation.
  • After: The prepared generation survives while backend readers obtain current cooldown state.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The owner-level repair has focused regression coverage and reported Gateway smoke evidence, but the client-consumer regression blocks merge.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its body reports built-Gateway 429/success smoke results, but supplies no linked runtime trace and explicitly leaves the full performance comparison pending.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Provider cooldown churn repeatedly rebuilds model runtimes and can stall concurrent chat and catalog requests.
Reason: The reported upstream failure and current source establish user value, and the maintainer-authored direction preserves the existing owner; added flags are benchmark-only.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep open: this maintainer-authored fix addresses a current runtime starvation path, but its notification change leaves Control UI model availability stale.

Priority: P1
Reviewed head: 9a6ce5b3b1022474a1ba79e511659450a13cae92

Before merge

  • Refresh client availability before suppressing catalog invalidation (P2) - After a connected Control UI caches a healthy model catalog, a cooldown or disabled-window publication now sends modelCatalogChanged=false, authChanged=true, and commandsChanged=false. ui/src/lib/model-catalog-cache.ts:48 ignores that payload, and ui/src/app/app-shell-gateway.ts:266 skips metadata invalidation. Healthy cached catalogs can have infinite expiry, so newly unavailable models remain selectable until another refresh; clearing a cooldown early likewise leaves stale disabled choices. Migrate the existing consumers to refresh availability-sensitive projections without triggering inventory discovery. This confirms the existing review finding, which remains unresolved at this head.
  • Complete next step - Resolve GitHub's reported merge conflict before landing this PR.

Findings

  • [P2] Refresh client availability before suppressing catalog invalidation — src/gateway/server-methods/chat-metadata-runtime.ts:110-112

Tests

  • Missing end-to-end proof: The pending built-Gateway comparison should cover connected Control UI availability updates, including newly blocked models and early cooldown clearing, alongside retained plugin generations.
Agent review details

How this fits together

Auth workers publish committed profile state into the runtime snapshot owner, which supplies prepared runtimes and Gateway metadata consumed by client model catalogs.

flowchart LR
  A[Auth worker commits] --> B[Runtime auth snapshot owner]
  B --> C[Availability classification]
  C --> D[Prepared runtime generations]
  B --> E[Gateway metadata projections]
  E --> F[Control UI catalog cache]
Loading

Technical review

Best possible solution:

Preserve prepared generations for availability-only changes and refresh every availability-sensitive consumer through the existing auth owner.

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

Current-main source connects availability mutations to prepared-owner retirement, matching the measured reproduction in #161468; this review executed no target code.

Is this the best way to solve the issue?

Separating availability from catalog identity at the existing snapshot owner is a focused repair, provided all consumers retain fresh availability without restarting discovery.

Full review comments:

  • [P2] Refresh client availability before suppressing catalog invalidation — src/gateway/server-methods/chat-metadata-runtime.ts:110-112
    After a connected Control UI caches a healthy model catalog, a cooldown or disabled-window publication now sends modelCatalogChanged=false, authChanged=true, and commandsChanged=false. ui/src/lib/model-catalog-cache.ts:48 ignores that payload, and ui/src/app/app-shell-gateway.ts:266 skips metadata invalidation. Healthy cached catalogs can have infinite expiry, so newly unavailable models remain selectable until another refresh; clearing a cooldown early likewise leaves stale disabled choices. Migrate the existing consumers to refresh availability-sensitive projections without triggering inventory discovery. This confirms the existing review finding, which remains unresolved at this head.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against c7cfa1f9971d.

Provenance checked

  • Availability-triggered prepared-runtime invalidation changes intended behavior with a stated reason (1e6ca9f: Availability was included in metadata identity so model lists exposed cooldown, blocked-state, and retry-time changes.)
  • Shared-state publication and inherited snapshots changes intended behavior with a stated reason (381b1e0: State changes required canonical worker reconciliation rather than advancing derived snapshots with unreconciled state; this PR preserves snapshots only for unchanged credentials and order.)
  • Live usage overlays keeps the original intent (a13a010: Retained catalog readers must observe recovered account availability without retaining obsolete usage windows.)
  • Credential and profile-change refresh keeps the original intent (d8f55fa: New provider credentials must refresh catalog content while ordinary token rotation avoids unnecessary discovery.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +106, Tests +204, Docs +6, Other +250. Total +566 across 31 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 15 174 68 +106
Tests 10 228 24 +204
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 5 251 1 +250
Total 31 659 93 +566

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +174/−68; tests/support +228/−24 Excludes documentation and benchmark tooling; growth supplies separate availability publication, existing-owner usage bindings, and regressions for generation retention, inheritance, and notification lifecycle.

Labels

Label changes:

  • add P1: Repeated provider cooldown transitions can disrupt concurrent agent work and prolong catalog-reader waits.
  • add merge-risk: 🚨 compatibility: Changing the notification semantics without migrating existing clients leaves their cached availability projections stale.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P1: Repeated provider cooldown transitions can disrupt concurrent agent work and prolong catalog-reader waits.
  • merge-risk: 🚨 compatibility: Changing the notification semantics without migrating existing clients leaves their cached availability projections stale.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 26, 2026, 9:03 PM ET / October 27, 2026, 01:03 UTC.

@openclaw-barnacle openclaw-barnacle Bot reopened this Oct 27, 2026
Keep cooldown, blocked, and disabled updates on the current plugin generation and coalesce metadata notifications without catalog-change broadcasts. Preserve immediate availability reads and full credential, profile, order, ownership, and compensation invalidation.
@steipete
steipete force-pushed the steipete/fix-auth-availability-refresh-storm-20261026 branch from c542509 to a7e74a9 Compare October 27, 2026 01:49
@steipete
steipete merged commit 77af976 into main Oct 27, 2026
129 checks passed
@steipete
steipete deleted the steipete/fix-auth-availability-refresh-storm-20261026 branch October 27, 2026 02:13
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
…law#185250)

* fix(agents): keep prepared runtimes through auth availability changes

Keep cooldown, blocked, and disabled updates on the current plugin generation and coalesce metadata notifications without catalog-change broadcasts. Preserve immediate availability reads and full credential, profile, order, ownership, and compensation invalidation.

* test(agents): align availability fixtures with owner contracts

* test(gateway): use explicit API-key rotation fixture
RomneyDa added a commit that referenced this pull request Oct 28, 2026
* fix(agents): keep prepared runtimes through auth availability changes

Keep cooldown, blocked, and disabled updates on the current plugin generation and coalesce metadata notifications without catalog-change broadcasts. Preserve immediate availability reads and full credential, profile, order, ownership, and compensation invalidation.

* test(agents): align availability fixtures with owner contracts

* test(gateway): use explicit API-key rotation fixture

(cherry picked from commit 77af976)

Co-authored-by: RomneyDa <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 29, 2026
…olved peer identity; realign quota catalog e2e (#187594)

* test(ui): expect held catalog refresh to complete across quota recovery

Backport e8dd49e (#185250, main 77af976) keeps the prepared runtime
and its catalog owner through cooldown/blocked availability updates, so a quota
recovery no longer supersedes an in-flight catalog generation. The
automatic-during-catalog quota e2e still expected the held models.list refresh
to fail with "catalog generation was superseded". Main realigned this assertion
to the intended behavior in fc0e45a (#184971); that commit is a large CI
change, so carry only the assertion: the held refresh resolves ok and the
published catalog still reports gpt-5.5 available after it lands.

Refs fc0e45a

* fix(control-ui): keep the admitted sidebar scope while hello identity is unresolved

Backport 99e458b (#185762, main 8d0f6fb) stopped an unresolved peer
tab from persisting a profile-less boot record, but on main that fix sits on
top of #179254 (5b1b96b), which also keeps the admitted boot profile in
the sidebar snapshot scope until hello's selfUser resolves. Release lacks
#179254 (Solid-era handoff/perf work), so a peer tab that booted with the
operator's sidebar scope still recomputed profileId as null on hello, retired
that scope, and deleted the operator's cached sidebar snapshot. The next
reload then rendered the sidebar live instead of from cache.

Port only #179254's identity rule into the Lit SidebarSnapshotController:
keep the admitted profile while selfUser is undefined (a resolved different
user or an explicit null still replaces the scope) and skip capture under a
profile scope until identity resolves. Add main's unit regression adapted to
the release controller (fails without the runtime change).

The #185762 e2e waited for an 11th recent row, which main serves through its
#172946 sessions.list owner fixture; the backport dropped those handlers, so
the count could never be reached on release (it failed at 99e458b
itself). Assert instead that the cached reload shows the rows the operator's
page saved, which exceeds the single live row a held connect renders.

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

Labels

agents Agent runtime and tooling clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. docs Improvements or additions to documentation extensions: memory-lancedb Extension: memory-lancedb gateway Gateway runtime scripts Repository scripts security-sensitive-changed size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant