Skip to content

fix: config reload with more than 128 agents floods clients with skills.changed events - #195900

Open
arcabotai wants to merge 1 commit into
openclaw:mainfrom
arcabotai:fix/skills-sweep-eviction-bumps
Open

arcabotai wants to merge 1 commit into
openclaw:mainfrom
arcabotai:fix/skills-sweep-eviction-bumps

Conversation

@arcabotai

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: a config hot reload on a Gateway with more than 128 configured agents publishes one extra skills change per agent past the cap, and each one makes the Gateway refresh chat metadata for every agent and broadcast skills.changed to every connected client.

User Impact

User impact: operators running large agent fleets get one skills.changed broadcast per config reload (and per startup sweep) instead of one per evicted agent, so the Gateway main thread is no longer tied up by hundreds of redundant chat-metadata refreshes after each reload. Gateways with 128 agents or fewer see no change.

Why This Change Was Made

An all-agent skills discovery sweep registers every agent workspace in batches into a registry capped at 128 sources. Each registration past the cap evicts the oldest source and published its own workspace change. The sweep already ends with a global change that supersedes every workspace's version, so those per-eviction changes add nothing the closing change does not publish moments later.

While an all-agent sweep runs (config set, no workspaceDir), it now records the workspaces it evicts instead of publishing them. If the sweep completes, the closing global change covers them. If the sweep throws, the recorded workspaces are published as before, so a failed sweep still invalidates exactly what it did previously. Evictions outside an all-agent sweep, including a single-workspace refresh and a concurrent prepareLocalSkillSources registration, still publish immediately. Each sweep keeps its own list, so overlapping sweeps cannot publish or drop each other's evictions. No export, type, schema, or config option changes.

Evidence

Live isolated Gateway (loopback, token auth, stub model provider, 140 configured agents, skills.load.watch: false), with an operator WebSocket client counting skills.changed broadcasts after rewriting one agent's model to trigger a hot reload, three reloads per tree:

Tree Reload 1 Reload 2 Reload 3
main at 6bc38b0158b3 13 (12 watch + 1 config-change) 13 13
this branch 1 (config-change) 1 1

That matches (140 - 128) + 1 = 13 on main and the single closing change on the branch. Startup logged non-fatal usage-cost-cache worker-capacity warnings at 140 agents; the Gateway still completed the client handshake. Counts come from the live WebSocket event stream because gateway logs do not print each broadcast.

Regression test src/skills/runtime/refresh.sweep-eviction.test.ts (7 tests): with the production change reverted, the above-cap sweep test fails with two watch events plus one config-change for a 130-agent sweep, which is the N - 128 extra events. With the change, all 7 pass. Negative controls cover a failed sweep still publishing its evicted workspaces, a single-workspace eviction outside a sweep still publishing, a concurrent registration still publishing immediately, and a sweep retired by a concurrent config refresh. Sibling runs of discovery.integration, refresh.workspace, session-snapshot-content, and discovery.worker tests passed, as did pnpm tsgo:core, oxlint, and oxfmt on the touched files. The new test file is covered by a 276-line allocation under config/test-lines-allocations/ sized to this change's own test growth.

Closes #195833

— Opened by an AI agent from Arca. All code here is stewarded and reviewed by Luis Felipe Abarca (@felirami) of Arca Computer, Inc. (https://arca.computer). All Arca OSS contributions: https://oss.arcabot.ai

An all-agent discovery sweep already ends with one global skills change.
Record evictions from that sweep and publish them only if the sweep fails,
so a completed reload does not emit one watch change per source past the
registry cap.

Co-authored-by: Arca <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 9, 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.

@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. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 9, 2026
@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Coalesce eviction notifications from a successful all-agent skills sweep into its closing global notification while preserving failure and ordinary eviction notifications.

Example: Reload config on a Gateway with 140 distinct agent workspaces.

  • Before: The contributor measured 13 skills.changed broadcasts per reload.
  • After: The contributor measured one config-change broadcast per reload.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, useful repair supported by real Gateway event counts and meaningful boundary regressions, with broad CI still running.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The contributor records the changed discovery owner running through real Gateway config hot reload and authenticated WebSocket broadcasts in an isolated 140-agent setup, with three baseline counts of 13 and three branch counts of 1; the added tests separately cover failure and overlap behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Large-fleet config reloads flood connected clients with redundant skills notifications and trigger repeated Gateway metadata work.
Reason: The linked report establishes an owned release bug, and the change eliminates redundant work while retaining the existing freshness contract.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes a current large-fleet reload bug at the discovery owner, with no actionable correctness finding; exact-head CI is still pending.

Priority: P2
Reviewed head: bfa260bc37374cfb6cda2310a3fe0153839b0b06

Before merge

None.

Findings

None.

Agent review details

How this fits together

Skills discovery registers and scans agent workspaces, then publishes revisions consumed by Gateway chat metadata and connected WebSocket clients.

flowchart TD
  A[Config reload or startup] --> B[Skills discovery sweep]
  B --> C[Bounded source registry]
  C --> D[Sweep eviction records]
  B --> E[Global revision on success]
  D --> F[Workspace revisions on failure]
  E --> G[Gateway metadata and clients]
  F --> G
Loading

Technical review

Best possible solution:

Keep notification coalescing in the existing discovery owner, preserving ordinary eviction invalidation and failed-sweep recovery.

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

Current-main source establishes one eviction notification per distinct source beyond 128 plus the closing global notification, consistent with the linked release report and contributor's Gateway measurements; no target code was run during this review.

Is this the best way to solve the issue?

The patch removes redundant publications at their existing owner without adding consumer delays, another cache, or global suppression state, and preserves the distinct failure and concurrent-registration boundaries.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Eviction invalidation changes intended behavior with a stated reason (877301a: The worker-discovery implementation publishes invalidation because an evicted source no longer retains a fingerprint for comparison on readmission.)
  • Bounded all-agent discovery and completion keeps the original intent (bf12996: Register and scan bounded batches without redundant planning while ensuring config mutations await completed fresh discovery.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +29, Tests +276, Other +2. Total +307 across 3 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 59 30 +29
Tests 1 276 0 +276
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 3 337 30 +307

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #195833
Summary: This PR implements the repair for the linked source-eviction notification report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Repeated notifications add avoidable Gateway-wide work during reloads, with impact concentrated on large agent fleets.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 November 9, 2026, 5:41 AM ET / 10:41 UTC.

This branch has not been deployed

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

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

[Bug]: Config reload skills sweep publishes one skills change per evicted source; each one refreshes chat metadata for every agent

2 participants