Search Memories
montycat_semantic_searchSearch stored memories by meaning, keyword, or both, returning top-ranked matches with relevance scores to recall facts and context for RAG and agent memory.
Instructions
Search stored memory by MEANING, by KEYWORD, or both.
Use this to recall relevant facts, documents, or past context for RAG and agent memory. Returns the top matches ranked by relevance, each with its key, a score, and the stored value.
Ranking modes (mode):
"semantic" (default) — vector similarity. Finds a memory whose wording differs from the query. Scores are cosine similarity in [-1, 1].
"keyword" — BM25 over the stored text. Use it when the query contains an exact term that must appear: an identifier, error code, or file name. BM25 scores are unbounded and comparable only within one query.
"hybrid" — runs both and fuses them with reciprocal rank fusion. The safest default when a query mixes meaning with an exact term. Scores are normalized to [0, 1]. Keyword and hybrid need a Montycat Semantic engine >= 1.3.4; older engines reject the request rather than silently returning semantic-only results.
Narrowing is separate from ranking: filters, since, and until restrict
WHICH memories are ranked — a hard AND over indexed fields — and never
change the order within that set. Combine them freely: "what did we decide
about the index" + since yesterday + filters={"project": "montycat"} is
one call. A filter matching nothing returns [].
Args:
query: Natural-language description of what to recall. May be empty
when vector supplies a precomputed query embedding.
mode: Ranking strategy — "semantic", "keyword", or "hybrid".
vector: Optional precomputed query embedding, for the vector half of
"semantic" and "hybrid". It must match the keyspace's enrolled
embedding space and dimensions; when set, the engine does not
embed query.
scope: Owner/user id to scope recall to (searches only that owner's memory,
keyspace mem_). Use "shared" for the common keyspace.
keyspace: Explicit keyspace override (advanced; bypasses scope).
limit: Max number of results (default 5).
min_score: Optional relevance floor; drops weak matches. The valid range
follows the mode: [-1, 1] semantic, [0, 1] hybrid, >= 0
keyword.
filters: Optional metadata constraints, e.g. {"project": "x"} — only
memories whose indexed fields equal these values are ranked.
timestamp_field: Native Timestamp index field to constrain, e.g.
"event_time". Defaults to the auto-stamped "_created_at".
Use the index field name, not "timestamps.event_time".
The field must be stored as a Timestamp index; an
ordinary JSON string field is not sufficient.
since: Lower time bound for timestamp_field (ISO-8601, UTC).
until: Upper time bound for timestamp_field (ISO-8601, UTC).
Bounds use the SDK's native Timestamp after/before/range queries.
Do not also put timestamp_field in filters when supplying bounds.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | semantic | |
| limit | No | ||
| query | No | ||
| scope | No | ||
| since | No | ||
| until | No | ||
| vector | No | ||
| filters | No | ||
| keyspace | No | ||
| min_score | No | ||
| timestamp_field | No | _created_at |