Python: Add TodoProvider and AgentModeProvider samples - #7309
Queued
westey-m wants to merge 2 commits into
Queued
Conversation
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
Contributor
There was a problem hiding this comment.
Pull request overview
Adds two new runnable Python samples to demonstrate the built-in harness context providers (TodoProvider and AgentModeProvider) in isolation, aligning the Python sample set with the analogous .NET samples and improving discoverability in the context-provider sample index.
Changes:
- Added a scripted
TodoProviderwalkthrough that shows todo state evolving across multiple turns. - Added an interactive
AgentModeProvidersample with a/modeslash command to view/switch modes (built-in and optional custom modes). - Updated the context-provider samples README to index both samples and document their prerequisites.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| python/samples/02-agents/context_providers/todo_provider.py | New scripted sample wiring TodoProvider into an agent and printing the persisted todo list after each turn. |
| python/samples/02-agents/context_providers/agent_mode_provider.py | New interactive sample wiring AgentModeProvider into an agent and allowing mode changes via /mode. |
| python/samples/02-agents/context_providers/README.md | Adds both samples to the index and documents sample-specific prerequisites/notes (including interactivity and optional custom modes). |
westey-m
marked this pull request as ready for review
July 24, 2026 17:21
- 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
eavanvalkenburg
approved these changes
Jul 27, 2026
westey-m
enabled auto-merge
July 27, 2026 11:07
giles17
approved these changes
Jul 27, 2026
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 & Context
The Agent Framework ships built-in context-provider harness building blocks —
TodoProviderand
AgentModeProvider— but the Python samples did not demonstrate them as standalone,runnable examples. This PR is the Python counterpart to the .NET samples added in #7262: it
gives users 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?
context_providers/todo_provider.py— a scripted, non-interactive walkthroughthat attaches a
TodoProviderto aFoundryChatClient-backed agent, runs a fixed sequenceof messages (plan a small team offsite, report progress, change the plan), and prints the
evolving todo list after each turn (read directly from the provider's store).
context_providers/agent_mode_provider.py— an interactive input loop thatattaches an
AgentModeProviderand switches mode via a/modeslash command, demonstratingboth the built-in
plan/executemodes and custom modes (AGENT_MODE_USE_CUSTOM=true)via
default_mode/mode_instructions, using theget_agent_mode/set_agent_modehelpers.
02-agents/context_providersREADME with their prerequisites.What is the impact of these changes?
samples pass
uv run poe syntax -Sanduv run poe pyright -S.What do you want reviewers to focus on?
agent_mode_provider.pyloop is easy to follow.Related Issue
Related to #6448. This PR contributes a subset of the samples requested there — the Python
counterpart to the .NET samples in #7262 — and, like that PR, should not close the issue,
which will require additional PRs.
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.