Skip to content

Post the tagged-agent heads-up from the writing process, and skip it when only room agents are tagged (CHOO-3667) - #1222

Closed
abeldantas wants to merge 2 commits into
mainfrom
admin-mention-checks
Closed

abeldantas wants to merge 2 commits into
mainfrom
admin-mention-checks

Conversation

@abeldantas

Copy link
Copy Markdown
Collaborator

The admin's consumer reads every message in a workspace on one process, and checked each message with an @ for a tagged agent not in the room or a role with no live holder: two sessions and a lookup by name for every tag. In a load test at 60 messages a second the database saw these checks for about 10 messages a second, so the consumer fell behind.

In this PR we:

  • run the check once a message has committed, on the process that wrote it, in the router's after-commit work, as it already does for agents' replies
  • skip it when every name tagged is one of the room's agents, which the router has read to decide the message
  • move the checks unchanged to clients/mention_warnings.py; the consumer keeps the commands

The ownership tests now use a !help answer to show the consumer runs once, since it no longer posts the warning.

…when only room agents are tagged (CHOO-3667)

The admin's consumer reads every message in a tenant on one process, and
checked each message with an @ for a tagged agent not in the room or a
role with no live holder: two sessions and a lookup by name for every
tag. In a load test at 60 messages a second the database saw these
checks for about 10 messages a second, so the consumer fell behind.

The router has read the room's agents to decide the message, so it now
runs the check after commit on the process that wrote the message, and
only when the message tags a name that is none of the room's agents. The
checks themselves moved unchanged to clients/mention_warnings.py.

Copilot AI 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.

🟡 Changes recommended

A moderate active issue remains because messages sent by the selected admin actor can trigger absent-agent or role warnings when they contain an @ mention for a non-member.

1 open issue
What changed in this PR

This pull request moves tagged-agent and unreachable-role warnings from the single admin consumer into the message router’s post-commit workflow, reducing database load while preserving command-consumer ownership.

Changes:

  • Extracts mention-warning logic into MentionWarnings and adds unmatched-mention filtering.
  • Schedules warning checks after successful message commits on the writing process.
  • Skips checks when all mentions target agents already in the room.
  • Updates routing, consumer tests, ownership coverage, allowlist tests, and changelog documentation.

This pull request requires changes.

File Summary
core/​tests/​switch_core/​delivery/​test_mention_warnings.py Tests writer-side warnings, filtering, and system-message handling; includes a minor test-name typo.
core/​tests/​switch_core/​db/​test_tenant_exemption_allowlist.py Removes the obsolete command-consumer exemption.
core/​tests/​switch_core/​clients/​test_command_consumer.py Moves mention-warning tests to the extracted implementation.
core/​tests/​switch_core/​clients/​test_command_consumer_ownership.py Verifies command responses remain single-owner operations.
core/​switch_core/​main.py Connects tenant admin actors to the router.
core/​switch_core/​delivery/​router.py Schedules post-commit mention warnings; requires fixes for admin-authored messages and attachment events.
core/​switch_core/​clients/​mention_warnings.py Contains the extracted role and absent-agent warning logic.
core/​switch_core/​clients/​command_consumer.py Retains command handling while removing mention-warning responsibilities.
CHANGELOG.md Documents the post-commit warning optimization and behavior change.

Review effort: Lite

Comment on lines +1681 to +1683
admin = self._admin_for(reads.tenant_id)
if admin is None:
return None
@abeldantas

Copy link
Copy Markdown
Collaborator Author

Combined into #1307 with the other scaling PRs.

@abeldantas abeldantas closed this Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants