[Bounty proposal] fix(slack-app): voice-dictated messages can be sent to the wrong channel on an ambiguous fuzzy match
Description
In plugins/omi-slack-app/message_detector.py, ai_extract_message_and_channel resolves the spoken channel name the AI extracted against the workspace's channel list. After the exact-match check, the fallback is:
for name, id in channel_map.items():
if channel_name.lower() in name.lower() or name.lower() in channel_name.lower():
channel_id = id
channel_name = name
break
channel_map is built from list_channels() (Slack API order), and the loop takes the first channel satisfying a bidirectional substring match — not the closest one. A spoken name like "dev" with both dev-ops and dev-secrets in the workspace (neither an exact match) resolves to whichever one Slack happened to list first, arbitrarily.
The consequence is not cosmetic: all three call sites in main.py (the realtime-timeout auto-send, and the two chat_tool/session-based send paths) call slack_client.send_message immediately once a channel is resolved, with no confirmation step. A wrong guess here silently sends the user's voice-dictated message to a channel they never named.
ai_match_channel, an AI-based fuzzy matcher already defined lower in the same file, is dead code for this path — nothing calls it (grep -rn "ai_match_channel" plugins/omi-slack-app finds only its own definition).
Proposed Fix
Replace the inline loop with a small, pure resolve_channel(spoken_name, channel_map) helper:
- Exact (case-insensitive) match still wins outright.
- Otherwise, score every substring-matching candidate by
difflib.SequenceMatcherratio against the spoken name and take the single closest one. - A genuine tie between two equally-close candidates resolves to "not found" (the existing fallback path) instead of an arbitrary pick.
- Hermetic regression tests for the four cases above, loading
message_detector.pydirectly withopenai/dotenvstubbed (same pattern astest_slack_search.py/test_segments.py), registered in.github/checks-manifest.yaml.
Same shape as #13976 (hive-app update_task_status matching the first search hit) — a fuzzy match with no confirmation step, just with a worse failure mode here (the wrong channel, rather than the wrong task, receives content).
Proposed Bounty Reward: $50.00 USD
Bounty Payout Destination (PayPal): [email protected]
cc @josancamon19 @kodjima33
PR up: https://github.com/BasedHardware/omi/pull/14113
Happy to adjust anything — I'll turn review comments around the same day.
I have implemented and submitted the fix for this issue in PR #14124:
- Added
resolve_channel(spoken_name, channel_map)with exact-match precedence,difflib.SequenceMatcher.ratio()scoring, and ambiguous tie rejection returning(None, None). - Updated
MessageDetector.ai_extract_message_and_channelto useresolve_channeland exposed it as a static method. - Added hermetic regression tests in
plugins/omi-slack-app/test_channel_resolution.pyand registered the check in.github/checks-manifest.yaml. - All tests pass cleanly.
PR #14140 submitted addressing the fuzzy match ambiguity and length guards.
- Replaced arbitrary bidirectional substring fallback with similarity ratio ranking via difflib.
- Rejects ties / ambiguous candidate matches to prevent misdelivery.
- Added short-token threshold to eliminate false positives on common words.
- Hermetically tested with 4/4 passing unit tests.
Implemented the fix and hermetic unit test suite in PR #14180.
- Implemented
resolve_channel(spoken_name, channel_map)with exact match priority,difflib.SequenceMatcher.ratio()scoring for partial matches, and safe tie rejection. - Updated
ai_extract_message_and_channelto useresolve_channel. - Added hermetic test suite
plugins/omi-slack-app/test_resolve_channel.pycovering all 6 cases, registered in.github/checks-manifest.yaml.
USDC Address (Base / Polygon EVM): 0xa709768e0B597df11b2B81AB7ea54EEacd2532D0
Closing as already fixed on current main.
Current main message_detector.resolve_channel rejects ambiguous substring matches instead of first-hit send