.NET: Add TodoProvider and AgentModeProvider samples - #7262
Conversation
There was a problem hiding this comment.
Pull request overview
Adds two new .NET harness samples that demonstrate built-in AIContextProvider components (AgentModeProvider and TodoProvider), and wires these (plus previously unregistered Step20/21) into the repo’s sample verification and solution indexing so they’re easier to discover and validate.
Changes:
- Added
Agent_Step22_AgentMode(interactive) showing runtime mode switching via/modeand optional custom modes. - Added
Agent_Step23_TodoList(scripted) showing todo planning/progress tracking across turns and printing todos after each turn. - Registered Step20–23 in
verify-samples, and added Step22/23 to the solution + Agents README index.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/samples/02-agents/Agents/README.md | Adds Step22/23 to the Agents samples index table. |
| dotnet/samples/02-agents/Agents/Agent_Step23_TodoList/README.md | Documents the TodoProvider sample and how to run it. |
| dotnet/samples/02-agents/Agents/Agent_Step23_TodoList/Program.cs | Scripted TodoProvider walkthrough; prints evolving todo list across turns. |
| dotnet/samples/02-agents/Agents/Agent_Step23_TodoList/Agent_Step23_TodoList.csproj | New sample project targeting net10.0 and referencing Foundry + Azure.Identity. |
| dotnet/samples/02-agents/Agents/Agent_Step22_AgentMode/README.md | Documents the AgentModeProvider sample, commands, and custom-mode toggle. |
| dotnet/samples/02-agents/Agents/Agent_Step22_AgentMode/Program.cs | Interactive loop demonstrating mode_get/mode_set behavior and /mode command handling. |
| dotnet/samples/02-agents/Agents/Agent_Step22_AgentMode/Agent_Step22_AgentMode.csproj | New sample project targeting net10.0 and referencing Foundry + Azure.Identity. |
| dotnet/eng/verify-samples/AgentsSamples.cs | Registers Step20/21/23 for verification and marks Step22 as skipped (interactive). |
| dotnet/agent-framework-dotnet.slnx | Adds the new Step22/23 sample projects to the solution. |
… input Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Automated Code Review
Reviewers: 5 | Confidence: 93%
✓ Correctness
The PR adds two well-structured samples (AgentModeProvider and TodoProvider) and registers four samples in the verify-samples tool. All API usage is verified correct against source definitions: constructors, method signatures, return types, IDisposable patterns, and exception handling all match. The previously flaged issues (input trimming and missing Step21 in README) are both resolved in the current diff. No correctness bugs found.
✓ Security Reliability
The PR adds two new .NET samples (AgentMode and TodoList) and registers four samples in verify-samples. From a security and reliability perspective, the code is clean: disposable resources (AgentModeProvider, TodoProvider) are properly managed with using declarations, user input is trimed and validated with case-insensitive comparisons, invalid mode names are caught via ArgumentException, and DefaultAzureCredential usage includes appropriate production-use warnings. No secrets, injection risks, unsafe deserialization, or resource leaks were found.
✓ Test Coverage
This PR adds two new samples and registers four samples (including two previously unregistered) in the verify-samples infrastructure. From a test-coverage perspective, both TodoProvider and AgentModeProvider already have comprehensive unit test suites (804 and 665 lines respectively). The MustContain patterns in the sample definitions correctly target deterministic output strings printed by the sample code itself (not LM output), while ExpectedOutputDescription handles non-deterministic LLM behavior via AI verification. The one notable gap is that Agent_Step22_AgentMode is fully skipped with a SkipReason despite the verify-samples infrastructure supporting interactive sample automation via the Inputs property — a pattern used by other interactive samples in the repo.
✓ Failure Modes
This PR adds two new sample programs (AgentMode and TodoList) and registers them plus two existing samples in the verify-samples tool. All API types and methods exist and are used correctly. AgentResponse.ToString() returns the text content, so Console.WriteLine works as intended. Both providers implement IDisposable and are properly disposed via using declarations. The MustContain strings in the verify-samples registrations are all printed deterministically by sample code (not LLM output), making verification robust. The interactive Step22 sample is correctly marked with a SkipReason. The ArgumentException catch in Step22's /mode handler correctly surfaces the error message rather than swallowing it. No silent failures, lost errors, disposal gaps, or other concrete failure modes were identified.
✗ Design Approach
The new samples are wired consistently with the provider APIs, but the AgentMode sample is integrated into
verify-samplesin a way that skips it entirely even though the sample and verifier already support scripted interactive runs. That leaves one of the two new sample flows without automated coverage.
Flagged Issues
-
dotnet/eng/verify-samples/AgentsSamples.cs:382skipsAgent_Step22_AgentModewith a SkipReason claiming it 'does not exit on its own', butProgram.cs:96-104exits on/exitor blank input, and the verifier already supports stdin-driven samples via theInputsproperty (SampleRunner.cs:34-45,81-99;VerificationOrchestrator.cs:141-143). Existing interactive samples likeAgent_Step01_UsingFunctionToolsWithAprovalsuseInputsinstead ofSkipReason(AgentsSamples.cs:82-89). Keeping this as skipped means the new sample never gets exercised in CI.
Automated review by westey-m's agents
|
Flagged issue
Source: automated DevFlow PR review |
Reflects mode changes the agent makes itself via the mode_set tool. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Python: Add TodoProvider and AgentModeProvider context provider samples Add two Python samples under samples/02-agents/context_providers/ mirroring the .NET samples from microsoft#7262: - todo_provider.py: scripted walkthrough of TodoProvider that plans multi-step work and prints the evolving todo list after each turn. - agent_mode_provider.py: interactive loop using AgentModeProvider with a /mode slash command, demonstrating built-in plan/execute and custom modes. Also index both samples in the context_providers README. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8725831c-086b-475f-90e6-cdba41d59c33 * Python: Address review comments on AgentModeProvider sample - Replace the AGENT_MODE_USE_CUSTOM env var with an in-file USE_CUSTOM_MODES constant for choosing between built-in and custom modes. - Use plain input() in the interactive loop instead of asyncio.to_thread. - Update the README prerequisites to reference the in-file toggle. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8725831c-086b-475f-90e6-cdba41d59c33 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8725831c-086b-475f-90e6-cdba41d59c33
Motivation & Context
The Agent Framework ships built-in
AIContextProvidercomponents —TodoProviderandAgentModeProvider— but the .NET samples did not demonstrate them. These samples give usersrunnable, self-contained examples of tracking multi-step work with a todo list and driving
different agent behavior via operating modes, contributing to the broader effort to showcase the
harness building blocks.
Description & Review Guide
What are the major changes?
Agent_Step23_TodoList— a scripted, non-interactive walkthrough that wires aTodoProvideronto a Foundry agent and prints the evolving todo list after each turn.Agent_Step22_AgentMode— creates an agent with anAgentModeProviderand runs aninteractive input loop that switches mode via a
/modeslash command, demonstrating both thebuilt-in
plan/executemodes and custom modes viaAgentModeProviderOptions.Agent_Step20_DynamicFunctionToolsandAgent_Step21_ShellWithEnvironmentin theverify-samplestool (Step22 is marked skipped as itis interactive).
02-agents/AgentsREADME.What is the impact of these changes?
changes. New sample projects build cleanly.
What do you want reviewers to focus on?
verify-samplesexpectations are robust tonon-deterministic LLM output.
Related Issue
Related to #6448. This PR contributes a subset of the samples requested there; the issue will
require additional PRs and should not be closed by this one.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.