Skip to content

Short-term context

"Short-term" here means the context that lives only for the duration of one or a few turns: the prior conversation, the most-recent target snapshot, recent activity frames. It is short-term for the model — the underlying records are still durable in the store.

Sources of short-term context

SourceWhere it comes from
Prior messagesAgentsStore.loadMessages(sessionId) — full transcript so far
Target snapshotloadSessionState(sessionId, 'snapshot') — captured at session start
Most-recent memoriesMemoryActor.memory.search over the actor scope (default 10)
Active planMemoryActor.plan.active(mount) — if any
Recent eventsonly when profile.context.includeRecentEvents = true (the monitor profile)

How it's assembled

OraclePromptBuilder.buildResumeContext (and the equivalent fresh-build path) composes:

SYSTEM PROMPT
  | profile.systemPrompt (or generated from purpose)
  | skill bundle (deterministic order)
  | target snapshot (rendered tree)
  | (optional) recent memories matched to the prompt
  | tool list (JSON Schema)

USER MESSAGES
  | prior messages from session
  | the new prompt

The order is fixed; the per-section content is profile-driven. The four prompt formats (legacy / edn / sexp / markdown) shape the rendering of these sections, not their content.

Memory cascade for short-term

profile.context.memoryScope (AgencyProfile.ts:3) decides the cascade:

ScopeWhat memory is included on each turn
nonenothing — short-term context contains zero memories
sessionmemories saved during this session only
instancememories tied to this concrete actor instance
actormemories at the actor level (default for default profile)
classmemories saved for any actor of the same class
subtreememories from the actor and all its descendants
profilememories saved under this profileKey (cross-target — used by propose and edit)
globalunlimited cascade — admin-level

The cascade is enforced in searchMemoriesCascade (AgentsStore.ts:251-259) using memoryBelongsToCascade.

What's NOT short-term

  • Plans. Plans persist across sessions until completed. They live in plans with active/completed status.
  • Embeddings. Once generated, embeddings persist with the memory. They are not regenerated each turn.
  • Audit trail. Every cross-actor memory access is logged in memory_access_log, regardless of how short-term the surrounding turn was.

See also

Source: projects/matrix-3/packages/agents/src/profiles/AgencyProfile.ts:3-46 (memory scopes), projects/matrix-3/packages/agents/src/AgentsStore.ts:251-265 (cascade search).