Fix session memory injection logic and prevent duplicate memory entries#2387
Fix session memory injection logic and prevent duplicate memory entries#2387panchaldhruv27223 wants to merge 3 commits intoopenai:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fa4943e5d9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Codex Review: Didn't find any major issues. Breezy! ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Summary
This PR fixes and simplifies session memory handling in the 'examples/agents_sdk/context_personalization.ipynb' notebook.
It addresses two related issues:
The changes ensure that session memory is injected consistently when available, and that identical session notes are updated instead of duplicated.
Motivation
In tool-heavy and iterative conversations, recent session context is often required across multiple turns, not only after a trim event. The previous trim-gated injection could lead to loss of short-term context in these cases.
Additionally, session memory notes were previously append-only, allowing identical notes to accumulate over time. This PR introduces a simple deduplication mechanism to keep session memory concise and up to date.
These changes improve:
Changes Included
No changes were made to global or long-term memory behavior.
Notes
For new content
When contributing new content, read through our contribution guidelines, and mark the following action items as completed:
We will rate each of these areas on a scale from 1 to 4, and will only accept contributions that score 3 or higher on all areas. Refer to our contribution guidelines for more details.