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. The orchestrator resolves the user's private memory folder, downloads memory.md if present, and enforces the configured token budget. If the folder or file cannot be resolved, the turn continues without memory.

  2. Inject. Non-empty memory is injected verbatim into the system prompt under “What I know about you”. If no profile exists yet, this section is omitted.

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

  4. Gate. After the answer, a default-enabled, low-cost language-model call returns UPDATE or NOOP. An explicit NOOP skips the full rewrite. Gate errors fail open to UPDATE so consolidation can still run.

  5. Consolidate. When an update is warranted, the user-memory postprocessor runs in parallel with other postprocessors. It sends the existing profile and latest user/assistant exchange to the effective memory model, which returns either NOOP or a complete rewritten profile.

  6. Notify. By default, the assistant message temporarily shows “🧠 Updating context memory…” while the full rewrite runs. The notice is removed when consolidation finishes, including after a failure. It is not shown when the gate returns NOOP.

  7. Upload. If the profile body changed, the updated memory.md is uploaded with ingestion skipped and hidden from chat. If consolidation or upload fails, the visible answer is retained and the existing profile remains available for the next turn.

The postprocessor does not alter the substantive assistant answer. The only visible change is the optional transient update notice.

Storage Model and Access Control

Memory profiles are stored in the company Knowledge Base as Markdown:

user-memory/            ← company-wide root folder (auto-provisioned)
  <userId>/             ← private per-user folder (created on first use)
    memory.md           ← the user's single memory profile

Level

Access

user-memory root folder

Created automatically when a space admin enables context memory. The company Root Group is granted READ and WRITE, but not MANAGE, so users can create private child folders.

user-memory/<userId>

Created on demand with access inheritance disabled. The owning user receives access; Root Group access on the parent does not flow into the child. Other users cannot read the profile.

memory.md

Uploaded with SKIP_INGESTION and hideInChat: true. It is not indexed for search. The same logical file is upserted on every 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.

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
---

# User Memory

## 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)_

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

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

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.

## Recent Topics

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

## Follow-ups

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

Update Rules

Operation

When

ADD

A new, durable fact is added to the appropriate section.

UPDATE

A newer statement refines or contradicts an existing fact. The newest statement wins.

DELETE

A new turn explicitly invalidates an existing fact that should not remain.

NOOP

No durable user fact is present. The profile remains unchanged and no upload occurs.

Size control. The profile is kept within the configured token budget, 2000 tokens by default. Oversized profiles are condensed toward 90% of the cap by merging duplicates and removing stale or low-signal material. A still-oversized profile is hard-truncated with a <!-- truncated to fit memory budget --> marker.

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 Advanced Settings → General.

  3. Toggle “Context memory”. The setting defaults to enabled for new spaces and is treated as enabled when the stored key is absent.

  4. Save the space. When memory is effectively enabled, the admin app ensures the company-wide user-memory root exists.

If multiple active user-memory roots exist, the admin app warns the administrator. The duplicates must be renamed or removed before folder resolution can work reliably.

image-20260712-193522.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 loads the authenticated user's existing memory.md through node-chat. The read operation is read-only and returns an empty state when no profile exists; it does not create a folder or seed a document.

  • The editor shows the Markdown body only. YAML frontmatter is hidden and preserved when saving.

  • Users should edit content beneath the existing headings and should not rename or remove those headings.

  • Changes are not automatic; the user must select Save.

  • The update API accepts at most 1 MiB of UTF-8 content. The much smaller runtime token budget still applies when the orchestrator later loads or rewrites the profile.

  • Loading, empty, unavailable, error/retry, unsaved, saving, saved, and save-error states are surfaced in the UI.

The authenticated GraphQL operations are getMyContextMemory and updateMyContextMemory(document). The write path creates the private user folder if necessary and upserts 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 not explicitly false

Space admin

Enabled when the feature flag is on

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

node-chat passes the resulting value as space.allowUserMemory. The Python configuration itself defaults this field to false, so the orchestrator activates loading and post-processing only when the effective payload value is true.

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, condensation, and matching tokenization. When false, the configured Language Model is used.

Language Model

AZURE_GPT_4o_2024_1120

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.

Updating Notice Enabled

true

Temporarily appends “🧠 Updating context memory…” while a full rewrite is running and removes it afterward.

rootFolder defaults to user-memory but is hidden from the standard configuration form.

image-20260720-135036.png

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

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