Description
src/slack.rs:1120 — other_bot_present is always false because the multibot_threads cache is queried with the wrong key.
The cache is written in note_other_bot_in_thread (line 91) keyed by thread_ts:
cache.entry(thread_ts.to_string()).or_insert_with(tokio::time::Instant::now);
It is correctly read in bot_participated_in_thread (line 228) using thread_ts:
cache.get(thread_ts).is_some_and(|ts| ts.elapsed() < self.session_ttl)
But handle_message at line 1120 diverges and uses channel_id — a key that never exists in the cache:
// Bug: always false — channel_id is never a key in multibot_threads
cache.contains_key(&thread_channel.channel_id)
Since use_streaming() (line 419) returns !other_bot_present, streaming is permanently ON for all threads regardless of whether another bot is present. Regresses PR #535.
Suggested fix:
let other_bot_present = {
let cache = adapter.multibot_threads.lock().await;
thread_channel.thread_id.as_deref()
.is_some_and(|ts| cache.get(ts).is_some_and(|inst| inst.elapsed() < adapter.session_ttl))
};
Uses .get(ts).is_some_and(|inst| inst.elapsed() < session_ttl) to match the TTL-aware pattern at line 228, rather than bare contains_key.
Steps to Reproduce
Precondition: Two bots (openab-bot-1, openab-bot-2) running in the same workspace, both members of the test channel.
- @mention
openab-bot-1 in a channel — confirm it replies (edited: true in conversations.replies is expected at this point; only bot-1 is in the thread).
- In the same thread, @mention
openab-bot-2 — get a reply. This calls note_other_bot_in_thread and populates the cache with the thread_ts.
- In that same thread, @mention
openab-bot-1 again.
- Inspect
openab-bot-1's reply via conversations.replies.
Expected Behavior
openab-bot-1's reply in step 4 should have no edited field — streaming must be disabled once another bot has posted in the thread.
Environment
- Version:
openab-0.8.1-beta.3
- Platform: Slack
- Confirmed reproduction: thread
1777050262.713699 in #all-chuangwangfu — bot-1 reply after bot-2 posted still returned edited: true
- Tested with: two live bot instances against Slack API
Description
src/slack.rs:1120—other_bot_presentis alwaysfalsebecause themultibot_threadscache is queried with the wrong key.The cache is written in
note_other_bot_in_thread(line 91) keyed bythread_ts:It is correctly read in
bot_participated_in_thread(line 228) usingthread_ts:But
handle_messageat line 1120 diverges and useschannel_id— a key that never exists in the cache:Since
use_streaming()(line 419) returns!other_bot_present, streaming is permanently ON for all threads regardless of whether another bot is present. Regresses PR #535.Suggested fix:
Steps to Reproduce
Precondition: Two bots (
openab-bot-1,openab-bot-2) running in the same workspace, both members of the test channel.openab-bot-1in a channel — confirm it replies (edited: trueinconversations.repliesis expected at this point; only bot-1 is in the thread).openab-bot-2— get a reply. This callsnote_other_bot_in_threadand populates the cache with thethread_ts.openab-bot-1again.openab-bot-1's reply viaconversations.replies.Expected Behavior
openab-bot-1's reply in step 4 should have noeditedfield — streaming must be disabled once another bot has posted in the thread.Environment
openab-0.8.1-beta.31777050262.713699in#all-chuangwangfu—bot-1reply afterbot-2posted still returnededited: true