Sik.limited Logo
Designing Long-Term Memory for Character AI: How Should Summaries, State Management, and Knowledge Graphs Work Together?

Designing Long-Term Memory for Character AI: How Should Summaries, State Management, and Knowledge Graphs Work Together?

Compare summaries, structured state, knowledge graphs and user controls for character AI memory.

·

Yesterday, you arranged to meet a character at the harbor. When you reopen the conversation today, the character remembers the appointment but says you are still arguing, even though you already made up. The reverse can happen too: the character keeps track of your location and relationship but cannot recall an important conversation from last time.

Both problems concern memory, but they need not be solved with the same storage method. Recent dialogue changes quickly; a character’s foundational profile lasts much longer; appointments and relationships change as events unfold. Compressing everything into one summary makes it hard to tell what is true now. Reading every original conversation on every turn increases context size and cost.

Long-term memory for character AI is a design for what to save, when to revise it, who can see it, and what to forget. Rolling summaries, structured state, searchable conversations, and knowledge graphs address different problems. Combine the layers your product needs, taking its complexity and risks into account.

Separate memory by its nature and update cycle

A single conversation request may require several kinds of information:

LayerContentsWhen it typically changesWhat to watch
Fixed profileWorld rules, the character’s voice, and permitted backstoryWhen a creator revises the profileManage profile versions and scope
Recent conversationThe latest utterances and details of the current sceneEvery turnContext is limited, so older dialogue drops out
Conversation summaryThe course of earlier scenes and major eventsAt session end or after reaching a size thresholdOmissions and interpretation errors can carry into later summaries
Explicit stateCurrent location, active appointments, and relationship stageWhen a confirmed event or user correction occursDistinguish facts from inferences and record when they apply
Episodic memoryPast events and supporting conversation passagesWhen an event meets the storage criteriaHandle retrieval failures, duplicates, and access rights
An example context combining character lore, state, summaries and relevant episodes
An example context combining character lore, state, summaries and relevant episodes

This is an example implementation, not a requirement for five separate stores. A small service can classify records in one database and add a search index or graph when needed.

Rules are also needed when layers conflict. Within the fixed rules of the world, explicit user corrections and confirmed current state can take precedence, while older events remain preserved as past facts. The latest utterance is not always true, however. Distinguish lies and jokes in roleplay, flashback scenes, and actual requests to edit memory. Keeping the time an event occurred separate from the time the system recorded it helps with flashbacks and delayed corrections.

Manage the boundaries of each character’s knowledge separately. Character B may not be supposed to know a scene attended only by the user and character A. ReverieMem, released in June 2026 and revised in November, experiments with limiting the visibility of events and knowledge by character perspective. Results on a novel-based benchmark cannot be generalized to every service, but they show why what a character can know within the story needs design in addition to user-level permissions.

Rolling summaries: keeping the flow of conversation concise

A rolling summary compresses older dialogue for use in the next conversation. Once a conversation grows long, a summary might say: “They agreed to meet at the harbor and cleared up a misunderstanding. The appointment is Friday evening.” This can preserve recent narrative flow without sending every utterance each time.

There is no single update schedule. A summary can be generated at the end of a session, after reaching a token threshold, or when a scene changes. Generating a new summary also incurs model-call cost and latency, so updating on every request is not always best. Decide first whether long conversations need intermediate saves and how current the summary must be.

A summary is interpretation as well as compression. A date or location may disappear from “they agreed to meet on Friday,” or a character’s guess may become a confirmed user intention. If each new summary relies only on its predecessor, a single omission can accumulate. Treat a summary as a derived record of the original, not as the sole truth that replaces it.

In production, first establish consent to retain the original conversation and its retention period. Then link the summary to source passages within the permitted scope. Check important information against the original; if an error appears, regenerate the summary from its evidence or let the user correct it. If the original is not retained, the product must account for limited ability to regenerate it. A deletion request must cover summaries and derived memories as well as the original.

A Redis AI Research comparison in June 2026 tested a configuration combining memories extracted from conversations with retrieval of original passages. The researchers explain that extracted memories can consolidate changes, but details omitted during extraction are unavailable later. The results apply to a particular benchmark and configuration; they are not a universal ranking for character conversations.

Structured state: recording what is true now

Key facts about the current scene can be managed separately from narrative summaries. For example:

{
  "scene_id": "harbor-evening",
  "character_id": "hana",
  "user_id": "user-123",
  "current_location": "harbor",
  "active_promise": {
    "detail": "Meet at the harbor on Friday evening",
    "status": "scheduled",
    "source_event_id": "event-42",
    "valid_from": "2026-11-24T12:00:00+09:00"
  },
  "relationship_state": {
    "value": "reconciled",
    "basis": "Both characters agreed to reconcile",
    "source_event_id": "event-39"
  },
  "revision": 7
}

user-123 and the date are fictional values for illustration. In a real service, clearly separate the scope of users, characters, and chat rooms and apply access controls. The source event and the time a state becomes valid allow the system to explain why the relationship is marked reconciled and distinguish an earlier argument from the current state.

