Repository navigation
Read an agent's membership only before it says something (CHOO-3667) - #1247
Closed
abeldantas wants to merge 1 commit into
Closed
abeldantas wants to merge 1 commit into
abeldantas wants to merge 1 commit into
Conversation
After a message commits, the router read the membership of every agent it was addressed to, so that one removed from the room in the meantime says nothing there. A connected agent has nothing to say about a message addressed to it, so the read is now made only before a refusal or an offline notice is posted, or a cloud machine woken. In our load test that was one transaction per addressed agent, about three per message.
abeldantas
requested review from
agent-runner353,
amaudruz,
christian-mcdermott,
lbangalosbt,
massimo-sandboxaq,
niall-sandboxaq,
petr-sandbox,
raullopez-sandbox and
simonflk-sb
as code owners
November 1, 2026 01:38
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified, and the changes and corresponding tests address the intended reduction in unnecessary membership reads.
No open issues 🎉
What changed in this PR
This pull request reduces unnecessary post-commit membership reads for messages addressed to connected agents while preserving checks before refusals, offline notices, and cloud-machine wake-ups.
Changes:
- Adds
Delivery.checks_membershipto control deferred membership validation. - Updates post-commit recipient handling to check membership only when follow-up work may produce output or wake a machine.
- Updates routing and protocol tests.
- Documents the behavior in the changelog.
| File | Description |
|---|---|
core/tests/switch_core/delivery/test_router_sessions.py |
Verifies connected addressed agents avoid an extra membership read. |
core/tests/switch_core/delivery/test_no_session_reply_threading.py |
Updates the recipient test double for deferred membership validation. |
core/tests/switch_core/bridges/agent/protocol/test_controller_presence.py |
Updates controller-presence test setup for the new membership helper. |
core/switch_core/delivery/router.py |
Propagates deferred membership-check behavior into post-commit work. |
core/switch_core/delivery/recipient.py |
Defers membership checks until notices, refusals, or machine wake-ups may occur. |
CHANGELOG.md |
Documents the reduced membership-read behavior. |
Review effort: Lite
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.
After a message commits, the router read the membership of every agent the message was addressed to before running what the message left that agent to do, so that an agent taken out of the room in the meantime says nothing there. For a connected agent there is nothing to say, only a report to make.
In this PR we ask whether the agent is still a member only before a refusal or an offline notice is posted, or its cloud machine woken (
Delivery.checks_membership,AgentRecipient._after_message). Other work a row leaves an agent, such as a greeting, still asks first.In a local run of the load harness (200 agents behind 10 controllers, 2 processes, 5 msg/s), that was 3 transactions per message, one per addressed agent, and they are gone.
Stack (merge order)