feat-memory · personal memory v1Add personal memory for signed-in CoreSpeed users. Memory is on by default, manageable in Settings, shared across devices, and exposed to agents through a first-party CoreSpeed MCP endpoint. Sarea talks only to CoreSpeed-owned APIs and a local credential broker; agent subprocesses never receive Mem0 credentials or long-lived CoreSpeed tokens.
corespeed-memory MCP injection for new sessions when enabled.Use a CoreSpeed Memory Service backed by a self-hosted Mem0 deployment. Sarea owns preferences, UI, ingestion triggers, and MCP injection; the service owns JWT validation, policy, memory CRUD, and Mem0 integration.
| Candidate | Fit | Decision |
|---|---|---|
| Mem0 | Self-hostable OSS engine with REST APIs, per-user memory primitives, CRUD, and semantic search. | Use behind the CoreSpeed service boundary. |
| Zep / Graphiti | Strong temporal graph direction, but heavier and less direct for flat personal memory v1. | Keep as phase 2 challenger for org and temporal memory. |
| LangMem | Useful library abstractions, not a deployable multi-user service. | Do not use as v1 platform. |
| memU, A-MEM | Interesting research/proactive-agent direction, less mature for CoreSpeed account-bound SaaS memory. | Revisit later. |
| GBrain / Hermes memory | Opinionated full-agent brain designs. | Use only as design inspiration. |
The service returns and persists enabled: true when no preference exists.
No memory connector is injected and no conversation turns are sent.
It also removes memory tools from new or reloaded sessions, but it does not delete existing memories.
This matches Sarea's existing connector and credential behavior.
Delete item and clear all are management actions with confirmation for clear all.
On launch and sign-in, MemoryStore fetches GET /memory/preferences. If the state is unknown, Sarea must not inject memory MCP or send ingestion payloads. A cached enabled value is display-only until the service confirms.
{
"name": "corespeed-memory",
"url": "http://127.0.0.1:<brokerPort>/memory/mcp",
"headers": { "X-Broker-Auth": "<per-launch-token>" }
}
The broker forwards /memory/mcp to https://gateway.ai.<domain>/memory/mcp and injects a fresh CoreSpeed JWT upstream. The service scopes every read and write to the authenticated token subject.
After a completed turn, Sarea builds a compact payload instead of dumping the full transcript. It includes the latest user prompt, final assistant summary, lightweight tool summaries, session identity, workspace hash, and agent id.
{
"sessionId": "uuid-or-agent-session-id",
"sessionTitle": "Fix Sarea onboarding",
"workspacePathHash": "sha256...",
"agentId": "claude-code",
"createdAt": "2026-05-13T18:00:00Z",
"userPrompt": "The user's latest prompt",
"assistantSummary": "A concise final answer or turn summary",
"toolSummaries": [
{ "name": "apply_patch", "summary": "Edited SettingsView.swift to add..." }
]
}
| Tool | Purpose | Scope rule |
|---|---|---|
search_memory(query, limit?) | Find relevant personal memories. | Authenticated user's personal scope only. |
remember(text, source?) | Write an explicit memory with optional provenance. | Service derives user id from JWT. |
update_memory(id, text) | Update a memory by id. | Service verifies ownership before mutation. |
delete_memory(id) | Delete one memory by id. | Service verifies ownership before deletion. |
list_memory(query?, limit?, cursor?) | List or filter memory items for management and agent inspection. | Personal scope only in v1. |
Add a dedicated Settings -> Memory pane next to Account. Keep it separate from Account because management actions need space and confirmation flows.
| Endpoint | Use |
|---|---|
GET /memory/preferences | Fetch default-on remote preference. |
PUT /memory/preferences | Toggle memory on/off. |
POST /memory/ingest | Extract durable memories from compact turn payloads. |
GET /memory/items | Search/list memory items. |
DELETE /memory/items/:id | Delete one owned memory. |
DELETE /memory/items | Clear all personal memory. |
POST /memory/mcp | Streamable HTTP MCP endpoint for agents. |
The service validates the CoreSpeed JWT on every endpoint. The user id comes from the token subject, never from client-supplied payload fields. Preference storage is keyed by user_id; memory metadata can live in Mem0 or a CoreSpeed side table if needed for clean provenance.
Wire the memory paths under the existing gateway host.
Check ingestion quality, delete semantics, and MCP behavior.
Server can roll back by returning disabled or unavailable so clients stop ingestion and injection.