forked from actuallyrizzn/broca-2
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Feature Request: Progress Updates and Enhanced Response Delivery for Long-Running Jobs
Problem Statement
Broca currently processes messages that can take 30+ minutes to complete, but users receive no feedback during this time. This leads to:
- User Confusion: Users don't know if their message is being processed or if the system is stuck
- Lost Responses: When timeouts occur, responses may be generated but never delivered to users
- Poor UX: No visibility into which message is being processed or how long it's taking
Proposed Solution
Implement a comprehensive progress update system that:
- Sends Initial Status: Notifies users when processing begins
- Periodic Updates: Sends progress updates every 2 minutes for long-running operations
- Context-Aware Messaging: Provides different messages based on elapsed time
- Guaranteed Delivery: Ensures responses are sent even on timeout/error with retry logic
- Timeout Handling: Explicitly handles timeouts and notifies users appropriately
Implementation Details
Progress Update System
- Update Interval: 2 minutes (120 seconds) - appropriate for 30+ minute operations
- Initial Message: "🔄 Processing your message... This may take several minutes."
- Periodic Updates:
- 0-5 minutes: "⏳ Still processing... (Xm Ys)"
- 5-10 minutes: "⏳ Still processing... (X minutes elapsed). This is taking longer than usual."
- 10+ minutes: "⏳ Still processing... (X minutes elapsed). Complex operations can take 30+ minutes. Please be patient."
Enhanced Response Delivery
- Multiple Routing Attempts: Up to 3 attempts to deliver responses
- Timeout Handling: Catches
asyncio.TimeoutErrorand sends appropriate notifications - Error Recovery: Sends user-friendly error messages when processing fails
- Status Tracking: New "timeout" status to distinguish timeouts from other failures
Key Changes
File: runtime/core/queue.py
- Added
PROGRESS_UPDATE_INTERVAL = 120constant (2 minutes) - Added
_send_progress_update()method to send status messages to users - Modified
_process_with_core_block()to:- Accept
message_idparameter for progress updates - Send initial "processing" status
- Run periodic progress updates in background task
- Handle timeouts explicitly with
asyncio.TimeoutError - Send notifications on errors/timeouts
- Accept
- Enhanced
_route_response()with retry logic (up to 3 attempts) - Modified main processing loop to:
- Always attempt to send responses (even on timeout)
- Send timeout notifications when appropriate
- Retry response routing on failure
Benefits
- Improved User Experience: Users always know what's happening
- Reduced Support Burden: Fewer "is it working?" questions
- Better Error Handling: Users are notified of issues and timeouts
- Guaranteed Delivery: Responses are sent even when operations timeout
- Scalability: System handles very long-running operations gracefully
Example User Experience
Before:
- User sends message
- 30 minutes of silence
- User assumes system is broken
After:
- User sends message
- Immediate: "🔄 Processing your message... This may take several minutes."
- 2 minutes: "⏳ Still processing... (2m 0s)"
- 4 minutes: "⏳ Still processing... (4m 0s)"
- 10 minutes: "⏳ Still processing... (10 minutes elapsed). Complex operations can take 30+ minutes. Please be patient."
- 30 minutes: Full response delivered (or timeout notification if applicable)
Technical Considerations
- Progress updates run in background tasks that are properly cancelled when processing completes
- Updates are sent through the existing plugin handler system (no new dependencies)
- Timeout handling distinguishes between client-side timeouts and server-side timeouts
- Retry logic prevents lost responses due to transient network issues
Testing Recommendations
- Test with long-running queries (30+ minutes)
- Verify progress updates appear every 2 minutes
- Test timeout scenarios
- Verify responses are sent even after timeouts
- Check that users see all status messages
- Test error recovery and retry logic
Related Issues
This addresses user feedback about:
- Long wait times with no feedback
- Lost responses on timeout
- Unclear processing status
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request