[BUG] Documentation search returns duplicate language variants without result-size controls

Open
#4,090 4 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 2 days

@alzimmermsft is already working on this.

Since Nov 2, 2026.

Assessment

This issue has not been assessed yet.

Description

needs-team-attention server-Azure.Mcp tools-Search

Describe the bug

microsoft_docs_search can return many duplicate language variants for the same canonical Microsoft Learn URL/section, and its schema provides no maxResults, canonical-URL deduplication, product-version filter, or general documentation language filter. This inflates tool output and drives additional search-result parsing and page-fetch calls in agent sessions.

This surfaced in microsoft/GitHub-Copilot-for-Azure skill-improvement run 40389600647:

  • Queue-trigger searches returned 10 chunks but only 3 distinct canonical URLs (7 duplicate rows). Seven results were language variants of the same #poison-messages section.
  • Cosmos DB searches returned 10 chunks with 7–9 distinct URLs.
  • Durable Functions searches returned 10 chunks with 9 distinct URLs.
  • Search/fetch responses frequently exceeded the host display limit, causing spill-to-file plus extra rg, view, or parsing calls.

There were no exact duplicate documentation calls within a trial; the duplication was in the search result set itself.

Expected behavior

Search and fetch results should provide the smallest relevant first-party evidence set needed to answer the query without forcing the agent to process equivalent variants or entire unrelated pages.

Search behavior
  • Deduplicate results by canonical URL plus fragment before returning them. Equivalent language variants of the same section should occupy one result unless the user requests a specific language or language comparison.
  • Add optional maxResults/top control with the current default retained for compatibility.
  • Add optional filters for documentation language and product/runtime version where those dimensions exist.
  • Rank results matching the requested service, trigger, and intent above similarly named but unrelated services. A Queue trigger query should not spend result slots on Blob poison-message pages unless they add unique relevant evidence.
  • Return distinct high-value pages rather than multiple excerpts from one canonical section when those excerpts are substantially equivalent.
Fetch behavior
  • When the URL includes a fragment, support returning the relevant anchored section rather than always returning the full page.
  • Add an optional maxTokens or maxChars response limit, with clear truncation metadata and a continuation mechanism if needed.
Acceptance criteria
  1. The reproduction query returns one canonical #poison-messages Queue trigger result rather than separate Java, JavaScript, C#, Python, PowerShell, TypeScript, and Go rows.
  2. Returned URLs are unique after canonicalization unless their excerpts contain materially different requested-language content.
  3. A caller can request fewer than 10 results.
  4. A caller can constrain language when language-specific documentation is relevant.
  5. Fetching an anchored page can return only that section within a caller-specified size budget.
  6. Tests cover canonical URL/fragment deduplication, language filtering, result limits, and unrelated-service ranking.

Observed prompt and search-query examples

These are exact evaluation prompts and microsoft_docs_search queries from run 40389600647.

Queue trigger poison messages

User prompt:

My Azure Function queue trigger keeps moving messages to the poison queue after 5 dequeue attempts. How do I diagnose why the messages are failing?

Search query:

Azure Functions Storage Queue trigger poison queue maxDequeueCount diagnose failed invocation Application Insights exceptions host.json visibilityTimeout

This returned 10 chunks but only 3 distinct canonical URLs. Seven chunks were language variants of the same Queue trigger #poison-messages section.

Cosmos DB trigger deserialization

User prompt:

My Cosmos DB trigger function is throwing deserialization errors because incoming documents are missing fields my POCO expects. Restarting the change feed from the beginning didn't help. How do I troubleshoot this?

Search queries from the two repetitions:

Azure Functions Cosmos DB trigger C# POCO deserialization missing fields JsonElement IReadOnlyList StartFromBeginning lease checkpoint
Azure Functions Cosmos DB trigger .NET POCO deserialization missing fields StartFromBeginning existing leases checkpoints JsonElement JObject raw JSON

Each returned 10 chunks, with only 7–9 distinct canonical URLs and several legacy or repeated page sections.

Durable Functions stuck orchestration

User prompt:

One of my Durable Functions orchestrations has been stuck in the Running status for hours and never completes. How do I diagnose whether this is a non-determinism issue or something else, and how should I add a safe timeout?

Search query:

Azure Durable Functions stuck Running diagnose non-determinism replay instance history Application Insights DurableTask timeout CreateTimer Task.WhenAny cancel timer

This returned 10 chunks with 9 distinct canonical URLs. The agent then used full-page fetches for diagnostics, durable timers, and orchestration constraints, increasing the number of turns and accumulated context.

Actual behavior

A Queue trigger poison-message query returned Java, JavaScript, C#, Python, PowerShell, TypeScript, and Go variants that all resolved to the same canonical functions-bindings-storage-queue-trigger#poison-messages URL, plus unrelated Blob poison-message results.

The command schema accepts only:

{ "query": "..." }

and always returns up to 10 chunks. The agent then has to parse a large result set and fetch pages separately.

Reproduction Steps

  1. Invoke microsoft_docs_search with:
Azure Functions Storage Queue trigger poison queue maxDequeueCount diagnose failed invocation Application Insights exceptions host.json visibilityTimeout
  1. Inspect the returned URLs.
  2. Observe multiple language-specific rows for the same canonical Queue trigger poison-message section and unrelated Blob trigger rows.

Environment

Dominant language
C#
Stars
3.9k
Forks
689
Avg merge
2d 11h
Merged PRs (30d)
143

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/mcp

All issues in microsoft/mcp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.