# Memory settings UI

| Route | Shows |
| --- | --- |
| `/memory` | Standard 64px title bar with a **Memory settings** link. Topics, Timeline, Recent and Core above the Topic tree. No Topics yet: an empty state linking to settings. |
| `/settings/memory` | Lifecycle summary, then the controls below, on the shared Settings header, gutter, section and row styles. The summary is the only Memory-specific structure. |

Lifecycle summary: Capture, Write (writer model), Store (Local + Git, or Disabled), Recall (method, warning when it needs an embedding that is missing). At 720px the section list, tree and content stack and Memory navigation stays.

## Controls

| Control | Key | Values, **default** |
| --- | --- | --- |
| Enable Memory | `memory.backend` | **on** (`local`), off (`none`). Needs a restart. |
| Storage |  | Read-only: Topic Markdown, derived views, Git history |
| Writer model | `memory.writer.model` | **Automatic** (default Agent's model, else last used) or an enabled model |
| Automatic writing | `memory.writer.enabled` | **on** |
| Write frequency | `memory.writer.trigger_tokens` | 8K, **16K**, 32K |
| Verify after writing | `memory.writer.verify` | **off** |
| Recall method | `memory.retrieval.method` | Agent, **Keyword (BM25)**, Semantic, Hybrid |
| Embedding model |  | Status, plus **Install** while missing: about 1 GB with the packages, about 90 MB without |
| Hybrid weighting | `memory.retrieval.hybrid.weighting` | Weights: [Memory settings](https://fzkuji.github.io/OpenProgram/docs/capabilities/memory-settings.html). Default **Automatic**. Hybrid only. |
| Favour well-matched Topics | `memory.retrieval.hybrid.file_boost` | **on**. Hybrid only. |
| Recall depth | `memory.retrieval.top_k` | 3, **5**, 8, 10. Off in Agent mode. |
| Project memory | `memory.layers.project` | **on** |
| Write to project memory | `memory.layers.project_writes` | **on**. Needs Project memory. |
| Core Memory in every chat | `memory.core.inject` | **on**; independent of the recall method |
| Recent view size | `memory.recent.limit` | 25, **50**, 100 |
| Workspace |  | Read-only path; Runtime-managed files stay read-only |

- One schema for Settings, CLI and TUI.
- Each change posts to `POST /api/settings` at once; there is no Save button. A rejected write restores the old value and shows an inline error.
- Enable Memory explains the restart in its description, with no "Next start" badge: the API has no pending-restart state.
- No external API permission controls.

## Agent mode

**Agent · On demand** runs no automatic BM25, embedding or hybrid query. The Agent reads with `memory_get`, and `memory_search` falls back to exact line matching.

## Embedding install

1. `POST /api/memory/embedding/install` refuses at once on Intel macOS, with a message naming BM25 or a supported platform.
2. In a worker thread, install `sentence-transformers` and torch, then download the fixed encoder configuration, tokenizer and safetensors weights.
3. Verify the packages resolve and every required file exists and is non-empty, without constructing the encoder.

A failure returns 502 with the error and leaves the recall method alone. Semantic and Hybrid stay disabled until packages and snapshot are present; saving either repeats the full availability check. See [Recall](https://fzkuji.github.io/OpenProgram/docs/reference/design/memory/overview.html#recall).

## Loading

| Request on entry | Contract |
| --- | --- |
| `GET /api/settings?scope=memory` | The `memory.*` rows. Its failure shows an error and leaves controls disabled. |
| `GET /api/memory/status?settings=true` | `workspace_path`, `embedding_available`, `embedding_packages`. Skips `store.ensure()` and the workspace inspector; checks files and package specs without importing numerical code or loading weights. |
| `/api/models/enabled` | Writer choices. Runs in FastAPI's worker thread, off the event loop. |

The page appears once, whole, after all three settle. A failed status or model request does not block the settings rows. No agent runtime settings are requested.

**Layout and neighbouring pages**

- Lifecycle cards keep their intrinsic height in the scrolling column and never flex-shrink behind `overflow: hidden`.
- A long writer-model label shrinks inside the control cluster, not the left title or description.
- Entering Settings prefetches only Token Usage and the schema settings and system access. Providers, Search and Channels request their data when opened.

[Memory overview](https://fzkuji.github.io/OpenProgram/docs/reference/design/memory/overview.html)
