Skip to content

fix: prevent cross-space message contamination in group conversation grouping#5

Merged
ChristopherJHart merged 3 commits intomainfrom
fix-conversation-grouping-bug
Aug 6, 2025
Merged

fix: prevent cross-space message contamination in group conversation grouping#5
ChristopherJHart merged 3 commits intomainfrom
fix-conversation-grouping-bug

Conversation

@ChristopherJHart
Copy link
Collaborator

Problem

The application was incorrectly grouping messages from different WebEx spaces into the same conversation when they occurred within the same time window. This resulted in conversations that mixed participants and messages from completely unrelated WebEx spaces, making the conversation summaries confusing and inaccurate.

Root Cause

The group_group_conversations function in summarizer/grouping.py was processing messages from all group spaces together without first separating them by space_id. This caused the time-based context window logic to incorrectly group messages across space boundaries.

The bug occurred because:

  1. group_all_conversations correctly separated DM vs GROUP messages
  2. All GROUP messages (from multiple spaces) were passed to group_group_conversations as a single list
  3. group_group_conversations applied conversation logic to the mixed list without space separation
  4. Messages from different spaces within the time window were grouped together

Solution

Modified group_group_conversations to follow the same pattern as group_dm_conversations:

  1. Group messages by space first using the existing group_messages_by_space() helper function
  2. Process each space individually to prevent cross-space contamination
  3. Maintain proper conversation ID sequencing across multiple spaces
  4. Preserve all existing functionality for single-space conversation grouping

Changes Made

Core Fix (summarizer/grouping.py)

  • Added space-based separation logic to group_group_conversations
  • Updated function docstring to document the cross-space contamination prevention
  • Maintained backward compatibility for all existing functionality
  • Improved code formatting to meet linting standards

Test Coverage (tests/test_grouping.py)

  • Added comprehensive unit tests that reproduce the exact bug scenario
  • Test case test_cross_space_grouping_bug_is_fixed verifies:
    • Messages from different spaces are kept separate
    • No conversation contains messages from multiple spaces
    • Participants are correctly isolated by space
  • Test case test_single_space_grouping_still_works ensures:
    • Existing single-space grouping logic continues to work
    • No regression in core functionality

Verification

  • ✅ All existing tests continue to pass
  • ✅ New tests demonstrate the bug is fixed
  • ✅ Application runs without errors
  • ✅ No breaking changes to existing functionality

Impact

This fix ensures that conversation summaries accurately reflect the actual participants and context of each WebEx space, eliminating confusion caused by cross-space message mixing. Users will now see properly isolated conversations that match their actual WebEx space interactions.

@ChristopherJHart ChristopherJHart added the bug Something isn't working label Aug 6, 2025
@ChristopherJHart ChristopherJHart changed the title fix: [revent cross-space message contamination in group conversation grouping fix: prevent cross-space message contamination in group conversation grouping Aug 6, 2025
…upingBugFix

* Updated message content formatting for better readability.
* Revised test docstrings for clarity on message grouping behavior.
* Enhanced assertion messages for better debugging context.
@ChristopherJHart ChristopherJHart merged commit ea6775c into main Aug 6, 2025
24 checks passed
@ChristopherJHart ChristopherJHart deleted the fix-conversation-grouping-bug branch August 6, 2025 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant