Skip to content
Allay AI

WikiAllay Server

Memory and traces

The backend keeps what Allay needs to know about players: a session, a lasting memory with places, their deaths, the plugin's state for them, and traces of runs. Each lives only as long as it needs to, each belongs to one server (the same player on another server is someone else, see Security and privacy), and since 6.9 each sits in MongoDB sealed with AES-256-GCM.

#The session

Each player has a session in MongoDB, kept 30 days after the last question (CHAT_TTL_SECONDS, a day before 6.9).

  • It holds whole exchanges: the question, the tool calls with their results, and the answer. A follow-up like “how many were in that chest?” needs no second call.
  • Once a session passes 32 000 tokens or 100 exchanges, everything but the newest 12 000 tokens (at least 2 exchanges, at most 30) folds into a summary of up to 3000 characters. The fold runs after the answer, so the player doesn't wait.
  • Since 6.28 the backend counts tokens with o200k, the open tokenizer of OpenAI's current models, instead of three characters a token. Since 6.29 it counts the model's own tokens: each run's first step tells how many tokens the provider counted for what o200k counts, and the session keeps that ratio, between 0.5 and 3, for its next count. Without a report from the provider, the last ratio stays, or o200k counts alone.
  • Only a session past 42 000 tokens folds before the answer.
  • A player who left gets no summary: the session simply expires.
  • Between folds the session only grows at the end, so the provider's prompt cache keeps it.
  • /askx requests land in the session as one line: what was asked and which commands came out.

The v1 and v2 APIs share the session.

#Other threads

  • Public questions have their own thread, one per server. Each question starts with the asker's name, so a friend's follow-up makes sense. It keeps the answers but not the tool results, which only the asker may see. It lives 2 hours after the last question.
  • Automation agents each have a thread apart from the player's session, for 2 hours after their last wake.

#The lasting memory

The lasting memory sits in MongoDB until the player clears it, or 365 days after their last question. It holds up to 200 memories (MEMORY_MAX): short facts (what the player works on, how they like answers) and, since 6.9, places (their base, a villager that sells arrows), each with its coordinates and dimension. Before 6.9 the plugin kept places on disk as notes. Now one memories tool saves, finds, and deletes both, and gives the distance and direction to a place from where the player stands.

Since 6.27 a memory holds up to 500 characters and has a kind (fact, preference, goal, or place), an optional title for the player's list, up to five tags, and a pin. A place has a category (base, farm, storage, portal, villager, mine, structure, build, other) and a radius for an area. The agent changes a memory in place (update) when something changed, instead of adding a second one. Every one of these fields is sealed with the text.

The prompt lists every pinned memory (20 at most), the 30 newest facts, preferences, and goals, and the 5 saved places nearest the player within 256 blocks, with the way there and whether they stand inside one. Other places and older facts come when the agent looks them up. A search whose words meet no memory gives the agent a short index of all of them (id, kind, title or the text's start, tags), so it matches by meaning itself.

Players manage it with the plugin's commands:

  • /allay new starts a fresh session, and memories stay.
  • /allay memory lists them, pinned ones first, and filters them by tag. With text, it saves one by hand, and a note button under an answer saves a place. Since plugin 6.28 its window pins, unpins, and edits one (text, title, tags).
  • /allay forget deletes them.

#Deaths and the player's state

Since 6.9 the plugin reports each death as it happens: when, where, what killed the player, the death message, their level, and what dropped. The backend keeps the newest 100 (DEATHS_MAX) and answers “when did I die?” from them, ten a page, in the player's time zone. The plugin's state for a player (time zone, settings, goals) lives here too: the plugin loads it when the player joins and saves it as it changes. Both go 365 days after the player's last question.

#A player's copy and erasure

/allay privacy gives a player a link to everything kept about them, good for 24 hours. The backend keeps only a digest of the link's token. An erasure deletes all of it at once, and the link stops working.

#Traces

The backend traces runs into its MongoDB through Mastra's observability: each run, each model step (prompt, output, tokens), and each tool call with its arguments and result. Mastra Studio reads only the shape of them.

  • Every run is traced by default (TRACE_SAMPLE).
  • Traces go after 30 days (TRACE_DAYS, 7 before 6.9).
  • Since 6.9 a trace's prompts, answers, tool data, and error texts are sealed before they're written. The model, tokens, steps, and whether each one worked stay readable for the statistics.
  • Keys are redacted. A run takes about 150 KB to 1 MB, by how long the session is.
  • The admin panel shows only a trace's shape. An owner can open one run's words to look into a problem a player or server reported (“Show text”), after writing why (10–500 characters). Each look goes to the audit log with the reason, as does bun run dist/application/reveal.js <run id> --reason "…" in the container. The environment's account, which scripts use, can't open runs.
  • Erasing a player deletes the traces of their runs at once.

#How it's sealed

AES-256-GCM with a random 96-bit IV per value and a 128-bit tag, under a key derived with HMAC-SHA256 from the backend's SECRETS_KEY (or the key file in /data). The key never sits in MongoDB, so a dump or a backup alone reads nothing. Keep SECRETS_KEY safe and the same: a new one opens none of what was sealed before. Data from before 6.9 stays in the clear until it expires or is saved again.

Next: Telemetry