# flyte.ai.agents.memory

Dir-backed memory for :class:`flyte.ai.agents.Agent`.

This module implements :class:`MemoryStore`, a directory-backed store that
combines a managed conversation transcript with path-addressed artifact files,
plus optional auditing, read-only prefixes, version snapshots, and optimistic
concurrency. It is intentionally decoupled from the agent loop so non-agent
code (sleep cycles, promotion tasks, dashboards) can use the same store with
the same enforcement.

Design influences include the Claude-style "many small files addressed by
path, with audit + version history" pattern.

The path-addressed I/O methods (``read_text``, ``read_json``, ``get_meta``,
``current_sha``, ``write_text``, ``write_json``) — like the keyed-store methods
``create`` / ``get_or_create`` / ``save`` — are :func:`~flyte.syncify.syncify`-wrapped:
call them synchronously (``memory.read_text(...)``) or await the ``.aio(...)``
companion in async code. The remaining helpers (``flush_messages``, ``audit_tail``)
stay async-by-default with explicit ``*_sync`` companions, and ``list_paths`` is
synchronous.
## Directory

### Classes

| Class | Description |
|-|-|
| [`MemoryMeta`](https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.ai.agents.memory/memorymeta/page.md) | Per-file metadata sidecar (sha256, actor, timestamp, …) for a memory entry. |
| [`MemoryStore`](https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.ai.agents.memory/memorystore/page.md) | Conversation transcript + path-addressed artifact memory backed by :class:`flyte. |

### Errors

| Exception | Description |
|-|-|
| [`AccessDenied`](https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.ai.agents.memory/accessdenied/page.md) | Raised when a write targets a read-only or reserved prefix. |
| [`ConcurrencyError`](https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.ai.agents.memory/concurrencyerror/page.md) | Raised when an ``expected_sha`` precondition does not match the current state. |
| [`MemoryStoreError`](https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.ai.agents.memory/memorystoreerror/page.md) | Base class for :class:`MemoryStore` errors. |

### Variables

| Property | Type | Description |
|-|-|-|
| `MESSAGES_PATH` | `str` |  |

## Subpages

- [AccessDenied](https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.ai.agents.memory/accessdenied/page.md)
- [ConcurrencyError](https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.ai.agents.memory/concurrencyerror/page.md)
  - Parameters
- [MemoryMeta](https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.ai.agents.memory/memorymeta/page.md)
  - Parameters
- [MemoryStore](https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.ai.agents.memory/memorystore/page.md)
  - Parameters
  - Methods
  - append()
  - audit_tail()
  - audit_tail_sync()
  - create()
  - current_sha()
  - exists()
  - extend()
  - flush_messages()
  - flush_messages_sync()
  - get_meta()
  - get_or_create()
  - list_paths()
  - read_json()
  - read_text()
  - remote_path_for_key()
  - save()
  - write_json()
  - write_text()
- [MemoryStoreError](https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.ai.agents.memory/memorystoreerror/page.md)

---
**Source**: https://github.com/unionai/unionai-docs/blob/main/content/api-reference/flyte-sdk/packages/flyte.ai.agents.memory/_index.md
**HTML**: https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.ai.agents.memory/
