Skip to content

Python: Simplify Python memory sample to use session state - #4085

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
eavanvalkenburg:docs/update-memory-sample
Feb 19, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
eavanvalkenburg:docs/update-memory-sample

Conversation

@eavanvalkenburg

Copy link
Copy Markdown
Member

Simplifies the 04_memory.py get-started sample:

  • Rename UserNameProvider → UserMemoryProvider for clarity
  • Use session state (state dict) instead of instance variables for persistence
  • Use context.extend_instructions() instead of context.instructions.append()
  • Use DEFAULT_SOURCE_ID class attribute (proper pattern)
  • Fix imports to use public agent_framework API
  • Add session state inspection at end of sample

This aligns the sample with the updated docs in MicrosoftDocs/semantic-kernel-pr#880.

- Rename UserNameProvider → UserMemoryProvider
- Use session state (state dict) instead of instance variables
- Use context.extend_instructions() instead of context.instructions.append()
- Use DEFAULT_SOURCE_ID class attribute
- Fix imports to use public agent_framework API
- Add session state inspection at end of sample

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings February 19, 2026 14:14
@eavanvalkenburg Eduard van Valkenburg (eavanvalkenburg) added the python Usage: [Issues, PRs], Target: Python label Feb 19, 2026
@github-actions github-actions Bot changed the title Simplify Python memory sample to use session state Python: Simplify Python memory sample to use session state Feb 19, 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

Updates the Python getting-started memory sample (04_memory.py) to demonstrate persisting user info via AgentSession.state using a context provider, aligning the sample with newer session-state guidance.

Changes:

  • Switches imports to the public agent_framework API surface.
  • Reworks the provider to store/read the user name from provider-scoped session state and uses SessionContext.extend_instructions().
  • Adds a final print showing how to inspect stored provider state from the session.

Merged via the queue into microsoft:main with commit f93ceae Feb 19, 2026
31 checks passed
@eavanvalkenburg
Eduard van Valkenburg (eavanvalkenburg) deleted the docs/update-memory-sample branch June 30, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants