"""Test exact screen_candidates_for_telegram from agent_monitor with 5 candidates.""" import sys, asyncio from pathlib import Path sys.path.insert(0, str(Path(__file__).parent / "src")) import aima_agent_monitor as m # Get 5 real candidates import csv, sqlite3 BASE = Path(__file__).parent used_leads, used_phones = m.collect_used() conn = sqlite3.connect(str(m.DB)) all_rows = conn.execute( "SELECT lead_id, first_name, last_name, phone, registered_at, last_activity_at " "FROM aima_imported_contacts WHERE dataset=? ORDER BY row_index DESC", (m.DATASET,) ).fetchall() conn.close() candidates = [r for r in all_rows if r[3] and str(r[0]) not in used_leads and r[3] not in used_phones] test_candidates = candidates[:5] print(f"Testing with {len(test_candidates)} candidates from {m.DATASET}", flush=True) for r in test_candidates: print(f" {r[0]} {r[3][-4:]}", flush=True) # Now call screen_candidates_for_telegram exactly as monitor does print("\nCalling screen_candidates_for_telegram...", flush=True) result = asyncio.get_event_loop().run_until_complete( m.screen_candidates_for_telegram(test_candidates, 3) ) print(f"Found: {len(result)} confirmed", flush=True)