Description
The WarnAndStop path in the bot turn limiter (discord.rs ~L295-310) uses parent_id to
check whether a bot is allowed to post a warning, but does not check thread_metadata
to distinguish threads from category children. This is the same class of bug fixed by
detect_thread() (PRs #506/#518/#519), but the fix was never applied to the WarnAndStop
code path.
When a text channel's parent_id (its Discord category) happens to match an entry in
another bot's allowed_channels, allowed_here is incorrectly set to true, causing that
bot to post a turn-limit warning in a channel it should not have access to.
Steps to Reproduce
- Configure two agents — e.g. Kiro with
allowedChannels: [A] and Gemini with
allowedChannels: [B], where channel A is a text channel under a Discord category
whose ID matches one of Gemini's allowed channels (or vice versa).
- Set up a Kiro cronjob that fires periodically in channel A (a non-thread channel
message).
- Since cronjob messages are bot messages with no human resets, the bot turn counter
accumulates across firings.
- Once the counter hits
soft_limit (default 20), Gemini's WarnAndStop fires.
- The
allowed_here check resolves parent_id (the category ID) against Gemini's
allowed_channels — matches — and Gemini posts a warning in channel A where it is not
supposed to operate.
Expected Behavior
Gemini should NOT post the turn-limit warning in channel A. The WarnAndStop path
should use thread_metadata (like detect_thread() does) to distinguish actual
threads from category children. Only when thread_metadata is present should
parent_id be used for the allowed-channel lookup:
if gc.thread_metadata.is_some() && gc.parent_id.is_some_and(|pid| {
self.allowed_channels.contains(&pid.get())
}) {
allowed_here = true;
}
Environment
- OpenAB v0.8.2-beta.3
- discord.rs WarnAndStop block (~L295-310)
Screenshots / Logs
discord discussion: https://discord.com/channels/1491295327620169908/1496961096182006023/1498772341394772130
Description
The WarnAndStop path in the bot turn limiter (discord.rs ~L295-310) uses parent_id to
check whether a bot is allowed to post a warning, but does not check thread_metadata
to distinguish threads from category children. This is the same class of bug fixed by
detect_thread() (PRs #506/#518/#519), but the fix was never applied to the WarnAndStop
code path.
When a text channel's parent_id (its Discord category) happens to match an entry in
another bot's allowed_channels, allowed_here is incorrectly set to true, causing that
bot to post a turn-limit warning in a channel it should not have access to.
Steps to Reproduce
allowedChannels: [A]and Gemini withallowedChannels: [B], where channel A is a text channel under a Discord categorywhose ID matches one of Gemini's allowed channels (or vice versa).
message).
accumulates across firings.
soft_limit(default 20), Gemini'sWarnAndStopfires.allowed_herecheck resolvesparent_id(the category ID) against Gemini'sallowed_channels— matches — and Gemini posts a warning in channel A where it is notsupposed to operate.
Expected Behavior
Gemini should NOT post the turn-limit warning in channel A. The
WarnAndStoppathshould use
thread_metadata(likedetect_thread()does) to distinguish actualthreads from category children. Only when
thread_metadatais present shouldparent_idbe used for the allowed-channel lookup:Environment
Screenshots / Logs
discord discussion: https://discord.com/channels/1491295327620169908/1496961096182006023/1498772341394772130