Skip to content

[Bug] WebSearch tool chip in Web UI displays raw line count as search result count (e.g. "94 结果" instead of 8 results) #4167

Description

@nothankyouzzz

Description

When running a WebSearch tool call in the Web/Desktop UI, the summary chip on the tool execution card displays the total number of lines in the formatted output instead of the actual number of search results returned. For example, a search returning 8 items formatted across 94 text lines displays as 🔍 搜索 ... 94 结果 instead of 8 结果.

Steps to Reproduce

  1. In a chat session (Web/Desktop UI), trigger a WebSearch tool call (e.g. searching Hono web framework 2026 features).
  2. The search backend returns 8 search results.
  3. Observe the tool header chip in the transcript card.

Observed Behavior

The chip displays 94 结果 (or 94 results), reflecting the total count of text lines in the formatted output.

Expected Behavior

The chip should display the actual number of returned search results (e.g. 8 结果 / 8 results).

Root Cause Analysis

In the Web UI's tool chip renderer (dist-web):

case "grep":
case "search":
  return t.output && t.output.length > 0 
    ? e("tools.chip.results", { count: t.output.length }) 
    : "";

Here, t.output is an array of strings representing the output lines split by \n. Because WebSearchTool in packages/agent-core-v2 formats each search result as a multi-line block (Title, Site, Date, URL, Snippet, blank lines, and --- dividers), t.output.length equals the total line count (94 lines in this case) rather than the count of search result items.

Suggested Fix

  1. Provide structured metadata (e.g., result_count: number) on the tool result payload so the UI does not have to guess from line count; OR
  2. In the frontend chip renderer, count distinct items (e.g., counting Title: occurrences or separator dividers) rather than raw t.output.length.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions