a digital person for bluesky

Fix halt message queue clearing issue

When a halt command is received, the bot now properly deletes the queue file
before terminating. This prevents the halt message from being reprocessed
when the bot restarts, which could cause an infinite halt loop.

Changes:
- Added queue_filepath parameter to process_mention()
- Delete queue file and mark notification as processed before exit(0)
- Updated all process_mention() calls to pass the filepath

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

Changed files
+19 -3
+19 -3
bsky.py
··· 186 186 return void_agent 187 187 188 188 189 - def process_mention(void_agent, atproto_client, notification_data): 189 + def process_mention(void_agent, atproto_client, notification_data, queue_filepath=None): 190 190 """Process a mention and generate a reply using the Letta agent. 191 + 192 + Args: 193 + void_agent: The Letta agent instance 194 + atproto_client: The AT Protocol client 195 + notification_data: The notification data dictionary 196 + queue_filepath: Optional Path object to the queue file (for cleanup on halt) 191 197 192 198 Returns: 193 199 True: Successfully processed, remove from queue ··· 511 517 except: 512 518 logger.info("Halt reason: <unable to parse>") 513 519 520 + # Delete the queue file before terminating 521 + if queue_filepath and queue_filepath.exists(): 522 + queue_filepath.unlink() 523 + logger.info(f"✅ Deleted queue file: {queue_filepath.name}") 524 + 525 + # Also mark as processed to avoid reprocessing 526 + processed_uris = load_processed_notifications() 527 + processed_uris.add(notification_data.get('uri', '')) 528 + save_processed_notifications(processed_uris) 529 + 514 530 # Export agent state before terminating 515 531 export_agent_state(CLIENT, void_agent) 516 532 ··· 731 747 # Process based on type using dict data directly 732 748 success = False 733 749 if notif_data['reason'] == "mention": 734 - success = process_mention(void_agent, atproto_client, notif_data) 750 + success = process_mention(void_agent, atproto_client, notif_data, queue_filepath=filepath) 735 751 if success: 736 752 message_counters['mentions'] += 1 737 753 elif notif_data['reason'] == "reply": 738 - success = process_mention(void_agent, atproto_client, notif_data) 754 + success = process_mention(void_agent, atproto_client, notif_data, queue_filepath=filepath) 739 755 if success: 740 756 message_counters['replies'] += 1 741 757 elif notif_data['reason'] == "follow":