Skip to content

.NET: Add Hosted-AgentSkills sample with Foundry Skills integration#6013

Open
rogerbarreto wants to merge 6 commits into
microsoft:mainfrom
rogerbarreto:issues/5776-net-hosted-agents-sample-agent-skills-support
Open

.NET: Add Hosted-AgentSkills sample with Foundry Skills integration#6013
rogerbarreto wants to merge 6 commits into
microsoft:mainfrom
rogerbarreto:issues/5776-net-hosted-agents-sample-agent-skills-support

Conversation

@rogerbarreto
Copy link
Copy Markdown
Member

Motivation and Context

Closes #5776 — .NET Hosted Agents Sample - Agent Skills Support.

Mirrors the Python Foundry Skills sample (PR #5822) for .NET, demonstrating how to load behavioral guidelines from Foundry Skills at startup using AgentSkillsProvider and the progressive disclosure pattern.

Description

New sample: Hosted-AgentSkills under dotnet/samples/04-hosting/FoundryHostedAgents/responses/

The agent:

  1. Downloads SKILL.md files from Foundry via ProjectAgentSkills.DownloadSkillAsync (from Azure.AI.Projects.Agents SDK)
  2. Extracts ZIP archives with zip-slip protection into downloaded_skills/<name>/
  3. Wires them into AgentSkillsProvider as an AIContextProvider (progressive disclosure: advertise → load on demand)
  4. Hosts via the Responses protocol (AddFoundryResponses / MapFoundryResponses)

Ships two Contoso Outdoors skills matching the Python sample:

  • support-style — tone, formatting, signature guidelines (canary: STYLE-CANARY-3318)
  • escalation-policy — when and how to escalate tickets (canary: ESC-CANARY-7742)

Key discovery: Azure.AI.Projects.Agents (transitive dep of Azure.AI.Projects 2.1.0-beta.2) already has ProjectAgentSkills with full skills CRUD — no raw REST needed.

Tests:

  • 14 unit tests (ZIP extraction, skill name validation, AgentSkillsProvider integration) — all passing
  • Container integration test scenario (agent-skills) with fixture and 4 tests
  • Local smoke test (scripts/smoke.ps1)

Also: Updated commented-out PackageReference versions from 1.0.0 to latest NuGet across all 13 hosted samples.

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? No.

rogerbarreto and others added 4 commits May 21, 2026 16:05
Add a new hosted agent sample that demonstrates how to load behavioral
guidelines from Foundry Skills at startup using AgentSkillsProvider and
the progressive disclosure pattern (advertise -> load on demand).

The sample:
- Downloads SKILL.md files from Foundry via ProjectAgentSkills SDK
- Extracts ZIP archives with zip-slip protection
- Wires skills into AgentSkillsProvider as an AIContextProvider
- Hosts the agent via the Responses protocol

Ships two Contoso Outdoors skills matching the Python sample (PR microsoft#5822):
- support-style: tone, formatting, signature guidelines
- escalation-policy: when and how to escalate tickets

Includes convenience provisioning gated behind PROVISION_SAMPLE_SKILLS
env var, clearly documented as NOT a production pattern.

Closes microsoft#5776

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Unit tests (14 tests, all passing):
- ZIP extraction with zip-slip guard (valid archive, traversal attack,
  sibling-prefix attack, directory entries)
- Skill name validation (rejects dots, separators, traversal patterns)
- AgentSkillsProvider with downloaded skills (advertises both skills,
  load_skill returns canary tokens, unknown skill returns error)

Container integration test:
- New 'agent-skills' scenario in the test container that creates
  Contoso Outdoors skills on disk and wires AgentSkillsProvider
- AgentSkillsHostedAgentFixture + 4 integration tests verifying:
  - Routine questions load support-style skill (STYLE-CANARY-3318)
  - Escalation triggers load escalation-policy (ESC-CANARY-7742)
  - Skills are advertised in system prompt
  - load_skill tool is invoked via FunctionCallContent

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add scripts/smoke.ps1 for local Docker smoke testing: builds the
  contributor image, runs the container, verifies both skills are loaded
  via canary tokens (STYLE-CANARY-3318, ESC-CANARY-7742)
- Add 'agent-skills' to the bootstrap script scenario list
- Add agent-skills row to the integration test README scenarios table
- Exclude HostedAgentSkillsPatternTests from net472 (uses net8.0+ APIs)

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

Update the end-user PackageReference versions (in the commented-out
sections) from 1.0.0 to the current latest NuGet versions:

- Microsoft.Agents.AI: 1.6.1
- Microsoft.Agents.AI.Foundry: 1.6.1-preview.260514.1
- Microsoft.Agents.AI.Foundry.Hosting: 1.6.1-preview.260514.1
- Microsoft.Agents.AI.Hosting: 1.6.1-preview.260514.1
- Microsoft.Agents.AI.OpenAI: 1.6.1
- Microsoft.Agents.AI.Workflows: 1.6.1

Also adds explicit versions to Hosted-Workflow-Handoff which had bare
PackageReference entries without Version attributes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 21, 2026 17:04
@moonbox3 moonbox3 added documentation Improvements or additions to documentation .NET labels May 21, 2026
Copy link
Copy Markdown
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 hosted agent sample demonstrating Foundry Skills integration and the progressive disclosure pattern via AgentSkillsProvider, plus accompanying unit/integration-test scaffolding and sample dependency-version comment updates.

Changes:

  • New Hosted-AgentSkills sample: provisions (optional), downloads, extracts, and wires Foundry skills into a hosted Responses agent.
  • Adds unit tests for ZIP extraction + skill name validation + AgentSkillsProvider behavior, and introduces an integration-test scenario/fixture for agent skills.
  • Updates commented-out PackageReference versions across multiple existing hosted samples and registers the new sample in the .NET solution.

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
dotnet/tests/Microsoft.Agents.AI.UnitTests/Microsoft.Agents.AI.UnitTests.csproj Excludes the new AgentSkills unit test from legacy TFMs.
dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/HostedAgentSkillsPatternTests.cs Adds unit tests covering ZIP extraction guardrails and provider behavior.
dotnet/tests/Foundry.Hosting.IntegrationTests/scripts/it-bootstrap-agents.ps1 Adds agent-skills to the integration test scenario bootstrap list.
dotnet/tests/Foundry.Hosting.IntegrationTests/README.md Documents the new agent-skills integration scenario/fixture.
dotnet/tests/Foundry.Hosting.IntegrationTests/Fixtures/AgentSkillsHostedAgentFixture.cs Adds fixture for the agent-skills hosted-agent integration scenario.
dotnet/tests/Foundry.Hosting.IntegrationTests/AgentSkillsHostedAgentTests.cs Adds integration tests for skills advertisement/loading (currently skipped like other placeholder ITs).
dotnet/tests/Foundry.Hosting.IntegrationTests.TestContainer/Program.cs Adds an agent-skills scenario wiring AgentSkillsProvider over on-disk skills.
dotnet/tests/Foundry.Hosting.IntegrationTests.TestContainer/Foundry.Hosting.IntegrationTests.TestContainer.csproj Adds references needed by the new skills scenario in the test container.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Workflow-Simple/HostedWorkflowSimple.csproj Updates commented-out end-user package versions.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Workflow-Handoff/HostedWorkflowHandoff.csproj Updates commented-out end-user package versions.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/HostedToolbox.csproj Updates commented-out end-user package versions.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-TextRag/HostedTextRag.csproj Updates commented-out end-user package versions.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Observability/HostedObservability.csproj Updates commented-out end-user package versions.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-MemoryAgent/HostedMemoryAgent.csproj Updates commented-out end-user package versions.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-McpTools/HostedMcpTools.csproj Updates commented-out end-user package versions.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-LocalTools/HostedLocalTools.csproj Updates commented-out end-user package versions.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-FoundryAgent/HostedFoundryAgent.csproj Updates commented-out end-user package versions.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Files/HostedFiles.csproj Updates commented-out end-user package versions.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ChatClientAgent/HostedChatClientAgent.csproj Updates commented-out end-user package versions.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AzureSearchRag/HostedAzureSearchRag.csproj Updates commented-out end-user package versions.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AgentSkills/skills/support-style/SKILL.md Adds the sample “support-style” skill content.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AgentSkills/skills/escalation-policy/SKILL.md Adds the sample “escalation-policy” skill content.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AgentSkills/scripts/smoke.ps1 Adds a local smoke-test script for the new sample.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AgentSkills/README.md Documents sample behavior, setup, and expected canary tokens.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AgentSkills/Program.cs Implements the sample: skill provisioning (optional), download, ZIP extraction, and hosting via Responses.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AgentSkills/HostedAgentSkills.csproj Adds the new sample project and publish-time inclusion of skills/.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AgentSkills/Dockerfile.contributor Adds contributor-focused Docker packaging instructions (pre-publish + copy output).
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AgentSkills/Dockerfile Adds end-user Dockerfile (restore/publish in-container).
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AgentSkills/agent.yaml Adds agent definition for Foundry deployment.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AgentSkills/agent.manifest.yaml Adds agent manifest with parameters and model resource mapping.
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AgentSkills/.env.example Adds example environment configuration for local runs.
dotnet/agent-framework-dotnet.slnx Registers the new Hosted-AgentSkills sample in the solution.

Remove references to non-existent ../../README.md. Replace with
inline instructions matching other hosted samples that don't have
a parent README.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use Ordinal on Unix (case-sensitive FS) and OrdinalIgnoreCase on
Windows to prevent case-based path bypass on Linux containers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rogerbarreto
Copy link
Copy Markdown
Member Author

Re: zip-slip OrdinalIgnoreCase on case-sensitive FS (both comments)

Fixed in 6a22579 — now uses \OperatingSystem.IsWindows()\ to select \Ordinal\ on Unix vs \OrdinalIgnoreCase\ on Windows. Containers run Linux -> case-sensitive check applied. Same fix in test helper.

@rogerbarreto rogerbarreto self-assigned this May 21, 2026
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.

.NET Hosted Agents Sample - Agent Skills Support

3 participants