Skip to content

.NET: Add Foundry Agents Tool Sample - Web Search#4040

Open
rogerbarreto wants to merge 4 commits intomicrosoft:mainfrom
rogerbarreto:feature/3674-web-search
Open

.NET: Add Foundry Agents Tool Sample - Web Search#4040
rogerbarreto wants to merge 4 commits intomicrosoft:mainfrom
rogerbarreto:feature/3674-web-search

Conversation

@rogerbarreto
Copy link
Member

Motivation and Context

Adds a new FoundryAgents_Step25_WebSearch sample demonstrating how to use the Responses API built-in web search tool with AI Agents.

Description

  • Create agents with web search capabilities using two approaches:
    • Option 1: HostedWebSearchTool (MEAI + AgentFramework abstraction)
    • Option 2: ResponseTool.CreateWebSearchTool() (Native SDK / Responses API)
  • Extract text responses and URL citations from agent responses
  • Manage agent lifecycle (create and cleanup)

Note: The web search tool uses the built-in Responses API web search capability. No Bing Grounding connection is required.

Changes

  • New sample: FoundryAgents_Step25_WebSearch with Program.cs and README.md

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

rogerbarreto and others added 2 commits February 5, 2026 14:31
Remove incorrect Bing Grounding connection ID requirement from the
WebSearch sample. The web search tool uses the OpenAI Responses API
built-in capability and does not need a connection ID.

- Remove AZURE_FOUNDRY_BING_CONNECTION_ID env var requirement
- Use HostedWebSearchTool() without connectionId properties
- Refactor creation options into local functions (MEAI + NativeSDK)
- Switch from AzureCliCredential to DefaultAzureCredential
- Update README to reflect correct prerequisites

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 18, 2026 17:28
@rogerbarreto rogerbarreto added documentation Improvements or additions to documentation .NET labels Feb 18, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new .NET GettingStarted FoundryAgents_Step25_WebSearch sample demonstrating how to enable the Responses API built-in web search tool on Foundry Agents, run a query, and extract text + URL citation annotations.

Changes:

  • New console sample project (net10.0) that creates a Foundry agent with web search tooling (MEAI hosted tool, with a native SDK option shown).
  • Adds output processing to print text responses and URL citation annotations.
  • Adds a README with prerequisites and run instructions for the new step.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step25_WebSearch/README.md Documents purpose, prerequisites, env vars, and execution steps for the web search sample.
dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step25_WebSearch/Program.cs Implements agent creation (web search enabled), execution, citation extraction, and cleanup.
dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step25_WebSearch/FoundryAgents_Step25_WebSearch.csproj New sample project definition and dependencies.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Contributor

@westey-m westey-m Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be added to the solution and the sample should be added to the parent folder readme.

Comment on lines +30 to +39
foreach (ChatMessage message in response.Messages)
{
foreach (AIContent content in message.Contents)
{
if (content is TextContent textContent)
{
Console.WriteLine($"Response: {textContent.Text}");
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should jut be Console.WriteLine($"Response: {response.Text}")

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

Labels

documentation Improvements or additions to documentation .NET

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments