Skip to content
runward
runward
Product
Who it is for
Trust
Documentation
News
Try it on an example Talk to us

Docs · The doctrine · Section 06

Memory and context engineering

Memory is the primary form of an agent's state, and the main determinant of both quality and cost. An agentic system is not just a loop that calls tools: it is a loop that remembers, forgets, and contextualizes itself. This section elevates memory and context engineering to the rank of a pillar, on par with orchestration and the model boundary.

Guiding principle of this section: the model boundary does not apply only to generation, it also applies to retrieval. Not everything is retrieved, all the time. The decision of what to load is deterministic, not entrusted to the model.

A single store is not enough

No memory technology covers all needs on its own. Several stores are therefore composed, each with its own role, behind ports, with graceful degradation if one is absent.

Memory roleWhat it carriesCharacteristic
Memory sourceFacts and memories with enriched metadataSimple write and read, rich metadata
Knowledge graphRelations between memories, entities, eventsAutomatic linking, vector search, traversal
Working memoryCurrent session state, presenceReal time, low latency
Archival memoryDeep, rarely accessed historyVoluminous, queried only when needed

The frugality of tiered retrieval

The heart of memory engineering is not querying everything at every turn. A deterministic decision, based on the detected complexity and intent, chooses the retrieval depth. This is the model boundary applied to data retrieval.

detected intent + complexity · deterministic, no model call 0 LEVEL 0 · bare minimumsession state, presence, today's events · when: greeting, acknowledgment 1 LEVEL 1 · standard context+ graph search, recent memories, working memory · when: task, question 2 LEVEL 2 · deep+ archival memory, enrichment by multi-hop graph traversal Refinements: a recall intent forces level 2; a greeting forces level 0; the router targets the useful sources (for example, calendar to the graph only).

The effect is twofold: the latency of a trivial turn collapses, and the context cost concentrates where it creates value. Most turns do not deserve deep retrieval, and the system decides this without burning a model call to find out. At every level, the same value score (recency, frequency, relevance, importance, centrality) orders what surfaces. Its weighting is not universal: it is calibrated per domain and verified like any deterministic gate, rather than set by decree.

Forgetting is a first-class function

A memory that never forgets becomes noise. But forgetting is not erasing: by default, it means ceasing to surface a memory, not destroying it. Forgetting happens at retrieval, governed by a value score, and physical deletion remains the exception. Decay with reinforcement at each access merely follows the forgetting curve described by Ebbinghaus in 1885: what is not called upon fades, what is recalled is reinforced.

MechanismPrincipleEffect
Value scoreA score combines recency, access frequency, relevance, importance, and centrality in the graph. Age is only one signal, modulated by reinforcement and salience.What is relevant surfaces; the rest withdraws from view, without being destroyed.
Invalidation, not deletionA contradicted fact is marked invalid with its two times (learned, valid), instead of being deleted. This is the bi-temporal model.The history is kept: what is true now, and what was true before.
ConsolidationNear-duplicates merge, close episodes are summarized into higher-level facts.Forgetting is often compressing: less volume, as much meaning.
Fact immunityStable facts and identity invariants are flagged and exempted from decay.What constitutes identity never fades.

Physical deletion, for its part, is reserved for low-value derived data, for example old, invalidated associative links, under an explicit retention rule, and for mandated erasure only. Demoting to a cold archive is always preferred to destroying. Importance, the central signal of this score, does not cost a model call: it is derived from deterministic signals, access frequency, centrality, category, novelty, and from a label emitted as a by-product of the asynchronous extraction already performed outside the turn. The model boundary, applied all the way down to the computation of importance. Consolidation, for its part, remains derived and reversible: the original survives in the immutable log (§07), the source of truth is never consolidated, and each summary keeps an explicit link to the raw facts it derives from, so that an audit can always trace back to the origin, even after working memory has forgotten the detail. Finally, any retrieved content enters the context as untrusted data, never as an instruction: memory is also an indirect injection surface (§11).

Linking happens on its own

Rather than asking the user to tag and organize, the system automatically links memories to one another and to entities, by similarity above a threshold. The connections emerge in the graph. The threshold alone is not enough: it produces weak edges and hub nodes; weakly supporting links must be pruned, not only invalidated ones, to preserve the graph's precision. Deep retrieval exploits these links through a traversal of a few hops around the direct results.

The heavy work happens outside the interactive turn

Fact extraction, consolidation of related memories, graph updates, session summaries: these costly operations do not happen while the user is waiting. They are delegated to a background, asynchronous process, triggered after the turn. Memory tidies itself while the system is at rest, not while it is responding.

Validity over time, the heart of the bi-temporal model

Decay handles age, but not validity. A fact true yesterday may be false today. Hence the two times carried by each fact: when it was learned and when it is valid. This is what makes it possible to invalidate without destroying, and to reason about how information evolves, querying what is true now or what was true at a given date. Coupled with the immutable log of Section 07, the bi-temporal model reconciles the forgetting of reasoning with the traceability of audit. When two facts contradict each other, the most recently learned one invalidates the older, unless a more authoritative source says otherwise; both remain in the history.

Talk to us

Tell us who you are, and we will get back to you.

Your details are recorded by Another Framework, publisher of runward, to get back to you. They are neither sold nor shared, and are deleted three years after our last exchange. To see or delete them: contact@runward.dev.