.NET: Add Hosted-AgentSkills sample with Foundry Skills integration#6013
Open
rogerbarreto wants to merge 6 commits into
Open
Conversation
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>
Contributor
There was a problem hiding this comment.
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-AgentSkillssample: provisions (optional), downloads, extracts, and wires Foundry skills into a hosted Responses agent. - Adds unit tests for ZIP extraction + skill name validation +
AgentSkillsProviderbehavior, and introduces an integration-test scenario/fixture for agent skills. - Updates commented-out
PackageReferenceversions 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>
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
AgentSkillsProviderand the progressive disclosure pattern.Description
New sample:
Hosted-AgentSkillsunderdotnet/samples/04-hosting/FoundryHostedAgents/responses/The agent:
SKILL.mdfiles from Foundry viaProjectAgentSkills.DownloadSkillAsync(fromAzure.AI.Projects.AgentsSDK)downloaded_skills/<name>/AgentSkillsProvideras anAIContextProvider(progressive disclosure: advertise → load on demand)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 ofAzure.AI.Projects2.1.0-beta.2) already hasProjectAgentSkillswith full skills CRUD — no raw REST needed.Tests:
agent-skills) with fixture and 4 testsscripts/smoke.ps1)Also: Updated commented-out
PackageReferenceversions from1.0.0to latest NuGet across all 13 hosted samples.Contribution Checklist