---
title:

OpenAI Guide to Context Personalization

date: 2026-01-15
draft: false
---

https://cookbook.openai.com/examples/agents_sdk/context_personalization

OpenAI has released its framework and algorithm for building personalization. The core idea is the separation of data types combined with a specific processing algorithm. This method allows for the accumulation of behavioral data and ensures response consistency across multiple sessions. It’s a valuable example of how to address agent-related challenges.

Here is the summary.

Memory Architecture

  1. State Components:
    • Profile: Structured user data in YAML format.
    • Global Notes: Long-term preferences in Markdown format.
    • Session Data: Temporary notes and current dialogue history.
  2. Injection: Relevant parts of the profile and notes are dynamically inserted into the system prompt before each model call.
  3. Distillation: The agent uses the save_memory_note tool to automatically capture new facts and preferences during the conversation.
  4. Context Management (Trimming): When the token limit is reached, recent message history is preserved, and important session notes are re-injected into the prompt to maintain coherence.
  5. Consolidation: At the end of a session, asynchronous data processing is performed: deduplication, conflict resolution, and removal of outdated information.

Principles of Operation

Priority Hierarchy

When data conflicts occur, the following priority order is applied:

  1. Latest user message.
  2. Session-specific refinements.
  3. Global profile settings.

Technical Implementation

  • Formatting: Using YAML for profiles and bulleted lists for notes ensures high predictability in model interpretation.
  • Tooling: Explicit tool calls for memory recording allow for controlled agent learning.

Evaluation and Safety

Efficiency Metrics

  • Extraction Accuracy: Correctness and completeness of capturing new facts (Precision/Recall).
  • Injection Quality: Impact of memory on responses without compromising current task performance.
  • Consistency: Absence of duplicates and contradictory data after consolidation.

Safety (Guardrails)

  • Data Filtering: Excluding personally identifiable information (PII) and passwords from memory.
  • Injection Protection: Preventing attempts to alter system instructions via user notes.
  • Lifecycle: Mechanisms for automatic expiration and deletion of irrelevant data.