diagnose_goals_flow.pyā¢5.33 kB
#!/usr/bin/env python3
"""
š Diagnostic Script: Check Goals Flow and Updates
"""
def diagnose_goals_flow():
"""Diagnose why the goals flow is broken"""
print("š DIAGNOSING GOALS FLOW AND UPDATES")
print("=" * 60)
try:
# Test 1: Check if prompt generator is working
print("1ļøā£ Testing prompt generator availability...")
from prompt_generator import PromptGenerator
generator = PromptGenerator()
print("ā
PromptGenerator available")
# Test 2: Check context gathering
print("\n2ļøā£ Testing context gathering...")
try:
context = generator._gather_context_data("test goals flow", "smart")
print("ā
Context gathering successful")
print(f"š Context type: {type(context)}")
# Check specific fields
print(f"š¬ Conversation summary: {hasattr(context, 'conversation_summary')}")
print(f"š Action history: {hasattr(context, 'action_history')}")
print(f"šÆ Project plans: {hasattr(context, 'project_plans')}")
if hasattr(context, 'project_plans'):
print(f"šÆ Project plans content: {context.project_plans[:100]}...")
else:
print("ā Project plans field missing!")
except Exception as e:
print(f"ā Context gathering failed: {e}")
return
# Test 3: Check optimized prompt generator
print("\n3ļøā£ Testing optimized prompt generator...")
try:
from optimized_prompt_generator import OptimizedPromptGenerator
opt_generator = OptimizedPromptGenerator()
print("ā
OptimizedPromptGenerator available")
# Test context conversion
context_dict = opt_generator._context_to_dict(context)
print(f"ā
Context conversion successful")
print(f"š Available keys: {list(context_dict.keys())}")
print(f"šÆ Project plans in dict: {'project_plans' in context_dict}")
except Exception as e:
print(f"ā Optimized prompt generator failed: {e}")
return
# Test 4: Check intent classification
print("\n4ļøā£ Testing intent classification...")
try:
if opt_generator.intent_selector:
relevant_context, intent_analysis = opt_generator.intent_selector.select_relevant_context(
"test goals flow and updates",
context_dict
)
print(f"ā
Intent classification successful")
print(f"šÆ Intent: {intent_analysis.primary_intent.value}")
print(f"š Context requirements: {intent_analysis.context_requirements}")
print(f"š§ Selected context: {list(relevant_context.keys())}")
print(f"šÆ Project plans in selected: {'project_plans' in relevant_context}")
else:
print("ā ļø Intent selector not available")
except Exception as e:
print(f"ā Intent classification failed: {e}")
# Test 5: Check conversation context formatting
print("\n5ļøā£ Testing conversation context formatting...")
try:
conversation_context = opt_generator._format_phase1_conversation_context(context_dict)
print(f"ā
Conversation context formatting successful")
print(f"š Result length: {len(conversation_context)}")
print(f"š¬ Contains context: {'š¬ CONTEXT:' in conversation_context}")
print(f"š Contains recent: {'š RECENT:' in conversation_context}")
print(f"šÆ Contains goals: {'šÆ GOALS:' in conversation_context}")
print(f"š Formatted result:\n{conversation_context}")
except Exception as e:
print(f"ā Conversation context formatting failed: {e}")
# Test 6: Check essential context safeguard
print("\n6ļøā£ Testing essential context safeguard...")
try:
# Create a filtered context that's missing some sections
filtered_context = {'user_preferences': 'test', 'agent_metadata': 'test'}
safeguarded_context = opt_generator._ensure_essential_context(filtered_context, context_dict)
print(f"ā
Essential context safeguard successful")
print(f"š Safeguarded keys: {list(safeguarded_context.keys())}")
print(f"šÆ Project plans safeguarded: {'project_plans' in safeguarded_context}")
except Exception as e:
print(f"ā Essential context safeguard failed: {e}")
print("\n" + "=" * 60)
print("š DIAGNOSIS COMPLETE")
# Final assessment
if 'šÆ GOALS:' in conversation_context:
print("š SUCCESS: Goals flow is working!")
else:
print("ā FAILURE: Goals flow is broken!")
print("š Check the diagnostic output above for issues")
except Exception as e:
print(f"ā Error during diagnosis: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
diagnose_goals_flow()