Article
Context Engineering for Personalization - State Management with ...
developers.openai.com
Quoted on this wiki
Every place a page here uses this source, in the order the words come in it.
This cookbook shows a state-based long-term memory pattern: “State object = your local-first memory store (structured profile + notes)” Distill memories during a run (tool call → session notes)
Modern AI agents are no longer just reactive assistants—they’re becoming adaptive collaborators. The leap from “responding” to “remembering” defines the new frontier of context engineering. At its core, context engineering is about shaping what the model knows at any given moment. By managing what’s stored, recalled, and injected into the model’s working memory, we can make an agent that feels personal, consistent, and context-aware. “It allows developers to define structured state objects that persist across runs, enabling memory, notes, or even preferences to evolve over time.” This cookbook shows a state-based long-term memory pattern:
State object = your local-first memory store (structured profile + notes) “Distill memories during a run (tool call → session notes)” Consolidate session notes into global notes at the end (dedupe + conflict resolution)
“By managing what’s stored, recalled, and injected into the model’s working memory, we can make an agent that feels personal, consistent, and context-aware.” The RunContextWrapper in the OpenAI Agents SDK provides the foundation for this. It allows developers to define structured state objects that persist across runs, enabling memory, notes, or even preferences to evolve over time. When paired with hooks and context-injection logic, this becomes a powerful system for context personalization—building agents that learn who you are, remember past actions, and tailor their reasoning accordingly.
Deduplication quality: duplicates removed without losing meaning “Conflict resolution: correct “latest wins” or precedence behavior” Non-invention: no hallucinated facts introduced during consolidation
At the End of the Session “Conflicts are resolved and duplicates are removed” The updated state object is reused.