# Memory, Sessions, And Context

## Endpoint Summary

| Method | Path | Purpose |
| --- | --- | --- |
| `GET` | `/v1/memory` | Memory backend summary |
| `POST` | `/v1/memory/search` | Search memory |
| `POST` | `/v1/memory/write` | Write memory |
| `GET` | `/v1/memory/episodes` | List episodes |
| `GET` | `/v1/memory/failures` | List captured failures |
| `GET` | `/v1/sessions` | List Omnius task sessions |
| `GET` | `/v1/sessions/{id}` | Get session history |
| `GET` | `/v1/context` | Show current session context |
| `POST` | `/v1/context/save` | Save a context entry |
| `GET` | `/v1/context/restore` | Build a restore prompt |
| `POST` | `/v1/context/compact` | Request context compaction |

## Memory Search

Use memory search for persistent knowledge, failures, prior decisions, and scoped context. Public connector surfaces such as Telegram should keep scope explicit so one chat does not pollute another.

## Memory Write

Memory writes require run or admin scope where enforced. Prefer structured, scoped writes over dumping entire transcripts.

## Failures

Failure records let the agent learn from raw observed outputs. The design goal is to pass failure output through as evidence, not convert platform-specific strings into hardcoded policy shortcuts.

## Context

Context endpoints expose the TUI context stack:

- `GET /v1/context`: current context snapshot.
- `POST /v1/context/save`: persist a context entry.
- `GET /v1/context/restore`: build a restore prompt.
- `POST /v1/context/compact`: request compaction.

## Sessions

Session endpoints expose archived task turns, which can be used by dashboards, replay tooling, or state restoration.
