fix(x): don't skip unfiltered resolved handle search when entity-extracted

The resolved handle dedup was wrong: if entity_extract found @thedorbrothers
(from @mentions in Phase 1 results), the resolved handle search was skipped
entirely. But entity-extracted handles are searched WITH topic keywords
(from:handle topic), while resolved handles need UNFILTERED search
(from:handle) to find posts that don't mention the topic string.

Example: Dor Brothers' viral tweet (5.5K likes) says "We made a $300M movie
starring @LoganPaul" - no mention of "dor brothers" anywhere. The topic-
filtered entity search missed it. The unfiltered resolved search finds it.

Before: 30 X posts, 161+ likes (entity search only)
After: 40 X posts, 5549+ likes (resolved handle adds viral tweet)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matt Van Horn
2026-02-25 20:35:08 -08:00
parent 4f584a4e96
commit bbaaf28d2e
+7 -7
View File
@@ -436,12 +436,12 @@ def _run_supplemental(
has_handles = entities["x_handles"] and x_source == "bird" has_handles = entities["x_handles"] and x_source == "bird"
has_subs = entities["reddit_subreddits"] and not skip_reddit has_subs = entities["reddit_subreddits"] and not skip_reddit
# Check if resolved handle is new (not already in extracted entities) # Always run unfiltered search for resolved handle (even if entity-extracted).
has_resolved = ( # Entity-extracted handles get topic-filtered queries (from:handle topic),
resolved_handle # but resolved handles need UNFILTERED search (from:handle) to find posts
and x_source == "bird" # that don't mention the topic string (e.g. Dor Brothers' viral tweet about
and resolved_handle.lower() not in {h.lower() for h in entities["x_handles"]} # Logan Paul doesn't contain "dor brothers" in the text).
) has_resolved = bool(resolved_handle) and x_source == "bird"
if not has_handles and not has_subs and not has_resolved: if not has_handles and not has_subs and not has_resolved:
return [], [] return [], []
@@ -471,7 +471,7 @@ def _run_supplemental(
x_future = None x_future = None
resolved_future = None resolved_future = None
max_workers = sum([has_subs, has_handles, has_resolved]) max_workers = sum([bool(has_subs), bool(has_handles), bool(has_resolved)])
with ThreadPoolExecutor(max_workers=max(max_workers, 1)) as executor: with ThreadPoolExecutor(max_workers=max(max_workers, 1)) as executor:
if has_subs: if has_subs:
reddit_future = executor.submit( reddit_future = executor.submit(