Repository navigation
Read only the clients and agents a change names, so creating agents stops pinning every process (CHOO-3667) - #1229
Closed
abeldantas wants to merge 3 commits into
Closed
abeldantas wants to merge 3 commits into
abeldantas wants to merge 3 commits into
Conversation
…tops pinning every process (CHOO-3667) Registering, renaming or deleting an agent made every process read every client of the workspace and, with a messaging app connected, every agent too, back to back while changes kept coming. Creating 10,000 agents kept every process at full CPU until its health checks started failing. The client.changed signal now names the clients it changed and each process reads only those rows (ClientLifecycleService.reconcile_clients). A bridge keeps the agents as it last read them and reads only the named ones (CollaborationCore._update_agent_identities). The 30-second re-check compares a fingerprint of the workspace's clients and agents before reading them all (ClientLifecycleService.recheck_all). A signal that names no clients, as an older process sends, still reads the whole workspace.
abeldantas
requested review from
agent-runner353,
amaudruz,
christian-mcdermott,
lbangalosbt,
massimo-sandboxaq,
niall-sandboxaq,
petr-sandbox,
raullopez-sandbox and
simonflk-sb
as code owners
October 31, 2026 17:44
…cks to use The client re-check's fingerprint (a row count and the sum of a 60-bit hash of the columns acted on) moves to switch_core/db/fingerprint.py, so the other families' 30-second re-checks can compare one before reading everything. No change in behavior.
This was referenced Oct 31, 2026
Re-check controller bindings in one narrow query, and only when placements changed (CHOO-3667)
#1237
Closed
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A critical concurrency flaw allows full reconciliation to overwrite newer named changes with stale client and agent identities.
1 open issue
What changed in this PR
This pull request reduces cross-process reconciliation load during client and agent lifecycle changes by propagating affected client IDs, performing targeted reads, and using fingerprints to detect unsignaled changes.
Changes:
- Adds client-ID-aware lifecycle signals with backward-compatible full-tenant reconciliation.
- Adds targeted client and collaboration-agent updates with periodic fingerprint checks.
- Expands regression coverage for signals, fingerprints, identity changes, retries, and rolling deployments.
- Documents the performance improvement.
| File | Summary |
|---|---|
core/tests/switch_core/management/harness.py |
Updates the lifecycle test harness for named client announcements. |
core/tests/switch_core/db/stores/test_client_store.py |
Tests client and agent fingerprints and change detection. |
core/tests/switch_core/clients/test_client_signals.py |
Tests targeted signals, legacy fallback, reconciliation, and periodic rechecks. |
core/tests/switch_core/bridges/collaboration/test_bridge_inbound_tenant_binding.py |
Ensures bridge startup performs the initial full identity read. |
core/tests/switch_core/bridges/collaboration/test_bridge_identity_changes.py |
Tests targeted agent identity reads and updates. |
core/tests/switch_core/bridges/collaboration/test_bridge_identity_backfill.py |
Updates bridge fixtures for tracked identity state. |
core/tests/switch_core/bridges/agent/test_api_key_cache.py |
Updates lifecycle test compatibility for named announcements. |
core/tests/switch_core/bridges/agent/protocol/test_room_roster_authz.py |
Updates lifecycle test compatibility for named announcements. |
core/tests/switch_core/bridges/agent/protocol/test_register_overwrite_owner_guard.py |
Updates lifecycle test compatibility for named announcements. |
core/tests/switch_core/bridges/agent/protocol/test_bridge_identity_tenant_scope.py |
Updates lifecycle test compatibility for named announcements. |
core/tests/switch_core/bridges/agent/protocol/test_agent_tenant_scoped_admin.py |
Updates lifecycle test compatibility for named announcements. |
core/tests/switch_core/bridges/agent/protocol/registration_harness.py |
Updates the registration harness for named announcements. |
core/switch_core/db/stores/client_store.py |
Adds targeted client queries and aggregate fingerprints. |
core/switch_core/db/fingerprint.py |
Provides PostgreSQL row-hash fingerprinting utilities. |
core/switch_core/clients/client_signals.py |
Publishes, aggregates, chunks, and reconciles named client changes. |
core/switch_core/clients/client_lifecycle_service.py |
Implements targeted reconciliation and fingerprint-based checks. Moderate: the member-client filter can cause explicitly unsupported member actors to be treated as deleted. Critical: concurrent full and named reconciliations can apply stale snapshots over newer changes. |
core/switch_core/bridges/collaboration/lifecycle_service.py |
Forwards named agent changes to tenant bridges. |
core/switch_core/bridges/collaboration/collaboration_core.py |
Maintains an agent view and incrementally updates platform identities. |
core/switch_core/bridges/agent/protocol/agent_core.py |
Names affected clients during registration, rename, and deletion announcements. |
CHANGELOG.md |
Documents the reduced reconciliation workload. |
This pull request requires changes.
Review effort: Lite
Comment on lines
+413
to
+417
| async def reconcile_clients( | ||
| self, tenant_id: str, client_ids: Collection[str] | ||
| ) -> None: | ||
| """`reconcile_tenant` for the named clients only: their rows are read, | ||
| and each is started, stopped or renamed here to match, where the full |
Collaborator
Author
|
Combined into #1307 with the other scaling PRs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

When an agent is registered, renamed or deleted, every process read every client of the workspace again and, with a messaging app connected, every agent too, back to back for as long as changes kept coming. Every process also read every client every 30 seconds. Creating 10,000 agents kept every process at full CPU for 17 minutes, and their health checks started failing.
In this PR we:
client.changedsignal, so each process reads only those rows (ClientLifecycleService.reconcile_clients)CollaborationCore._update_agent_identities); the platform calls stay the ones a full read makesClientLifecycleService.recheck_all), so a change no signal names, such as an agent's description edited in another process, is still read within 30 secondsA process from before this sends
client.changedwithout ids, and that still reads the whole workspace.Load test with 10,000 agents behind 498 controllers on 12 pods, main plus #1220 to #1225: