POST /agentmemory/smart-search
Runs a hybrid three-stream search across all memories and observations. This is the primary search endpoint — it combines keyword matching (BM25), semantic similarity (vector), and entity-linked knowledge graph traversal, then fuses the ranked results.You must provide either a
query string or an expandIds array. Providing both is allowed — expandIds expands the context around specific observations while query runs the full retrieval pipeline.Request
Natural language search query. Agent Memory tokenizes this for BM25, embeds it for vector similarity, and extracts named entities for graph traversal — all in a single call.
Array of observation IDs (strings or
{ obsId, sessionId } objects) to expand context around. Used internally by the viewer and MCP tools to fetch neighbouring observations.Scope the search to a specific project. Omit to search across all projects.
Maximum number of results to return (default
10). Must be a positive integer.When
true, also searches the lessons store (crystallized learnings from past sessions) and merges them into the results.Override the agent scope for this search. Useful when routing queries on behalf of a specific agent in multi-agent setups. You can also pass
?agentId=<id> as a query parameter.Bias results toward observations from a specific session.
Response
Ranked array of matching observations. Each result includes
obsId, sessionId, title, type, score (combined RRF score), and timestamp.POST /agentmemory/search
A lower-level search endpoint that gives you more control over output format and token budget. Returns observations in one of three formats.Search query string. Must be non-empty.
Max results to return. Must be a positive integer.
Scope to a project.
Working directory — biases results toward files under this path.
Output format. One of:
full— complete observation objectscompact— titles and scores onlynarrative— prose summary of results
Maximum tokens for the response. When set, Agent Memory trims results to fit within the budget.
POST /agentmemory/context
Generates a formatted context block ready to inject directly into an agent prompt. Unlike raw search, this endpoint applies token budgeting, deduplication, and formatting so the output is immediately usable.Request
The current session ID. Agent Memory uses this to avoid including observations from the current session in the recalled context.
Project name to recall context for.
Maximum token budget for the returned context block (default
2000). Must be a positive integer. Agent Memory ranks and trims memories to fit within this budget.Response
Formatted context block as a markdown string. Inject this into the agent’s first turn or system prompt.
Approximate token count of the returned context.
POST /agentmemory/enrich
Enriches one or more file paths with related memories, past edit history, observed bugs, and relevant concepts. Use this to give the agent deep context about a specific file before it reads or edits it.Request
Current session ID.
Array of file paths to enrich. Must be non-empty. All paths must be strings.
Additional search terms to broaden the enrichment query beyond the file path itself.
The tool that triggered this enrichment (e.g.
"Read", "Edit"). Used for diagnostic tracing.Project name for scoped recall.
Response
The response includes per-file summaries, related memories, past edit history from observations, known issues, and matched concepts.POST /agentmemory/file-context
Returns a focused context block for specific files within a session. Lighter than/enrich — returns raw observation context for the given files without the full enrichment pass.
POST /agentmemory/graph/query
Traverses the knowledge graph starting from a node, querying by node type, or running a text search across node names. Returns matching nodes and their edges up to the specified depth.Request
- Start from a node
- Query by type
- Text search
ID of the graph node to start traversal from. Returns all nodes reachable within
maxDepth hops.Filter results to a specific node type. One of:
file, function, concept, error, decision, pattern, library, person, project, preference, location, organization, event.Text query matched against node names.
Maximum traversal depth from the start node (default
2).Maximum number of nodes to return.
Pagination offset.
Response
Matching graph nodes. Each node has an
id, type, name, properties, sourceObservationIds (for provenance tracing), and createdAt.Edges connecting the returned nodes. Edge types include:
uses, imports, modifies, causes, fixes, depends_on, related_to, prefers, blocked_by, rejected, avoids, optimizes_for, and more.true when the result was capped by limit. Use offset to page through the rest.true when the response was served from the precomputed top-degree snapshot rather than a live graph enumeration. Snapshots are rebuilt via POST /agentmemory/graph/snapshot-rebuild.Graph Management
| Endpoint | Method | Description |
|---|---|---|
/agentmemory/graph/stats | GET | Returns aggregate counts: total nodes, edges, node type breakdown. |
/agentmemory/graph/build | POST | Backfills the graph from all existing compressed observations. Pass { "batchSize": 25 } to control batch size. |
/agentmemory/graph/snapshot-rebuild | POST | Rebuilds the top-degree snapshot used to serve large-corpus queries without timeout. |
/agentmemory/graph/reset | POST | Wipes graph state without touching observations. Use when the graph is corrupt or too large to rebuild safely. |
/agentmemory/graph/extract | POST | Extracts graph nodes and edges from a batch of observations. Pass { "observations": [...] }. |
GET /agentmemory/config/flags
Returns the current runtime feature flags, LLM provider kind, and embedding provider. Use this to check which optional features are active before calling feature-gated endpoints.Response
The running Agent Memory version.
Detected LLM provider kind (
anthropic, openai, gemini, openrouter, minimax, noop)."embeddings" if an embedding provider is configured, "none" if BM25-only mode is active.Array of feature flag objects. Each flag includes
key, label, enabled (current state), needsLlm (whether an LLM provider is required), and enableHow (exact instruction to turn it on).POST /agentmemory/timeline
Returns a chronological slice of observations centred on a given anchor timestamp or observation ID. Useful for replaying what happened around a specific point in time.ISO timestamp or observation ID to centre the timeline around.
Scope to a project.
Number of observations to include before the anchor.
Number of observations to include after the anchor.
POST /agentmemory/patterns
Detects recurring patterns across all sessions for a project — common code idioms, repeated workflows, and frequently co-occurring concepts.GET /agentmemory/diagnostics/followup
Returns a directional signal for the follow-up query rate — the proportion of searches followed by another search within a short window. High follow-up rates may indicate recall quality issues.The follow-up rate is a directional signal only — it overcounts on legitimate query refinement (when you intentionally narrow a search). Tune the window with
AGENTMEMORY_FOLLOWUP_WINDOW_SECONDS.