Graph-Structured Agent Memory: An Engineering Architecture That Separates Facts from Beliefs

    Vector RAG is not enough for long-horizon agents. This article describes a graph-structured memory stack that layers world facts, first-person experience, and opinions, then uses temporal entity-graph retrieval and adaptive reasoning so evidence grades stay explicit.

    Graph-Structured Agent Memory: An Engineering Architecture That Separates Facts from Beliefs

    Why stuffing more context is not enough

    In agent systems, long-term memory is often reduced to a vector store plus similarity retrieval. That pattern works for short chats and single-turn Q&A. Once tasks span sessions, time, and roles, three structural problems appear.

    First, evidence and inference are mixed. “It rained today” is an observed fact; “today is a good day to sleep” is a belief. The texts may be similar and close in embedding space, but their epistemic status is different. Facts need evidence chains; beliefs need confidence, provenance, and revocability. If both are stored as equal text, later reasoning cannot tell what is a baseline fact and what is only an opinion.

    Second, time and causality break. Vector search finds semantic neighbors; it does not reliably answer “what happened before they resigned” or “was this advice given after a failure.” Order, event boundaries, causal edges, and validity intervals are not stable similarity features. Without temporal indexing, the system retrieves related but time-shifted snippets and produces answers that sound plausible but violate event order.

    Third, there is no stable “character.” If replies depend only on whatever fragments were retrieved this turn, tone can swing from rigorous to casual. Long-term memory must store not only what is known, but what was done, what stance was held, and when and why that stance changed. Otherwise style, value constraints, and behavioral bounds drift.

    A better path is not a larger context window, but a different memory topology: model objective facts, first-person experience, and subjective opinions as layers, plus temporal and causal links, and distinguish evidence grades at retrieval and reasoning time. That is the problem a graph-structured memory stack is meant to solve.

    Core idea: layer facts, experience, and opinions; let the graph connect them

    The point is not “replace vectors with a graph.” It is “use a graph for epistemic relations and multi-index retrieval.” A practical design usually has four logical networks:

    1. World network: objective facts
      External information independent of the agent’s viewpoint—for example, that an entity holds a role in an organization, or that a technical approach has a class of constraints. Records should carry source, evidence, validity time, and confidence. This is the baseline fact layer and must not change with the agent’s current tone.

    2. Experience network: autobiographical memory
      First-person records of what the agent did and advised—for example, that it recommended a plan in a given session. This answers “what I did,” not “what the world is.” It should link to action logs, session IDs, and outcome feedback so “I said X” is not treated as “X is true.”

    3. Opinion network: subjective beliefs
      Evaluations, preferences, inferences, and stances—for example, that a plan looks safer under current constraints. Opinion records need holder, polarity, confidence, formation time, supporting grounds, and a revocable flag. Opinions can update with new evidence; versions should be kept so the system can explain why a view changed.

    4. Relation and temporal network: links and constraints
      This layer adds little new semantic content. It holds entity relations, event order, causal edges, validity intervals, and cross-network references so the first three networks can be queried by when, why, and with whom. In engineering terms it is a graph index: nodes point at fact, experience, or opinion records; edges express sequence, causality, support/refute, and derivation.

    With the four networks separated, the system can classify on write, route on retrieve, and grade evidence at inference. Facts outrank opinions. Experience only proves that something was lived or done. Opinions must carry uncertainty. The agent no longer treats all text as homogeneous knowledge.

    Similarity search only sees semantic nearness. Temporal entity-graph retrieval extracts entities, time constraints, event types, and causal intent from the question, recalls a subgraph on the relation/temporal network, then pulls evidence from world, experience, and opinion stores.

    A typical flow:

    • Intent parse: fact lookup, experience recall, opinion ask, temporal Q&A, or causal explanation.
    • Entity and time normalize: aliases and relative times become comparable intervals.
    • Subgraph recall: start from entities and time, expand one or two hops along allowed edges.
    • Evidence fill: follow references to facts, action records, and versioned opinions with confidence.
    • Conflict check: overlapping facts that contradict; opinions that are stale or rebutted.
    • Rank and trim: evidence grade, temporal closeness, source reliability, task relevance, under a context budget.

    Pseudocode:

    1. function retrieve(query, memory):
    2. intent = parse_intent(query) // fact | experience | opinion | temporal | causal
    3. entities, time_range = normalize(query)
    4. seeds = graph.lookup(entities, time_range)
    5. subgraph = graph.expand(seeds, max_hops=2, edge_types=intent.allowed_edges)
    6. evidence = []
    7. for node in subgraph.nodes:
    8. if node.type == "fact":
    9. evidence.append(world.get(node.ref))
    10. elif node.type == "experience":
    11. evidence.append(experience.get(node.ref))
    12. elif node.type == "opinion":
    13. evidence.append(opinion.get(node.ref, include_history=true))
    14. evidence = resolve_conflicts(evidence)
    15. return rank_by_evidence_and_time(evidence, budget=context_budget)

    The graph is not a fancier vector DB; it is explainable connectivity. “What happened before X” walks temporal edges. “Why did the advice change” walks support/refute and versions. “What did you do before” stays in the experience network.

    Reasoning: adaptive orchestration

    Retrieval is not enough. Different questions need different fusion policies. Adaptive orchestration chooses a path from question type, evidence sufficiency, and conflict.

    Three paths:

    • Direct answer: fact questions with sufficient world evidence, plus source and validity time.
    • Graph explanation: temporal, causal, and experience questions must use subgraph evidence and emit event chains and citations, not conclusions only.
    • Cautious fusion: opinions, conflicts, or low-confidence evidence: explicitly separate facts, experience, and views, with confidence and uncertainty.

    Conflict rules belong in the reasoning layer, not ad-hoc prompts: facts over opinions; high-reliability sources over low; newer well-supported facts can supersede expired facts while old versions remain; experience cannot prove external facts, only that the agent acted or observed; rebutted opinions are marked updated, not deleted.

    Simplified fusion:

    1. function answer(query, evidence):
    2. facts = filter(evidence, type="fact")
    3. exps = filter(evidence, type="experience")
    4. ops = filter(evidence, type="opinion")
    5. if conflict(facts):
    6. return cautious_answer(facts, reason="conflicting facts")
    7. if query.intent == "causal":
    8. return explain_with_graph(facts, exps, ops)
    9. if query.intent == "opinion":
    10. return present_opinion(ops, confidence=true, history=true)
    11. return cite(facts, exps)

    Answers are then driven by evidence grade and policy, not a single retrieved snippet. Character is easier to keep: opinions hold long-term stance, experience holds behavioral history, the world network bounds what is true.

    Engineering: write path, storage, evaluation, governance

    Write pipeline: extract, classify (fact / experience / opinion), entity-link, normalize time, detect conflicts, version. Detect contradictory values for the same entity attribute in overlapping intervals at write time. Keep source, generation method, confidence, and revocable flags.

    Storage: graph store for entities, relations, time, and causality; vector index for semantic recall; inverted/keyword index for exact entity match; event log for audit and replay. Hot/cold tiers: frequent entities and recent events stay hot; historical versions archive.

    Metrics should go beyond answer accuracy: fact accuracy, temporal Q&A accuracy, causal-chain completeness, conflict-resolution correctness, experience-recall consistency, opinion-version explainability, context cost, and latency. Long-horizon tests should include cross-session, cross-time, and conflicting-evidence cases, not only single-turn recall.

    Governance: partition by user, tenant, and task; deletion and forgetting; sensitive-data redaction; access audit; provenance for opinions. Production memory needs to be auditable, revocable, and versioned.

    Practice and limits

    Start with a small loop: fact lookup, experience recall, and temporal Q&A; a minimal schema for the four networks and a write classifier; then graph retrieval and evidence grading; then opinion versions and causal edges. Do not chase a fully automatic knowledge graph first. Keep facts and beliefs unmixed, time filterable, and answers citable.

    Graph memory is not universal. It raises write and maintenance cost, is sensitive to extraction quality, and needs governance. For short, low-risk sessions, summaries plus vector recall still work. The value shows up in long-horizon, multi-session work that needs explanation and consistency.

    The stack is not a single model. It is epistemic layering plus engineering constraints: facts have evidence, experience has a first-person boundary, opinions have confidence and versions, and the relation/temporal graph connects them. That is how an agent can have hindsight instead of repeating the same cognitive blur in a longer context.