Skip to content

Privacy: Slack callback should stop responding when user continues conversation via Web UI #20

Open

Description

@enyst

Summary

When a user starts a conversation via Slack and then continues that same conversation via the Web UI, the agent's responses are still being posted to the Slack thread. This is a privacy concern because the user may have intentionally moved to the Web UI for privacy.

Current Behavior

  1. User sends a message via Slack → Agent responds in the same Slack thread
  2. User sends another message in that Slack thread → Agent responds again in the same thread (correct)
  3. User goes to Web UI, finds that conversation, sends a message → Agent still responds in Slack thread (incorrect)

Expected Behavior

Once the user switches to a different interface (Web UI), responses should only go to that interface. The Slack callback should detect that the last user message came from a different source and stop posting to Slack.

Technical Analysis

The current implementation in enterprise/server/conversation_callback_processor/slack_callback_processor.py:

  1. SlackCallbackProcessor is registered when a new Slack conversation is created
  2. When agent state changes to AWAITING_USER_INPUT or FINISHED, the callback is invoked
  3. The callback sends a summary to Slack without checking the source of the last user message

The callback currently tracks last_user_msg_id to prevent duplicate processing, but doesn't track whether the message originated from Slack or the Web UI.

Proposed Solution

Track Slack-originated message IDs in the callback processor:

  1. Add a last_slack_message_id: int | None field to SlackCallbackProcessor
  2. When Slack sends a message to the conversation (via SlackUpdateExistingConversationView.send_message_to_v0_conversation or similar), store the resulting event ID in the processor
  3. In SlackCallbackProcessor.__call__, check if last_user_msg[0].id matches the last_slack_message_id
  4. Only send to Slack if the IDs match; otherwise, log and skip

Implementation Details

# In SlackCallbackProcessor
class SlackCallbackProcessor(ConversationCallbackProcessor):
    slack_user_id: str
    channel_id: str
    message_ts: str
    thread_ts: str | None
    team_id: str
    last_user_msg_id: int | None = None
    last_slack_message_id: int | None = None  # NEW: Track Slack-originated message
    
    async def __call__(self, callback, observation):
        # ... existing checks ...
        
        # Get the ID of the last user message  
        current_msg_id = last_user_msg[0].id if last_user_msg else None
        
        # NEW: Check if last message came from Slack
        if current_msg_id != self.last_slack_message_id:
            logger.info(
                f'[Slack] Skipping response - last message (id={current_msg_id}) '
                f'did not originate from Slack (expected={self.last_slack_message_id})'
            )
            return
        
        # ... continue with existing logic ...

Required Changes

  1. SlackCallbackProcessor: Add source tracking and check
  2. SlackUpdateExistingConversationView: After sending message, update the callback processor with the new message ID
  3. Consider applying similar changes to other integrations (GitHub, GitLab, Jira, Linear) for consistency

Impact

  • User Privacy: Users can trust that moving to Web UI provides privacy from Slack
  • Backward Compatible: Existing Slack-only conversations continue to work as expected
  • Other Integrations: Similar pattern can be applied to GitHub, GitLab, Jira, Linear integrations

Related Files

  • enterprise/server/conversation_callback_processor/slack_callback_processor.py
  • enterprise/integrations/slack/slack_view.py
  • enterprise/integrations/slack/slack_manager.py
  • enterprise/storage/conversation_callback.py

