fix(discord): fix slash command detection when auto-create-thread is on#6293
fix(discord): fix slash command detection when auto-create-thread is on#6293dsocolobsky wants to merge 3 commits into
Conversation
11511d8 to
70b3713
Compare
|
| Test | Status |
|---|---|
| test_mention_then_command | ✅ PASSED |
| test_nickname_mention_then_command | ✅ PASSED |
| test_dm_no_mention_needed | ✅ PASSED |
| test_no_mention_in_channel_dropped | ✅ PASSED |
| test_command_detected_after_auto_thread | ✅ PASSED |
| test_text_before_command_not_detected | ❌ FAILED |
Issue Found
**Test: ** ❌
Failure:
Root Cause: The test asserts that is called, but this is incorrect. When the message content is , the mention is stripped to , which doesn't start with , so it's treated as text, not a command. Text messages don't dispatch to the agent, so is never called.
Expected Behavior: The message should be accepted (not dropped), but no command output is produced, so should NOT be awaited.
Fix Needed: Remove or modify the assertion on line 61 of . The test should instead verify that:
- The message is accepted (not dropped)
- No command is dispatched (send is NOT called)
This is exactly the follow-up fix mentioned in PR #13187:
Fix test assertion for non-command text messages (no agent in mock = no send call)
Recommendation
Do not merge yet. This PR needs the follow-up fix:
Once this fix is applied, the PR is ready to merge. The core functionality (mention stripping + command detection) is working correctly - only the test assertion is wrong.
Reviewer: @teknium1
Tested on: macOS (Apple Silicon), Python 3.11.15
Date: April 20, 2026
✅ Fix Applied - All Tests PassingUpdate: The test assertion issue has been fixed. All 6 tests now passing. Fix AppliedFile: (line 61) Before: After: Test Results (After Fix)
RecommendationReady to merge. The fix:
Reviewer: @teknium1 |
|
Merged via PR #13187 (#13187). Your commits were cherry-picked onto current main with your authorship preserved in git log. Thanks @dsocolobsky! |
…ousResearch#9091, NousResearch#13131 - Fix duplicate 'timezone' import in e2e conftest - Fix test_text_before_command_not_detected asserting send() is awaited when no agent is present in mock setup (text messages don't produce command output)
…ousResearch#9091, NousResearch#13131 - Fix duplicate 'timezone' import in e2e conftest - Fix test_text_before_command_not_detected asserting send() is awaited when no agent is present in mock setup (text messages don't produce command output)
…ousResearch#9091, NousResearch#13131 - Fix duplicate 'timezone' import in e2e conftest - Fix test_text_before_command_not_detected asserting send() is awaited when no agent is present in mock setup (text messages don't produce command output)
…ousResearch#9091, NousResearch#13131 - Fix duplicate 'timezone' import in e2e conftest - Fix test_text_before_command_not_detected asserting send() is awaited when no agent is present in mock setup (text messages don't produce command output)
…ousResearch#9091, NousResearch#13131 - Fix duplicate 'timezone' import in e2e conftest - Fix test_text_before_command_not_detected asserting send() is awaited when no agent is present in mock setup (text messages don't produce command output)
…ousResearch#9091, NousResearch#13131 - Fix duplicate 'timezone' import in e2e conftest - Fix test_text_before_command_not_detected asserting send() is awaited when no agent is present in mock setup (text messages don't produce command output)
What does this PR do?
Fixes text-based
/slashcommands (e.g.@bot /yolo,@bot /usage) not being recognized when sent via@mentionin a Discord channel.The root cause is that
_auto_create_thread()can modifymessage.contentafter mention-stripping but before the/commanddetection check runs. This PR saves a copy of the mention-stripped text before auto-threading and uses that copy for command detection.I've added tests that fail previous to this PR and pass after this PR, plus some required mock/fixture code to support them, I plan to expand on these tests in a separate PR since they're useful.
Related Issue
Fixes #5865
Type of Change
Changes Made
gateway/platforms/discord.py: Save mention-stripped content intonormalized_contentbefore
_auto_create_thread()runs, and use it for/commanddetection and asevent_textdownstream.
tests/e2e/conftest.py: Add Discord mock setup, message factories, and adapter fixtures fore2e testing.
tests/e2e/test_discord_adapter.py: Add 6 e2e tests covering mention stripping, commanddispatch, DMs, and the auto-threading content restoration bug.
How to Test
@bot /yoloor@bot /usageChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/A