Files
c79f886dc3 .NET: Align Foundry sample environment variables and credentials. (#6422)
* dotnet: refresh Foundry sample guidance

Carry forward the still-relevant sample guidance and Foundry-specific documentation fixes from the old stacked sample migration work, adapted to the current repo layout and policy.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* dotnet: rename Foundry sample env vars

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* dotnet: remove persistent provider sample

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* dotnet: drop SAMPLE_GUIDELINES.md from this PR

Defer the guidelines doc and its cross-link to a follow-on PR to avoid broken-link failures in CI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* dotnet: add DefaultAzureCredential warning to remaining samples

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* dotnet: address PR review feedback

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-11 17:26:00 +00:00
..

Harness Step 02 — BackgroundAgents (Stock Price Research)

This sample demonstrates how to use the BackgroundAgentsProvider to delegate work from a parent agent to background agents. Both agents use HarnessAgent for pre-configured function invocation, per-service-call persistence, and context-window compaction.

What It Does

A parent agent receives a list of stock tickers and uses a web-search background agent to find the closing price for each ticker on December 31, 2025. The background tasks run concurrently, and results are presented in a summary table.

Architecture

┌────────────────────────────────────────┐
│     StockPriceResearcher               │
│         (Parent Agent)                 │
│                                        │
│  BackgroundAgentsProvider              │
│    ├─ BackgroundAgents_StartTask       │
│    ├─ BackgroundAgents_WaitFor...      │
│    ├─ BackgroundAgents_GetTaskResults  │
│    └─ ...                              │
└────────────┬───────────────────────────┘
             │  delegates to
             ▼
┌─────────────────────────────────┐
│       WebSearchAgent            │
│        (Sub-Agent)              │
│                                 │
│  Tools:                         │
│    └─ web_search (Foundry)      │
└─────────────────────────────────┘

Prerequisites

  • An Azure AI Foundry endpoint with an OpenAI model deployment
  • Set the following environment variables:
    • AZURE_FOUNDRY_OPENAI_ENDPOINT — Your Foundry OpenAI endpoint URL
    • FOUNDRY_MODEL — Model deployment name (defaults to gpt-5.4)

Running the Sample

cd dotnet/samples/02-agents/Harness/Harness_Step02_Research_WithBackgroundAgents
dotnet run

When prompted, enter a list of stock tickers such as:

BAC, MSFT, BA

The parent agent will delegate each ticker lookup to the web search background agent concurrently and present the results in a table.