Skip to content

Query fan-out: intent badges arrive minutes late (or never) on cold cache #431

Closed

Description

@gkhngyk

Problem

On the prompts page's Query Fan-out tab, the table renders quickly but the Intent column fills in much later — on a cold cache, minutes later, and since #428's 20s fetch abort, possibly not until a later visit.

Why (verified in code)

  1. POST /api/prompts/fanout-intents (https://github.com/ansvisor/ansvisor/blob/main/server/src/routes/prompts.js) classifies every cache-miss with the LLM before responding — concurrency 6, up to 200 queries per request. 120 cold queries ≈ 20 waves of LLM latency ≈ 40s+ for a single response.
  2. The client (web/src/app/[locale]/(dashboard)/dashboard/prompts/_fanout-tab.tsx) requests intents for all observed sub-queries in one call, not the 10 rows actually visible (PAGE_SIZE = 10) — the user waits on classifications for rows they may never scroll to.
  3. The initial paint deliberately stops waiting after 1.5s and lets the badges fill when the batch resolves — correct instinct, but the batch itself is the bottleneck.
  4. Since fix(fanout): complete aggregation, bounded fetches, real error messages #428, the action's 20s AbortSignal.timeout cuts the request off; the server keeps classifying and persists to fanout_query_intents, so intents appear only on a later visit. Better than a pinned function, but it turns "late" into "never (this session)".

Proposal

  • Client: chunked, page-first requests. Ask for the visible page's queries first (fast — mostly cache hits or ≤10 LLM calls), then classify the remainder in background chunks of ~20, merging each chunk into state as it resolves. Badges appear progressively instead of all-or-nothing. No server change strictly required.
  • Server (optional hardening): accept the smaller batches as-is; consider returning cached hits + pending: [...] for misses instead of blocking, so no request ever waits on LLM waves.

Acceptance criteria

  • Visible rows show intent badges within a few seconds on a warm cache, and within one LLM round-trip on a cold cache.
  • Remaining rows fill progressively; no single request blocks on classifying the entire observed set.
  • Works within the existing 20s fetch timeout (no request needs anywhere near it).

Activity

  1. added
    enhancement
    help wanted
    on Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions