Skip to content

Bug: Bot posts turn-limit warning in channels it is not allowed in #633

@themaxagent

Description

@themaxagent

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

  1. 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).
  2. Set up a Kiro cronjob that fires periodically in channel A (a non-thread channel
    message).
  3. Since cronjob messages are bot messages with no human resets, the bot turn counter
    accumulates across firings.
  4. Once the counter hits soft_limit (default 20), Gemini's WarnAndStop fires.
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingp2Medium — planned work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions