Context Memory

7 min read

For the end-user explanation of context memory and its behavior in chat, see Context Memory in Unique AI Chat.

Functionality

Context Memory gives every user a single, persistent memory profile shared across all chats and all Unique AI spaces where the feature is enabled. The profile is a compact, structured Markdown file that captures durable user context: identity, communication preferences, work context, skills, recent topics, and open follow-ups.

The Unique AI orchestrator loads the profile before a turn and maintains it after the answer:

  1. Load. A Loading context memory step is opened in chat. The orchestrator resolves /home-<user_id>/user-memory, falls back to the legacy location for users not yet migrated, and downloads memory.md when present. Oversized profiles are condensed and, only if still necessary, hard-truncated. Load failures do not block the turn.

  2. Inject. The Markdown profile body is injected into the system prompt under “What I know about you”. Frontmatter remains internal bookkeeping and is not shown to the model.

  3. Answer. The assistant can adapt tone, examples, and depth using the profile. It cannot update memory during the answer.

  4. Gate. After the answer, the postprocessor decides UPDATE or NOOP. Turns whose only new facts are third-party CID/PII should resolve to NOOP.

  5. Consolidate. For UPDATE, the effective memory model rewrites the full profile under the user-memory content policy.

  6. Scrub. Every rewrite passes through a mandatory final CID/PII scrub. The scrub can accept the candidate, return a cleaned and de-identified profile, or veto the write. It fails closed: an error or malformed result keeps the existing memory unchanged.

  7. Cap and persist. A changed, validated profile is fitted to the token budget and upserted as memory.md with ingestion skipped and chat visibility disabled.

Technical Update Flow

Diagram: Untitled Diagram-1789585682716

Storage Model and Access Control

Memory profiles are stored as Markdown below each user’s private root-level home folder:

/home-<user_id>/
  user-memory/
    memory.md           ← the user’s single memory profile

Level

Access

/home-<user_id>

Created by node-ingestion or, when missing, by the user-memory package with an exclusive owner ACL. There is no company-writable shared memory root.

/home-<user_id>/user-memory

Private per-user subfolder that holds the profile. Other users cannot read or write it.

memory.md

Uploaded with SKIP_INGESTION and hideInChat: true. It is not indexed for search, and the same logical file is upserted on each successful update.

Because there is exactly one memory file per user, every enabled space loads the same profile. Memory belongs to the user, not to a space or chat.

Security and Content Policy

Storage isolation controls who can access a profile; the content policy controls what may be written into it.

  • A user-memory profile may contain PII belonging to the signed-in user only.

  • It must not contain client-identifying data or PII about another user, client, prospect, counterparty, or other private entity. Work facts involving a client are retained only in fully de-identified form.

  • Credentials, payment data, health records, and government identifiers are never stored, including for the signed-in user.

  • The same policy is embedded in the gate, consolidation, condensation, and scrub prompts so enforcement cannot drift between write-path stages.

  • The final scrub is mandatory for every consolidation rewrite and fails closed. If it cannot validate the candidate, the candidate is discarded and the existing profile remains unchanged.

Memory Profile Format

The profile has YAML frontmatter followed by six fixed Markdown sections in the order below. Empty sections use _(empty)_.

Example memory.md

markdown
user_id: user_123
schema_version: 1
last_updated: 2026-06-17T12:00:00+00:00
turn_count: 12
---

## Identity
- Works as a credit risk analyst at a Swiss private bank, based in Zurich (CET).
- Native German speaker; communicates with the assistant in English.

## Communication Preferences
- Prefers concise answers with concrete examples.
- Wants tables for numeric comparisons instead of prose.

## Work Context
- Preparing the quarterly IFRS 9 impairment report.
- Migrating team reporting from Excel to a Python-based pipeline.

## Skills & Expertise
_(empty)_

## Follow-ups
- Wants to revisit the scenario-weighting approach next week.

## Recent Topics
- 2026-06-17 11:40 UTC: Discussed expected-credit-loss staging rules.

Frontmatter Fields

Field

Meaning

user_id

The owning user's ID. Preserved across automatic rewrites and hidden from the in-product editor.

schema_version

Profile schema version, currently 1. Preserved across rewrites.

last_updated

UTC timestamp of the last automatic consolidation that changed the profile.

turn_count

Incremented by one on each automatic rewrite.

Sections and Their Meaning

Section

What it captures

## Identity

Stable facts such as name, role, employer, team, timezone, and language.

## Communication Preferences

Preferred style, formatting, depth, tone, language, and examples.

## Work Context

Current focus areas, active projects, multi-week goals, and deadlines.

## Skills & Expertise

Competences, tools, languages, and proficiency levels.

## Follow-ups

Explicit hand-offs and topics the user wants to revisit.

## Recent Topics

Recently discussed subjects, dated with YYYY-MM-DD HH:MM UTC:.

Configure Context Memory for a Space

Context memory is configured per space and applies to Unique AI spaces.

  1. Enable the feature flag. FEATURE_FLAG_ENABLE_CONTEXT_MEMORY_UN_22033 must be enabled for the company.

  2. Open the Space configuration and go to the Configuration step, where the Context memory switch sits alongside the other general space settings. The switch is hidden entirely while the feature flag is off.

  3. Toggle “Context memory”. Newly created spaces start with the switch on while the feature flag is enabled. For every space the setting is opt-in at runtime: an absent key means memory stays off until the space is saved with the switch on.

  4. Save the space. This persists the space-level setting. Memory storage is provisioned privately per user on demand; saving a space no longer creates a company-wide shared user-memory root.

image-20260804-194210.png

Context memory and Web Search are mutually exclusive by default. If Web Search is enabled for the space, the Context memory switch is disabled with this tooltip:

Context memory is unavailable while web search is enabled, to keep user data out of external search queries.

Operators can lift the restriction per company with ALLOW_CONTEXT_MEMORY_WITH_WEB_SEARCH_UN_22591. This is an operator environment setting, not a configuration-backend registry flag, and must be set consistently on node-chat and admin-app.

image-20260712-193633.png

User-Level Opt-Out

Each user controls context memory in Settings → Context Memory. Disabling it sets the user's allowUserMemory preference to false, so memory is neither loaded nor updated in any space for that user.

Current behavior: disabling does not delete the stored memory.md. Re-enabling makes the existing profile available again. The current settings copy that promises permanent deletion does not match the implementation.

image-20260720-134841.png

Viewing and Editing a Profile

When enabled, Settings → Context Memory resolves the authenticated user’s private /home-<user_id>/user-memory folder and loads memory.md. If the folder does not exist, the private home path can be provisioned for that user. Opening the page with no profile seeds an empty memory.md.

Effective Enablement

Context memory is active for a turn only when every applicable condition below holds:

Condition

Level

Default

FEATURE_FLAG_ENABLE_CONTEXT_MEMORY_UN_22033 enabled for the company

Operator

Off

Space allowUserMemory is explicitly true

Space admin

On for newly created spaces while the feature flag is on; an absent key means off

Web Search disabled, or ALLOW_CONTEXT_MEMORY_WITH_WEB_SEARCH_UN_22591 enabled

Space admin / operator

Web Search blocks memory

User allowUserMemory not explicitly false

End user

Enabled

Advanced Configuration

Consolidation is configured per space under Unique AI Services → Context Memory in the assistant's advanced module configuration.

Setting

Default

What it controls

Use Orchestrator Language Model

true

Uses the orchestrator model for the gate, consolidation, mandatory CID/PII scrub, condensation, and matching tokenization. When false, the configured Language Model is used.

Language Model

AZURE_GPT_4o_2024_1120, unless the DEFAULT_LANGUAGE_MODEL environment variable overrides the platform default

Used when Use Orchestrator Language Model is false.

Max Tokens

2000 (500–8000)

Maximum runtime profile size. Oversized profiles are condensed and then hard-truncated if necessary.

Consolidation Gate Enabled

true

Runs a cheap UPDATE/NOOP decision before the full rewrite. Disable it to run full consolidation after every non-empty turn.

image-20260804-194508.png

Token Usage and Analytics

Every language-model call the feature makes is attributed to its own invocation source, so memory cost can be separated from the cost of the answer itself:

Invocation source

When it runs

user_memory_gate

The UPDATE/NOOP decision after the answer. Capped at a few output tokens.

user_memory_consolidation

The full profile rewrite.

user_memory_scrub

The mandatory final CID/PII validation and de-identification pass before a rewrite can be persisted.

user_memory_load_condense

Condensing a stored profile that is already over budget when it is loaded.

user_memory_post_consolidation_condense

Condensing a validated rewritten profile that is over budget before upload.

Each turn also records a context_memory_updated analytics flag: unset when the postprocessor did not run, false when it ran without writing, and true when a changed profile was uploaded.

Limitations

  • One memory per user, company-wide. There is no per-space or per-chat profile.

  • Not editable during a response. Automatic updates occur after the final answer. Users can separately edit and save the profile in Settings.

  • Web Search exclusivity. The features are mutually exclusive by default.

  • Token budget. Older or low-signal material can be compacted or dropped.

  • Opt-out is not deletion. The current implementation retains the file when the user disables memory.

Feature Flags and Company Settings

Name

Default

Effect

FEATURE_FLAG_ENABLE_CONTEXT_MEMORY_UN_22033

false

Per-company master switch from the feature-flag registry. It enables the space toggle, user Settings tab, and allowUserMemory payload wiring. Supports registry targeting by company.

ALLOW_CONTEXT_MEMORY_WITH_WEB_SEARCH_UN_22591

false

Operator environment override that allows memory and Web Search together. Accepts true, false, or comma-separated company IDs and must be configured on node-chat and admin-app.

Last updated