Skip to content

feat(discord): per-thread streaming decision based on multibot detection #534

@chaodu-agent

Description

@chaodu-agent

Description

Streaming (edit-based live updates) should be decided per-thread based on multibot detection, not globally based on allow_bot_messages config.

Current Behavior

allow_bot_messages = "off"      -> streaming ON (all threads)
allow_bot_messages = "mentions"  -> streaming OFF (all threads)

A human chatting 1-on-1 with a bot gets no streaming just because the deployment allows bot-to-bot interaction.

Expected Behavior

Default streaming ON. Only disable when 2+ bots detected in the thread.

fn should_stream(other_bot_present: bool) -> bool {
    !other_bot_present
}

Scenarios

Scenario 1: Single bot, human conversation

  1. Human sends @bot-A hello in channel
  2. openab creates new thread
  3. other_bot_present = false (new thread, no other bots)
  4. streaming ON - bot-A responds with live edit updates
  5. Human sends follow-up (no mention) - bot-A still alone - streaming ON

Scenario 2: Second bot joins mid-conversation

  1. Thread has bot-A + human (streaming ON)
  2. Human sends @bot-B can you help too?
  3. bot-B checks thread, sees bot-A -> other_bot_present = true
  4. bot-B responds with send-once (no streaming)
  5. multibot_threads cache updated for this thread
  6. Human sends @bot-A what do you think?
  7. bot-A checks thread, sees bot-B -> other_bot_present = true
  8. bot-A switches to send-once (was streaming before, now off)

Scenario 3: Channel message without mention

  1. Human sends hello everyone in channel (no @mention)
  2. Bot ignores - no streaming decision needed

Scenario 4: Bot-to-bot conversation

  1. bot-B sends @bot-A please review this in thread
  2. bot-A checks thread -> other_bot_present = true
  3. send-once (bot-to-bot always send-once)

Use Case

Users deploying openab with allow_bot_messages=mentions for multi-agent collaboration lose streaming in ALL threads, including 1-on-1 human conversations. This degrades the human UX unnecessarily. Per-thread streaming lets the same deployment provide live edit updates for single-bot threads while safely using send-once in multi-bot threads.

Implementation Notes

The data is already there:

  • multibot_threads cache tracks which threads have multiple bots
  • other_bot_present is computed per-thread in bot_participated_in_thread()
  • use_streaming() needs to change from per-adapter global to per-thread

The allow_bot_messages config should have no effect on streaming decisions.

Background

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions