Skip to content

Python: Add TodoProvider and AgentModeProvider samples#7309

Open
westey-m wants to merge 2 commits into
microsoft:mainfrom
westey-m:python-mode-todo-samples
Open

Python: Add TodoProvider and AgentModeProvider samples#7309
westey-m wants to merge 2 commits into
microsoft:mainfrom
westey-m:python-mode-todo-samples

Conversation

@westey-m

Copy link
Copy Markdown
Contributor

Motivation & Context

The Agent Framework ships built-in context-provider harness building blocks — TodoProvider
and 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?

    • New sample context_providers/todo_provider.py — a scripted, non-interactive walkthrough
      that attaches a TodoProvider to a FoundryChatClient-backed agent, runs a fixed sequence
      of 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).
    • New sample context_providers/agent_mode_provider.py — an interactive input loop that
      attaches an AgentModeProvider and switches mode via a /mode slash command, demonstrating
      both the built-in plan/execute modes and custom modes (AGENT_MODE_USE_CUSTOM=true)
      via default_mode / mode_instructions, using the get_agent_mode / set_agent_mode
      helpers.
    • Indexed both samples in the 02-agents/context_providers README with their prerequisites.
  • What is the impact of these changes?

    • Samples-only changes; no changes to shipped library code and no breaking changes. Both
      samples pass uv run poe syntax -S and uv run poe pyright -S.
  • What do you want reviewers to focus on?

    • Whether the sample flows read clearly and idiomatically, and whether the interactive
      agent_mode_provider.py loop 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

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

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
Copilot AI review requested due to automatic review settings July 24, 2026 17:09
@westey-m
westey-m temporarily deployed to github-app-auth July 24, 2026 17:09 — with GitHub Actions Inactive
@westey-m
westey-m temporarily deployed to github-app-auth July 24, 2026 17:09 — with GitHub Actions Inactive
@westey-m
westey-m temporarily deployed to github-app-auth July 24, 2026 17:09 — with GitHub Actions Inactive
@agent-framework-automation agent-framework-automation Bot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python labels Jul 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 TodoProvider walkthrough that shows todo state evolving across multiple turns.
  • Added an interactive AgentModeProvider sample with a /mode slash 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).

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 5 | Confidence: 93% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Failure Modes, Design Approach


Automated review by westey-m's agents

@westey-m
westey-m marked this pull request as ready for review July 24, 2026 17:21
@westey-m
westey-m temporarily deployed to github-app-auth July 24, 2026 17:21 — with GitHub Actions Inactive

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 5 | Confidence: 94% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Failure Modes, Design Approach


Automated review by westey-m's agents

Comment thread python/samples/02-agents/context_providers/agent_mode_provider.py Outdated
Comment thread python/samples/02-agents/context_providers/agent_mode_provider.py Outdated
- 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
@westey-m
westey-m temporarily deployed to github-app-auth July 27, 2026 10:42 — with GitHub Actions Inactive
@westey-m
westey-m enabled auto-merge July 27, 2026 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants