7b6d257988
* Python: Add TodoProvider and AgentModeProvider context provider samples Add two Python samples under samples/02-agents/context_providers/ mirroring the .NET samples from #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
Context Provider Samples
These samples demonstrate how to use context providers to enrich agent conversations with external knowledge — from custom logic to Azure AI Search (RAG) and memory services.
Samples
| File / Folder | Description |
|---|---|
simple_context_provider.py |
Implement a custom context provider by extending ContextProvider to extract and inject structured user information across turns. |
todo_provider.py |
Use the built-in TodoProvider to give an agent todo-list tools. A scripted walkthrough that plans multi-step work and prints the evolving todo list after each turn. |
agent_mode_provider.py |
Use the built-in AgentModeProvider to track and switch an agent's operating mode at runtime. An interactive loop with a /mode slash command demonstrating the built-in plan/execute modes and custom modes. |
cross_session_observer.py |
Detect injected context messages whose origins differ from the current session, via the Message.additional_properties["_attribution"]["origin_session_ids"] field. Self-contained — no LLM credentials required. |
azure_ai_foundry_memory.py |
Use FoundryMemoryProvider to add semantic memory — automatically retrieves, searches, and stores memories via Microsoft Foundry. |
file_access_data_processing/ |
Use FileAccessProvider with FileSystemAgentFileStore to give an agent read/write/search access to a folder of CSV data files. See its own README. |
azure_ai_search/ |
Retrieval Augmented Generation (RAG) with Azure AI Search in semantic and agentic modes. See its own README. |
azure_content_understanding/ |
Analyze documents, images, audio, and video with Azure Content Understanding and inject the extracted content into agent context. |
mem0/ |
Memory-powered context using the Mem0 integration (open-source and managed). See its own README. |
redis/ |
Redis-backed context providers for conversation memory and sessions. See its own README. |
Prerequisites
For cross_session_observer.py:
- No external dependencies; runs against in-memory
SessionContext.
For simple_context_provider.py:
FOUNDRY_PROJECT_ENDPOINT: Your Microsoft Foundry project endpointFOUNDRY_MODEL: Model deployment name- Azure CLI authentication (
az login)
For todo_provider.py:
FOUNDRY_PROJECT_ENDPOINT: Your Microsoft Foundry project endpointFOUNDRY_MODEL: Model deployment name- Azure CLI authentication (
az login)
For agent_mode_provider.py:
FOUNDRY_PROJECT_ENDPOINT: Your Microsoft Foundry project endpointFOUNDRY_MODEL: Model deployment name- Azure CLI authentication (
az login) - To try the custom
concise/detailedmodes instead of the built-inplan/executemodes, set the in-fileUSE_CUSTOM_MODESconstant toTrue. - This sample is interactive: it reads commands from the console in a loop (type
/exitto quit).
For azure_ai_foundry_memory.py:
FOUNDRY_PROJECT_ENDPOINT: Your Microsoft Foundry project endpointFOUNDRY_MODEL: Chat/responses model deployment nameAZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME: Embedding model deployment name (e.g.,text-embedding-ada-002)- Azure CLI authentication (
az login)
For file_access_data_processing/:
FOUNDRY_PROJECT_ENDPOINT: Your Microsoft Foundry project endpointFOUNDRY_MODEL: Chat model deployment name- Azure CLI authentication (
az login)
See each subfolder's README for provider-specific prerequisites.