Skip to main content

Module context

Module context 

Source
Expand description

Context memory contract shared by every runtime tier.

Historically this lived in aria-agent-memo as MemoStore (local/embedded). The contract is lifted into agent-core so the cloud can ship a Postgres + pgvector implementation (see crates/aria-agent-cloud/src/context/pg.rs) while the on-device SDK keeps the aria memo implementation (aria-agent-memo). The two share:

See docs/adr/0010-context-storage-pgvector.md.

Modules§

embed
Local lightweight embedding + cosine similarity for vector recall.

Structs§

CompositeContextStore
The both backend: a local (aria memo) store plus a cloud store.
ContextFragment
A single unit of remembered context.
MemoryContextStore
In-process ContextStore used by tests and by the SDK default.
RecallQuery
Query used by ContextStore::recall.

Enums§

ContextError
FragmentKind
Kinds of context fragments a store can hold.
MemoryBackend
Where a memory context lives.

Constants§

EMBED_DIM
Dimension of the dense embedding produced by embed::LocalEmbedder.

Traits§

ContextStore
The unified context-memory contract. Everything that needs conversational or long-term context goes through this trait.

Functions§

ensure_embedding
Embed a fragment’s content when it carries no vector yet. Shared by every backend so stored vectors stay comparable.
keyword_score
Keyword relevance of frag against query_text:
merge_fragments
Merge results from two backends: a fragment is a duplicate when either its id or its key was already seen; the freshest copy wins.
now_ms
rank
Score, sort (descending) and truncate candidates to top_k. Fragments that score 0.0 are dropped — an empty query therefore recalls nothing.
score_fragment
Blend semantic (vector) similarity with the keyword score: 0.7 * cosine + 0.3 * keyword. Pure keyword when a vector is missing on either side.