Skip to content

Python: Add FileMemoryProvider context provider sample - #7428

Merged
eavanvalkenburg merged 2 commits into
microsoft:mainfrom
westey-m:python-filememoryprovider-sample
Jul 30, 2026
Merged

Python: Add FileMemoryProvider context provider sample#7428
eavanvalkenburg merged 2 commits into
microsoft:mainfrom
westey-m:python-filememoryprovider-sample

Conversation

@westey-m

Copy link
Copy Markdown
Contributor

Motivation & Context

FileMemoryProvider gives an agent file-based memory through the file_memory_* tools, with each memory stored in an AgentFileStore.

Until now, Python did not have a focused sample showing how to attach the provider directly to an Agent, persist memories on disk, or configure a stable scope so memories can be recalled across independent sessions.

This adds the Python counterpart to the .NET sample in #7401, alongside the other context-provider samples.

Description & Review Guide

  • What are the major changes?
    • Add file_memory_provider.py, a Foundry-backed travel assistant using FileMemoryProvider over FileSystemAgentFileStore.
    • Demonstrate a stable per-user scope, one session that stores user preferences, the resulting files on disk, and a new session that recalls those preferences without shared chat history.
    • Document the sample and its prerequisites in the context-provider README.
  • What is the impact of these changes?
    • Samples-only and additive; no framework APIs or runtime behavior change.
  • What do you want reviewers to focus on?
    • Whether the stable per-user scope and two-session flow clearly explain the distinction between Python's default per-session isolation and explicit cross-session memory sharing.

Related Issue

Related to #6448.

Issue #6448 tracks several additional harness samples, so this PR contributes the Python FileMemoryProvider sample without closing the broader issue. PR #7401 is the complementary .NET sample; this PR adds the Python implementation under 02-agents/context_providers and demonstrates Python's scope API.

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 a language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI review requested due to automatic review settings July 30, 2026 09:43
@westey-m
westey-m temporarily deployed to github-app-auth July 30, 2026 09:43 — with GitHub Actions Inactive
@westey-m
westey-m temporarily deployed to github-app-auth July 30, 2026 09:43 — with GitHub Actions Inactive
@westey-m
westey-m temporarily deployed to github-app-auth July 30, 2026 09:43 — 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 30, 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 a focused Python sample demonstrating FileMemoryProvider + FileSystemAgentFileStore to persist “memory files” on disk and recall them across independent AgentSessions using a stable per-user scope, and documents it alongside the other context-provider samples.

Changes:

  • Add a new Foundry-backed sample (file_memory_provider.py) showing file-based memory persistence across two separate sessions via an explicit scope.
  • Update the context-provider samples README to include the new sample and list its prerequisites.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
python/samples/02-agents/context_providers/README.md Registers the new sample in the samples list and documents required env vars/auth.
python/samples/02-agents/context_providers/file_memory_provider.py New end-to-end sample wiring FileMemoryProvider over FileSystemAgentFileStore and demonstrating cross-session recall via stable scope.

Comment thread python/samples/02-agents/context_providers/file_memory_provider.py
Comment thread python/samples/02-agents/context_providers/file_memory_provider.py Outdated

@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: 4 | Confidence: 43% | Result: All clear

Reviewed: 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 30, 2026 09:55
@westey-m
westey-m temporarily deployed to github-app-auth July 30, 2026 09:55 — 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: 52% | Result: All clear

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


Automated review by westey-m's agents

@westey-m
westey-m temporarily deployed to github-app-auth July 30, 2026 10:38 — with GitHub Actions Inactive
@eavanvalkenburg
eavanvalkenburg added this pull request to the merge queue Jul 30, 2026
Merged via the queue into microsoft:main with commit 47c8e29 Jul 30, 2026
37 checks passed
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.

4 participants