Building GPT-6 Astra’s Memory Pattern From Scratch
Go from context windows to memory that lasts. Explore compaction, context offloading, and durable notes, then build the patterns in Python from scratch.
Take the learning with you
Get the presentation.
Keep the architecture diagrams and memory patterns close while you build. Explore the webinar’s slides and supporting material on OpenSpeech.
Open in OpenSpeech Public presentation · Opens in a new tabThe big picture
From a full context window to lasting memory.
What happens when an AI agent runs out of context? Summarising the conversation makes room, but useful details can disappear. In this webinar, Richmond Alake explores a different pattern: keep durable notes, archive previous context windows, and retrieve the original information when it is needed.
Starting with the publicly described memory behaviour of GPT-6 Astra in Codex, the session breaks down context reduction, memory types, and the trade-offs between compaction and offloading. The proposed architecture is Richmond’s interpretation of that behaviour, rather than a confirmed account of OpenAI’s implementation.
Then the ideas become code. An interactive appbook makes token usage and context rollover visible, before a Python notebook walks through an agent loop, tool calling, session persistence, summarisation, and retrievable offloaded context. You leave with the vocabulary to discuss memory engineering and the resources to build it yourself.
“Forget, don’t delete.”
Richmond Alake on preserving a path back to the original information
Worth remembering
Key takeaways
-
Compaction and offloading solve different problems.
Compaction compresses information into a smaller representation. Offloading moves it out of the active context and leaves a reference. Both free up space, and they can work together.
-
A summary needs a way back to the source.
Repeatedly summarising summaries can lose details. Archive the original conversation so a missing fact becomes something to retrieve, rather than something that is gone.
-
Combine durable notes with searchable history.
Keep concise notes for continuity across context windows, with access to earlier windows for details the notes did not capture. Neither layer has to carry the whole conversation.
-
Retrieval needs context of its own.
Relevance alone is not enough. Source references, recency, and a clear distinction between the active request and older turns help an agent use recalled information appropriately.
-
Design for all four Rs of memory.
Retain, recall, refine, and reuse. Think beyond storing information: decide how to retrieve it, improve it, and apply it to future work.
-
Inspect the harness, not just the answer.
Track token budgets, rollover thresholds, tool traces, and the contents of each context window. Validate tool arguments and verify that a compaction step actually frees up space.
Theory, meet practice
Inside the session
The session moves from the mental models to a working implementation, with live demos along the way.
Understand the patterns
Context reduction, compaction, offloading, memory types, and what can go wrong when an agent retrieves an earlier conversation.
Explore the appbook
Inspect live context windows, compare summarisation with offloading, and watch token usage change as a window rolls over.
Build from first principles
Work through a Python agent loop, tool schemas and validation, persistent sessions, summaries, and references to archived context.
Make it work on your machine
Get the code. Build the patterns.
Work through the companion notebook, or use the appbook to see how the different approaches change an agent’s context. The main notebook builds the agent loop and memory mechanisms directly in Python.
Companion notebook · PythonAgent memory from scratchagent_memory_from_scratch.ipynbTo run the examples, follow the repository setup instructions and use your own OpenAI API key. You can read the saved notebook outputs without running the code.
Keep learning
Make memory your next deep dive.
Explore 100 Days of Agent Memory for more patterns, practical frameworks, and lessons from building in the open.
Explore the series