Skip to content

fix(fuzzy): search full wishlist, not just top 50#99

Draft
ArtyETH06 wants to merge 1 commit into
mainfrom
ArtyETH06/mcp-fix-fuzzy-lead-research
Draft

fix(fuzzy): search full wishlist, not just top 50#99
ArtyETH06 wants to merge 1 commit into
mainfrom
ArtyETH06/mcp-fix-fuzzy-lead-research

Conversation

@ArtyETH06

Copy link
Copy Markdown
Contributor

Problem

leadbay_research_lead_by_name_fuzzy failed 100% of the time. MCP telemetry (7d ending 2026-06-11): 17 calls, 0 ok, 17 LEAD_NOT_FOUND, recurring across three consecutive MCP-analysis runs (2026-06-02, 2026-06-09, 2026-06-11). A perfect-zero rate is a real defect, not a scope limit.

Root cause

packages/core/src/composite/research-lead-by-name-fuzzy.ts fetched only page 0 (top 50) of the active lens wishlist (discoverLeads.execute(client, {count:50, page:0})), then substring-matched against that window. Any lead beyond the first page was invisible to the matcher.

Crucially, the wishlist is not strictly score-ordered — a high-score lead can land on page 1. Live probe of the test account confirmed: the active lens (last_requested_lens = 40005) has total=51, and "YOUR CAR TODAY LLC" (firmographic score 86) sits on page 1, absent from page 0. The default lens (39107) has total=60 with 10 leads stranded on page 1. Every lookup of such a lead returned a spurious LEAD_NOT_FOUND.

Fix

Page through the full wishlist (capped at 40 pages / 2000 leads) before ranking, breaking when has_more is false. Updated the companyName inputSchema description, the LEAD_NOT_FOUND hint ("searched the full wishlist"), and the promptforge template; regenerated tool-descriptions.generated.ts.

Reproduce-as-eval

Added WORKFLOWS.md workflow #25 — "Fuzzy lead lookup beyond the top page" (scenario: "Research the company YOUR CAR TODAY LLC for me."), a real lead on page 1 of the active test lens. Plus a new unit test research-lead-by-name-fuzzy-pagination.test.ts pinning the page-1 case (mocked).

Verification

  • pnpm -r typecheck — green (4/4 packages)
  • pnpm -r test — green (core 381, promptforge 16, mcp 382)
  • Live eval /eval --workflow 25 — PASS (5/5/5/5), 3 rounds. Rounds 1-2 failed for scenario-quality reasons only (round 1 used a company from the wrong lens; round 2's "YOUR CAR TODAY" parsed as "do you have a car?"). The fix itself was correct throughout — round 3's unambiguous phrasing confirmed the fuzzy tool resolves the page-1 lead with full firmographics (_meta.resolved_from="companyName", score 86) instead of LEAD_NOT_FOUND. The judge scored mission_match / instruction_adherence / no_fabrication / tool_selection_fit all 5/5; invariants 2/2 PASS.

Files changed

  • packages/core/src/composite/research-lead-by-name-fuzzy.ts — full-wishlist pagination (the fix)
  • packages/promptforge/tool-descriptions/composite/research-lead-by-name-fuzzy.md.tmpl — description update
  • packages/core/src/tool-descriptions.generated.ts — regenerated
  • packages/core/test/unit/composite/research-lead-by-name-fuzzy-pagination.test.ts — new regression test
  • WORKFLOWS.md — workflow Publish Leadbay MCP to marketplaces #25 contract + scenario

leadbay_research_lead_by_name_fuzzy fetched only page 0 (top 50) of the
active lens wishlist, so any lead beyond the first page returned a
spurious LEAD_NOT_FOUND. MCP telemetry (7d ending 2026-06-11) showed
17/17 calls failing with LEAD_NOT_FOUND across three consecutive
analysis runs.

Root cause: research-lead-by-name-fuzzy.ts only called discoverLeads with
{count:50, page:0}. The wishlist is paginated (and NOT strictly
score-ordered — a high-score lead can land on page 1), so the substring
matcher never saw leads beyond the top-50 window.

Fix: page through the full wishlist (capped at 40 pages / 2000 leads)
before ranking. Updated the inputSchema description, the LEAD_NOT_FOUND
message, and the promptforge template accordingly.

Reproduce-as-eval: WORKFLOWS.md workflow #25 ("Research the company
YOUR CAR TODAY LLC") — a real lead that lives on page 1 of the active
test lens (score 86, total=51). Verified live: pre-fix returns
LEAD_NOT_FOUND, post-fix resolves with full firmographics. New unit test
research-lead-by-name-fuzzy-pagination.test.ts pins the page-1 case.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ArtyETH06 ArtyETH06 self-assigned this Jun 11, 2026
@ArtyETH06

Copy link
Copy Markdown
Contributor Author

TEST PR from the mcp-analysis / eval skill

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant