engram_context
Construct a formatted memory block for system prompts. Selects relevant memories by semantic query or top memories by frequency, truncates to fit token budget, and returns a single string in markdown, XML, JSON, or plain text.
Instructions
Build a single pre-formatted context block from relevant memories, ready to inject into a system prompt at session start. With a query it selects semantically relevant memories; with no query it returns the top memories by access frequency and recency. The block is rendered in the requested format and truncated to fit max_tokens. Returns: one formatted string (not an array) — contrast with engram_recall, which returns raw scored memory objects. Use when you want drop-in context text; use engram_recall when you need structured results to reason over.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum memories to include, 1–25 (default 10). | |
| query | No | Optional query to select relevant memories. If omitted, returns top memories by access frequency and recency. | |
| format | No | Output format (default markdown): markdown=human-readable headings, xml=structured tags, json=machine-parseable, plain=raw text. | markdown |
| namespace | No | Namespace to pull memories from (default "default"). | default |
| categories | No | Optional list of memory types to include, e.g. ["preference", "fact"]; omit for all. | |
| max_tokens | No | Approximate token budget for the block; lower-priority memories are dropped to fit (default 1000). | |
| include_metadata | No | If true, append each memory's id and confidence to the output (markdown and xml formats only). Default false. |