From 80400f743148e34dadcc0f06a49f24ba4991b9fd Mon Sep 17 00:00:00 2001 From: Cameron Pfiffer Date: Sun, 19 Oct 2025 13:14:45 -0700 Subject: [PATCH] Add validation for non-empty reason in memory deletion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ensures flag_archival_memory_for_deletion requires a non-empty reason field before processing deletions. Logs warning if reason is missing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- bsky.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bsky.py b/bsky.py index 853b977..93a5a55 100644 --- a/bsky.py +++ b/bsky.py @@ -675,6 +675,9 @@ To reply, use the add_post_to_bluesky_reply_thread tool: if message.name == 'add_post_to_bluesky_reply_thread': tool_call_results[message.tool_call_id] = message.status logger.debug(f"Tool result: {message.tool_call_id} -> {message.status}") + elif message.name == 'flag_archival_memory_for_deletion': + tool_call_results[message.tool_call_id] = message.status + logger.debug(f"Tool result: {message.tool_call_id} -> {message.status}") elif message.name == 'ignore_notification': # Check if the tool was successful if hasattr(message, 'tool_return') and message.status == 'success': @@ -776,8 +779,8 @@ To reply, use the add_post_to_bluesky_reply_thread tool: memory_text = args.get('memory_text', '') confirm = args.get('confirm', False) - # Only flag for deletion if confirmed - if confirm and memory_text: + # Only flag for deletion if confirmed and has all required fields + if confirm and memory_text and reason: flagged_memories.append({ 'reason': reason, 'memory_text': memory_text @@ -785,6 +788,8 @@ To reply, use the add_post_to_bluesky_reply_thread tool: logger.debug(f"Found memory flagged for deletion (reason: {reason}): {memory_text[:50]}...") elif not confirm: logger.debug(f"Memory deletion not confirmed, skipping: {memory_text[:50]}...") + elif not reason: + logger.warning(f"Memory deletion missing reason, skipping: {memory_text[:50]}...") except json.JSONDecodeError as e: logger.error(f"Failed to parse flag_archival_memory_for_deletion arguments: {e}") -- 2.51.2