The history lasts one conversation. Long-term memory is what an agent keeps between conversations: the user’s preferences, the state of a project, decisions taken. In Gwenflow it is a set of Markdown files, under a virtual /memories root, that the agent sees in its prompt and edits with tools. Three pieces work on the same files:

Storage

The files live in a MemoryStore:
Writes are versioned: a write checks that the file has not changed since it was read, so two processes editing the same file do not overwrite each other silently. On S3 the version is the object’s ETag, compared before each put; conditional_writes=True also sends If-Match headers, which makes the check atomic on servers that honour them (AWS S3). Paths that try to leave the root are rejected.

An agent with memory

  • always files are rendered in full in a ## Memory block of the system prompt; a missing one starts from a template.
  • browse prefixes are listed in an index (path and description of each topic file); the agent reads one with read_memory.
  • aload(query=...) also picks the topic files the request is about, by matching it against the index (file names, descriptions, identifiers) without an LLM call, and renders them in the prompt. recall_limit (3) caps them; recall_stopwords adds the common words of your domain.
  • The tools work on an in-process copy; aflush() writes the files that changed. After a version conflict, this run’s edits are replayed on a fresh copy.
The memory block is not rendered when the agent has a fixed system_prompt.

The tools

tools= exposes a subset. A conversational agent typically keeps read_memory and memory_edit and leaves the rest to the consolidator. max_lines (200) caps a file on every write, max_chars caps its rendering in the prompt.

Consolidating after a conversation

The consolidator updates the writable files and the topic files recalled for the conversation, and may create new ones under creatable_prefixes, never touching a file it was not shown. result.failed tells a failed call from “nothing to change”.

Curating

The curator is an agent that merges candidates, removes duplicates and archives files nobody reads. Run it on a schedule rather than after every conversation.

Limits

Long-term memory is not available to durable agents yet, and is never handed down to sub-agents.