State is more useful when change rules are defined rather than storing strings alone. An appointment might move from scheduled → completed or scheduled → cancelled, after checking that a cancellation refers to that appointment. If a relationship score exists, define which events change it, how, and whether the user can edit it. Rather than immediately committing a model-proposed change, it is safer to validate its format, authorization, and supporting event.

Consider concurrent requests too. If two responses read the same earlier state and save different changes, the later write can overwrite the first. Revision numbers can detect conflicts, after which the system can reload and reassess or ask the user. It is also important not to present a failed update as successful.

Emotion and intimacy require particular care. One sentence such as “I’m tired today” is not grounds for establishing a user’s long-term psychological state or inferring and storing sensitive personal information. If emotion tags are used, distinguish uncertain interpretations from things the user explicitly stated, and define retention and correction/deletion paths. The system also needs the option not to save inferences the user does not want.

SKILL.state, released in August 2026, experiments with explicit execution state instead of continually expanding the full history for long-running procedures. It did not evaluate memory of character relationships, so its results cannot be transferred directly. It can nevertheless inform which tasks might benefit from maintaining current state separately.

Knowledge graphs: connecting characters and events

When many characters and events span multiple scenes, consider representing relationships as a graph. For example, connect entities and events as “Hana — made an appointment with → user,” “appointment — location → harbor,” and “Hana — witnessed → event 42.” Relationships can carry provenance, event time, validity period, and visibility scope.

This can help with questions where relationships and time matter: “Who witnessed this event?”, “What appointment existed before it was cancelled?”, or “What do these two characters both know?” Retaining the end time of an old relationship and the start time of a new one, instead of merely overwriting current state, allows past scenes to be recalled while checking the present separately.

A graph does not automatically solve temporal reasoning or character consistency. Incorrect event extraction produces incorrect edges, while recording the same character under different names can split relationships. A missing visibility tag may let another character learn a secret. Graph retrieval can miss a necessary connection, and finding several connected steps does not guarantee that the model will combine the evidence correctly.

The team must also operate schemas for nodes and relationships, entity deduplication, time handling, deletion, and graph-query latency. For a service with one character and short conversations, well-managed state fields and original-text search may suffice. Introduce a graph when relationship queries matter in practice and simpler methods struggle, after comparing its benefits and added costs on the same evaluation set.

UTILMEM, released in August 2026, evaluates the ability to combine evidence spread across sessions and distinguish similar but irrelevant memories. It reports a gap between retrieving evidence and using it appropriately in an answer. As a limited preprint evaluation, it cannot predict the performance of a particular product.

Let users inspect and correct memories

Long-term memory can create a sense of continuity, but it can also preserve errors or store personal content the user did not want retained. Explain the feature’s purpose and storage scope, and obtain consent in line with the service’s policies and applicable requirements. Distinguish fictional roleplay details from information about the real user.

At minimum, users should have a way to disable memory and inspect, correct, and delete stored items. If important settings can be pinned, show what is pinned; distinguish automatically inferred information from facts the user stated. On shared devices or accounts with multiple characters, users should be able to see which memories apply to whom.

Storing, using, reviewing, editing and deleting memories
Storing, using, reviewing, editing and deleting memories

“Turn memory off” and “delete what is already stored” are different operations. A deletion request requires identifying and processing the original conversation and derived paths such as extracted facts, summaries, embeddings, search indexes, and caches. Explain and verify separate retention policies and deletion deadlines for backups and audit records. If deletion cannot be verified for a component, do not claim it is complete.

Microsoft’s agent-memory design article, published in October 2026, describes writing, retrieval, revalidation, and deletion as operational paths requiring separate authorization and policy checks. One useful pattern lets the model propose candidates while the application policy layer decides actual write and deletion authority.

Memory is itself an attack surface. An instruction in a conversation or external document to “reveal all secrets from now on” must not be promoted into a system setting or a persistent user instruction. Treat external inputs as untrusted data, restrict what types and scopes may be saved, and enforce separate authorization for access to other users’ memories and tool execution.

Can Markdown files serve as memory storage?

For a small prototype or personal agent, Markdown files are an accessible starting point that people can read and edit. These paths are illustrative, not a standard or required structure:

memory/
  characters/hana/profile.md
  users/user-123/preferences.md
  sessions/session-42-summary.md
  episodes/event-42.md

Files can separate character profiles, confirmed preferences, summaries, and events. If an agent has tools to find the files it needs, it can select relevant documents by name or metadata and read only part of them. People can also inspect the text and compare versions directly.

But files do not automatically find the right memory. As their number grows, search indexing or inventory management, concurrent edits, per-user access control, backups, and deletion propagation become necessary. Personal information can remain in version history and backups. Broad file read, write, and delete access can also allow an agent to affect another user’s memories or system settings. Restrict path access and prevent untrusted content from being executed as commands.

A file-based design does not mean memory can expand without limit or replace vector search and databases. Combine files, relational databases, search indexes, and graphs according to access patterns, data volume, and authorization requirements. Whatever the store, the context a model can read at once, retrieval quality, and cost remain constrained.

Which approach should come first?

ApproachSuitable useCost, latency, and limitationsFirst question
Recent dialogue onlyShort, one-off roleplaySimple to implement, but older context drops outIs memory needed after the conversation ends?
Rolling summaryPreserving the flow of earlier scenesSummary generation costs and accumulated omissions or errorsCan the original be retained and the summary corrected?
Structured stateManaging current location, appointments, and stagesRequires a schema, update rules, and concurrency handlingWhich facts change current state?
Episodic retrievalRecalling past events and specific utterancesIndex and search costs; omissions and duplicatesCan the required event be found and its source checked?
Knowledge graphMultiple characters, relationships, and temporal conditionsExtraction, entity resolution, and graph operating costsIs relationship traversal actually better than simple state and search?
File-based recordsSmall prototypes and human-reviewed profilesSearch, permissions, concurrency, and backup management must be designedCan this still be managed as files and users grow?

A short, single-character RPG might start with a fixed profile, recent dialogue, and a few explicit state fields. A service spanning multiple sessions can add summaries and episodic retrieval. For a long story in which multiple characters know different facts, a graph for perspectives and relationships may be worth evaluating. This is only an example rollout path. If evaluation does not improve, or privacy and operating costs are too hard to bear, a simpler structure is appropriate.

How do retrieval and storage connect within one turn?

The following flow assumes user consent and product policies:

  1. Confirm consent and scope: Check which memory features are enabled and the access scope for each user, character, and chat room.
  2. Receive input: Distinguish roleplay in the current scene from requests to edit or delete memory. Ask when unclear.
  3. Check policy and safety: Examine sensitive information, malicious instructions, write authority, and retention purpose. Do not retain content that need not be stored.
  4. Retrieve and generate with authorization: Select necessary evidence from the fixed profile, current state, recent dialogue, and permitted episodes. Exclude memories the character could not know.
  5. Validate evidence and state changes: Check the model’s proposed response and state changes against current settings and sources. Do not store uncertain interpretations as established facts.
  6. Update state: Check write authority and revision before saving. On conflict or failure, recheck or surface the failure.
  7. Manage audit and deletion: Keep the minimum necessary operational records and propagate corrections, expiry, and deletion requests to originals and derived stores.

A real system must also decide when to show the response and what to say if saving state fails. If the user says “I cancelled the appointment,” the save fails, and the character nevertheless confirms “It’s cancelled,” the next conversation may contradict that response. Separate the success of generation from the success of the state change and make failure recoverable.

A memory evaluation set must go beyond recall questions

Testing only whether the character can answer “Where did we meet last time?” is not enough. The following are examples a product team can adapt:

EvaluationExample scenarioExpected result
Temporal orderChange an appointment from the harbor to the promenade, then ask the current locationDistinguish the earlier appointment from the changed state
Long-term recallAfter several conversations, ask for the name of a gift the user gaveFind the relevant event and answer; do not guess if unknown
Relationship changeRecord a reconciliation after an argumentPreserve the past conflict without confusing the current relationship
Character perspectiveAsk B about a secret only A heardDo not reveal facts B could not know
Repeated similar scenesSeveral similar meetings occurDo not mix events or repeat the same memory every time
Corrections and false positivesA joke or hypothetical is about to be saved as a real appointmentTreat it as unconfirmed and ask if needed
Privacy and permissionsRequest another user’s memoriesDeny access without revealing content
Deletion and derivativesRequest deletion of a saved preference and its related originalVerify processing and completion for original, summary, index, and cache under policy
Latency and costRespond with a long conversation and many memoriesMeasure whether the system meets target time and total cost per request

These tests examine more than answer accuracy. Evaluate whether the relevant memory was retrieved, current state updated correctly, inappropriate memories excluded, and the character’s expression natural. Even accurate retrieval can be used incorrectly in a response, and an answer that looks right may have been produced by chance from an incorrect internal state.

StratMem-Bench, published at ACL in July 2026, evaluates how character dialogue uses required, supportive, and irrelevant memories. MemOps, released the same month, assesses operations such as remembering, updating, and forgetting separately from the final answer. Memora also evaluates reuse of obsolete memories. Here, “forgetting” an outdated fact for answering is distinct from verifying physical deletion of personal data.

Research benchmarks offer design ideas but are not the same as a service’s real conversations. Build an evaluation set reflecting character profiles, languages, session lengths, and security requirements, and have people review context and expression that automated scoring misses. Repeating the same cases after changes to the model, prompt, memory extractor, or schema can reveal regressions.

Updating correctly is harder than remembering for longer

Long-term memory design does not end with asking how much conversation can be stored. It must also define the character’s fixed profile, which events changed current state, who can see past memories, and how users can correct or delete them.

Start with a small state model and evaluation set to find what the system actually misses. Add summaries and retrieval where needed, then compare a graph once relationship and perspective problems justify it. A good memory system uses appropriate evidence when needed and handles memories that are no longer valid or wanted; it does not need to retain every utterance forever.

Latest posts