Skip to content

WebSearchResult

NexusLabs.Needlr.Copilot

WebSearchResult Class

The structured result of a Copilot web search, including the answer text, source citations, and the search queries that were performed.

public sealed class WebSearchResult

Inheritance System.Object 🡒 WebSearchResult

Example

var tools = CopilotToolSet.Create(opts => opts.EnableWebSearch = true);
var webSearch = tools[0];
var result = await webSearch.InvokeAsync(new AIFunctionArguments(
    new Dictionary<string, object?> { ["query"] = "latest .NET version" }));

if (result is WebSearchResult searchResult)
{
    Console.WriteLine(searchResult.Text);
    foreach (var citation in searchResult.Citations)
    {
        Console.WriteLine($"  [{citation.Title}]({citation.Url})");
    }
}

Remarks

ToString() returns Text so that existing agent tool flows (which stringify tool results) continue to work unchanged.

Host code that needs citation or search query metadata can inspect Citations and SearchQueries directly.

Properties

WebSearchResult.Citations Property

Source citations extracted from the search result. Each citation maps a character span in Text to a source URL. Empty when the API did not return any annotations.

public System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.Copilot.WebSearchCitation> Citations { get; }

Property Value

System.Collections.Generic.IReadOnlyList<WebSearchCitation>

WebSearchResult.SearchQueries Property

The Bing search queries that the Copilot web search tool performed while generating the answer. Empty when no web searches were triggered.

public System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.Copilot.WebSearchQuery> SearchQueries { get; }

Property Value

System.Collections.Generic.IReadOnlyList<WebSearchQuery>

WebSearchResult.Text Property

The answer text generated by the web search. May contain 【3:N†source】 citation markers whose positions are described by Citations.

public string Text { get; }

Property Value

System.String

Methods

WebSearchResult.ToString() Method

Returns Text so that agent tool flows that stringify results continue to receive the answer content.

public override string ToString();

Returns

System.String