Back to Openviking

Memory

docs/en/api/16-memory.md

0.4.135.6 KB
Original Source

Memory

Memory is produced by session commit or explicit extraction, stored in the user memory namespace, and consumed through the content, file-system, and retrieval APIs.

Built-in Memory Types

CategoryLocationDescription
profileuser/memories/profile.mdUser profile information
preferencesuser/memories/preferences/User preferences by topic
entitiesuser/memories/entities/Important entities (people, projects)
eventsuser/memories/events/Significant events
identityuser/memories/identity.mdAssistant identity and self-introduction
souluser/memories/soul.mdAssistant principles, boundaries, style, and continuity
casesuser/memories/cases/Trainable and evaluable task cases
trajectoriesuser/memories/trajectories/Reusable operation contracts
experiencesuser/memories/experiences/Reusable execution insights
toolsuser/memories/tools/Tool usage knowledge and best practices
skillsuser/memories/skills/Skill execution knowledge and workflow strategies

These are the enabled built-in types. Deployments can extend or override them with custom memory templates.


API Reference

recall()

Deprecated: /api/v1/search/recall is now a thin preset over /api/v1/search/search with mode="context" and carries no assembly logic of its own. New integrations should target the context face directly; the v1 field aliases are accepted only here and will be removed in the next minor release. Responses carry a Deprecation: true header.

Search each memory type independently and assemble a bounded memory block that can be injected directly into Agent context. Relative to the context face, /recall overlays purpose="coding", the v1-compatible score_threshold=0.1, dedup_turns=5 when a session_id is present, and query_expansion="auto". Coding Agent plugins explicitly send score_threshold=0.35; the public /recall default remains 0.1 so an unchanged request does not silently lose results after upgrading. Omitting quotas keeps v1's bucket defaults (events=10, entities=10, preferences=3, experiences=0); sending "quotas": null explicitly opts into the purpose preset ratios instead.

v1 field folding

v1 fieldFolds intoNotes
max_charsmax_tokens = max_chars / 465001625; an explicit max_tokens wins
min_scorescore_thresholdWhen neither is sent, the v1-compatible default 0.1 applies
render: trueNo detail pinDefault behavior: each category takes its default tier
render: falseReturns entries only, rendered empty
render: "compact"detail="abstract"The prototype-era compact mode; pins every category
v1 quotas keysOverlaid on the v1 bucket defaultsKey names unchanged; a partial map keeps the other buckets

Context-face parameters (max_tokens, detail, dedup_turns, session_id, query_expansion, exclude_uris, purpose, rewrite, rewrite_max_bullets) are also accepted here, so plugins can transition smoothly on deployments that have not been upgraded yet.

HTTP API

http
POST /api/v1/search/recall
Content-Type: application/json
bash
curl -X POST http://localhost:1933/api/v1/search/recall \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENVIKING_API_KEY" \
  -d '{
    "query":"API documentation preferences",
    "quotas":{"events":5,"entities":5,"preferences":3,"experiences":2},
    "max_chars":6500,
    "peer_scope":"all"
  }'

MCP

text
recall(
  query="API documentation preferences",
  quotas={"events": 5, "entities": 5, "preferences": 3, "experiences": 2},
  max_chars=6500,
  peer_scope="all"
)

Response

The response shape matches the context face (flat entries, flat XML in rendered):

json
{
  "status": "ok",
  "result": {
    "entries": [
      {
        "uri": "viking://user/default/memories/preferences/api-docs.md",
        "category": "preferences",
        "score": 0.82,
        "detail": "full",
        "text": "User prefers API docs to show HTTP, SDK and CLI examples together.",
        "origin": "self"
      }
    ],
    "rendered": "<memory uri=\"viking://user/default/memories/preferences/api-docs.md\" type=\"preferences\" score=\"0.82\" detail=\"full\">\nUser prefers API docs to show HTTP, SDK and CLI examples together.\n</memory>",
    "digest": "",
    "stats": {
      "quotas": {"events": 5, "entities": 5, "preferences": 3, "experiences": 2},
      "candidates": 4,
      "returned": 1,
      "dropped": 0,
      "max_tokens": 1625,
      "used_tokens": 96,
      "tier_counts": {"full": 1},
      "peer_scope": "all",
      "origins": {"actor_peer": 0, "self": 1, "other_peer": 0},
      "deprecated": {
        "endpoint": "/api/v1/search/recall",
        "successor": "/api/v1/search/search",
        "successor_body": {"mode": "context"},
        "aliases_used": ["max_chars"]
      }
    }
  }
}

See Retrieval - search(mode="context") for field meanings. Shape changes relative to v1: typecategory, modedetail, content/summarytext, rendered moves from three-level nesting to flat <memory> tags, and rank is no longer returned.

The public Python, TypeScript, Go SDKs and the ov CLI do not wrap this endpoint yet, so this section shows only the HTTP tab plus the MCP call that does exist.