From 0112b9a9a7ba733f146f971907cf5a7f71609597 Mon Sep 17 00:00:00 2001 From: Cameron Pfiffer Date: Sat, 23 Aug 2025 01:04:07 -0700 Subject: [PATCH] Fix X bot synthesis functionality with custom implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace import of send_synthesis_message from bsky.py with custom send_x_synthesis_message function - Create X-specific synthesis prompt focusing on X/Twitter platform experiences - Use simplified Letta client message creation instead of streaming for X synthesis - Remove dependency on atproto_client and bsky context that was causing 'NoneType' errors - Add proper error handling in X synthesis function X bot synthesis now works independently without bsky.py dependencies. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- x.py | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/x.py b/x.py index ed934c1..9c3d6a0 100644 --- a/x.py +++ b/x.py @@ -2054,6 +2054,44 @@ def initialize_x_void(): return void_agent +def send_x_synthesis_message(letta_client, agent_id): + """ + Send a simple synthesis message to the X agent. + Simplified version for X bot without atproto dependencies. + """ + try: + from datetime import date + today = date.today() + + synthesis_prompt = f"""Time for synthesis and reflection on your X (Twitter) experiences. + +Today's date: {today.strftime('%B %d, %Y')} + +Please reflect on: +1. Recent X interactions and conversations you've had +2. Patterns you've observed in X discussions +3. Your evolving understanding of the X platform dynamics +4. Notable exchanges or insights from X users +5. How your presence on X is developing + +Use your memory tools to record significant insights and observations.""" + + logger.info("🧠 Sending X synthesis message to agent") + + # Send simple synthesis message + response = letta_client.agents.messages.create( + agent_id=agent_id, + messages=[{"role": "user", "content": synthesis_prompt}], + max_steps=50 + ) + + logger.info("✅ X synthesis message completed successfully") + return True + + except Exception as e: + logger.error(f"Error sending X synthesis message: {e}") + return False + def x_main_loop(testing_mode=False, cleanup_interval=10, synthesis_interval=600, synthesis_only=False): """ Main X bot loop that continuously monitors for mentions and processes them. @@ -2069,7 +2107,7 @@ def x_main_loop(testing_mode=False, cleanup_interval=10, synthesis_interval=600, from time import sleep from config_loader import get_letta_config from letta_client import Letta - from bsky import send_synthesis_message + # We'll create our own X synthesis function instead logger.info("=== STARTING X VOID BOT ===") @@ -2116,8 +2154,7 @@ def x_main_loop(testing_mode=False, cleanup_interval=10, synthesis_interval=600, try: # Send synthesis message immediately on first run logger.info("🧠 Sending X synthesis message") - # No atproto_client for X bot, just pass None - send_synthesis_message(letta_client, void_agent.id, atproto_client=None) + send_x_synthesis_message(letta_client, void_agent.id) # Wait for next interval logger.info(f"Waiting {synthesis_interval} seconds until next synthesis...") @@ -2153,7 +2190,7 @@ def x_main_loop(testing_mode=False, cleanup_interval=10, synthesis_interval=600, current_time = time.time() if current_time - last_synthesis_time >= synthesis_interval: logger.info(f"⏰ {synthesis_interval/60:.1f} minutes have passed, triggering X synthesis") - send_synthesis_message(letta_client, void_agent.id, atproto_client=None) + send_x_synthesis_message(letta_client, void_agent.id) last_synthesis_time = current_time # Log cycle completion -- 2.51.2