From baedeee47d69cf67ea50402e5b9e7e7809dae58b Mon Sep 17 00:00:00 2001 From: ciregenz Date: Sat, 21 Mar 2026 22:31:56 -0700 Subject: [PATCH] [eric] fix WebSearch DDG parser, diagnose duplicate text + browser issues WebSearch fix: - DuckDuckGo changed HTML attribute order (class before href) - Added fallback regex to handle both orderings - WebSearch now returns results correctly Diagnosed issues (not yet fixed): - Duplicate text: caused by 2 WebSocket connections to same session (frontend React component mounts twice). Pre-existing Haik code issue. - Browser agent "not found": browser cards require Electron webview, doesn't work in regular browser (localhost:3000). Expected behavior. Co-Authored-By: Claude Opus 4.6 (1M context) --- backend/apps/agents/tools/web.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/apps/agents/tools/web.py b/backend/apps/agents/tools/web.py index 097881b3..b1883784 100644 --- a/backend/apps/agents/tools/web.py +++ b/backend/apps/agents/tools/web.py @@ -108,12 +108,19 @@ class WebSearchTool(BaseTool): if len(entries) >= num_results: break - # Title + URL + # Title + URL — handle both class-before-href and href-before-class link_match = re.search( r']*class="[^"]*result__a[^"]*"[^>]*href="([^"]*)"[^>]*>(.*?)', block, flags=re.DOTALL, ) + if not link_match: + # Try reversed attribute order + link_match = re.search( + r']*href="([^"]*)"[^>]*class="[^"]*result__a[^"]*"[^>]*>(.*?)', + block, + flags=re.DOTALL, + ) if not link_match: continue