-
Notifications
You must be signed in to change notification settings - Fork 11.4k
New cookbook: Context Engineering - Short-Term Memory Management with Sessions from OpenAI Agents SDK #2123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
A few recommendations:
|
Here, context refers to the total window of tokens (input + output) that the model can attend to at once. For GPT-5, this capacity is up to 272k input tokens and 128k output tokens but even such a large window can be overwhelmed by uncurated histories, redundant tool results, or noisy retrievals. This makes context management not just an optimization, but a necessity.
Before running the workflow, set your environment variables:
Alternatively, you can set your OpenAI API key for use by the agents via the
Real-World ScenarioWe’ll ground the techniques in a practical example for one of the common long-running tasks, such as:
Techniques CoveredTo address these challenges, we introduce two separate concrete approaches using OpenAI Agents SDK:
|
Sorry, this is very minor - just noted in session_memory.ipynb. --- the word 'independent' appears to be misspelled as 'indepentent' under the 'Techniques Covered' section. |
Summary
New cookbook: Context Engineering - Short-Term Memory Management with Sessions from OpenAI Agents SDK
This guide focuses on two proven context management techniques—trimming and compression—to keep agents fast, reliable, and cost-efficient.
Real-World Scenario
We’ll ground the techniques in a practical example for one of the common long-running tasks, such as:
In extended conversations about tech products—spanning both hardware and software—customers often surface multiple issues over time. The agent must stay consistent and goal-focused while retaining only the essentials rather than hauling along every past detail.
Techniques Covered
To address these challenges, we introduce two concrete approaches using OpenAI Agents SDK:
Motivation
This notebook is the first resource around agent memory. Many of our customers are asking about resources to solve agent memory challenges. This will be highly valuable asset for our customers who are building AI agents and working on context engineering.
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.