Activity

  1. enyst commented on Feb 13, 2026

    @enyst
    MemberAuthor

    V1 Fix Implementation

    The V1 fix has been implemented in PR #TBD. Here's how the V1 fix works:

    Changes to SlackV1CallbackProcessor

    1. Added _should_respond_to_slack(conversation_id) method:

      • Checks if last_slack_message_content is stored in slack_view_data
      • Fetches the last user message from the conversation via the agent server API
      • Returns True if messages match (from Slack) or if tracking is disabled (backward compatibility)
      • Returns False if messages don't match (user sent message via Web UI)
    2. Added _get_last_user_message(conversation_id) method:

      • Connects to the agent server using existing patterns
      • Fetches recent events and finds the most recent user message
      • Returns the message content or None if not found
    3. Modified __call__ method:

      • Added privacy check before sending summary to Slack
      • If check fails, returns success with detail indicating skip reason
      • If check passes, continues with normal flow

    Changes to slack_view.py

    1. Updated _create_slack_v1_callback_processor:

      • Now accepts message_content parameter
      • Stores last_slack_message_content in slack_view_data
    2. Updated _create_v1_conversation:

      • Passes initial user instructions to the callback processor
    3. Updated send_message_to_v1_conversation:

      • Before sending follow-up messages, updates the existing callback's slack_view_data['last_slack_message_content']
      • Uses EventCallbackService to find and update the callback

    Backward Compatibility

    • If last_slack_message_content is not set in slack_view_data, the privacy check is skipped
    • Existing callbacks in the database will continue to work as before
    • New callbacks will have privacy tracking enabled

    Tests Added

    • test_skips_response_when_message_not_from_slack: Verifies callback skips when message came from Web UI
    • test_sends_response_when_message_from_slack: Verifies callback processes when message came from Slack
    • test_backward_compatibility_when_no_tracking: Verifies old callbacks still work
    • test_last_slack_message_content_serialization: Verifies data is properly stored/restored
  2. enyst commented on Feb 13, 2026

    @enyst
    MemberAuthor

    Updated: The V1 fix has been implemented in PR OpenHands/OpenHands#12866 (OpenHands/OpenHands#12866)

    The V0 (legacy) fix was implemented in PR OpenHands/OpenHands#12864 (OpenHands/OpenHands#12864)

    Both PRs implement the same privacy fix: tracking the content of messages sent from Slack and only sending responses back to Slack when the last user message originated from Slack.

  3. enyst commented on Feb 13, 2026

    @enyst
    MemberAuthor

    Proposed Alternative Solution: Track Message Origin at the Event Level

    After investigating the V1 architecture, I've identified a fundamental challenge with the current content-comparison approach and propose a cleaner solution.

    The Core Problem

    The current approach (comparing message content) has several issues:

    1. Summary instructions are user messages: When the callback sends a summary request, it's added as a user message. This pollutes the "last user message" check.

    2. Content comparison is fragile: If users send similar messages from different sources, content matching fails.

    3. Inefficient fetching: Currently fetching 50 events just to find one message.

    Proposed Solution: Add trigger_source to Message Events

    Option A: Extend MessageEvent with a trigger_source field

    The SDK's MessageEvent (or the message payload) could include an optional trigger_source field:

    class MessageEvent:
        role: str  # 'user' or 'assistant'
        content: list[Content]
        trigger_source: str | None = None  # 'slack', 'web_ui', 'callback', 'api', etc.

    Flow:

    1. When Slack sends a message → trigger_source = 'slack'
    2. When Web UI sends a message → trigger_source = 'web_ui'
    3. When callback sends summary instruction → trigger_source = 'callback'
    4. Callback checks: fetch last user message where trigger_source != 'callback', check if trigger_source == 'slack'

    Benefits:

    • Clean separation of message origins
    • No content comparison needed
    • Works for all integrations (Slack, GitHub, Jira, etc.)
    • Enables future features (analytics, audit trails)

    Option B: Use Conversation-Level "Active Channel" Tracking

    Instead of per-message tracking, track the "active channel" at the conversation level:

    class AppConversationInfo:
        ...
        last_user_interaction_source: str | None = None  # 'slack', 'web_ui', etc.

    Flow:

    1. When ANY user message is sent, update last_user_interaction_source
    2. Slack sends message → set to 'slack'
    3. Web UI sends message → set to 'web_ui'
    4. Callback checks this field before sending to Slack

    Benefits:

    • Simpler than per-message tracking
    • Single source of truth
    • Easy to query

    Drawbacks:

    • Requires all message entry points to update this field
    • Web UI would need to know about this field

    Option C: Callback Self-Disabling After Response

    The simplest approach - each callback responds once per "user turn":

    class SlackV1CallbackProcessor:
        has_responded_to_current_turn: bool = False
        
        async def __call__(...):
            if self.has_responded_to_current_turn:
                return None  # Skip
            
            # ... do work ...
            
            self.has_responded_to_current_turn = True
            # Callback is saved, so this persists

    When Slack sends a NEW message, reset the flag.

    Benefits:

    • No changes to message/event models
    • Self-contained within Slack integration

    Drawbacks:

    • Doesn't solve the privacy concern if user switches to Web UI mid-conversation
    • Only prevents duplicate responses

    Recommendation

    Option A (trigger_source on messages) is the cleanest long-term solution because:

    1. It's explicit and unambiguous
    2. It works across all integrations
    3. It enables proper audit trails
    4. No special handling needed for callback-generated messages

    However, it requires SDK changes. If that's too invasive, Option B is a good alternative that can be implemented entirely in the enterprise codebase.

    Questions for Discussion

    1. Is modifying the SDK's MessageEvent to add trigger_source acceptable?
    2. Should this be a per-message field or a conversation-level field?
    3. Are there existing mechanisms in the SDK for message metadata that we can leverage?
  4. added
    enhancement
    on Mar 4, 2026
  5. github-actions commented on Apr 19, 2026

    @github-actions
    Contributor

    This issue is stale because it has been open for 40 days with no activity. Remove the stale label or leave a comment, otherwise it will be closed in 10 days.

  6. github-actions commented on Jun 1, 2026

    @github-actions
    Contributor

    This issue is stale because it has been open for 40 days with no activity. Remove the stale label or leave a comment, otherwise it will be closed in 10 days.

  7. github-actions commented on Jun 11, 2026

    @github-actions
    Contributor

    This issue was automatically closed due to 50 days of inactivity. We do this to help keep the issues somewhat manageable and focus on active issues.

  8. reopened this on Jun 11, 2026
  9. github-actions commented on Jul 22, 2026

    @github-actions
    Contributor

    This issue is stale because it has been open for 40 days with no activity. Remove the stale label or leave a comment, otherwise it will be closed in 10 days.

  10. transferred this issue fromOpenHands/OpenHandson Jul 27, 2026
  11. all-hands-bot commented on Sep 4, 2026

    @all-hands-bot
    Contributor

    [Automatic Post]: This issue has had no activity for 39 days (labels: enhancement). Could someone take a look when they have a chance and help figure out next steps?

    Generated by OpenHands automation on behalf of the user.

  12. all-hands-bot commented on Oct 16, 2026

    @all-hands-bot
    Contributor

    [Automatic Post]: This issue has had no activity for 41 days (labels: enhancement). Could someone take a look when they have a chance and help figure out next steps?

    Generated by OpenHands automation on behalf of the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions