Skip to main content

API Reference


AgentMemory

The primary interface for reading, writing, and managing agent memory.

Constructor


read

Returns the current version of the entry, or None if not found or below confidence threshold. The branch parameter selects which branch to read from (defaults to main).

write

Creates a new version of the entry. If the key already exists, the previous version is superseded (CoW). The memory_type parameter controls decay behavior — belief decays 2× faster, experience decays 1.5× slower. The branch parameter determines which branch the entry is written to (defaults to main). Every write is also logged as an event on the agent’s git-like timeline. The optional artifact_refs parameter links external blobs (S3 objects, files, URLs) to this entry. See ArtifactRef below.

list

Returns all current entries, optionally filtered by entity. Set include_superseded=True for full version history. The branch parameter selects which branch to list from.
Search across all entries with rich filters. depth controls progressive retrieval: 1 = Hot tier only, 2 = Hot + Warm, 3 = all tiers (default). When query is provided, the text is forwarded to the adapter for full-text search (Postgres tsvector). When recall_config is also set, returns ScoredEntry objects sorted by composite recall score with a breakdown dict.

graph_neighbors

Traverse the knowledge graph from an entity. Returns edges connecting the entity to other entities, agents, and outcomes. Multi-hop traversal is supported via depth > 1 (Postgres adapter uses recursive CTE). The Filesystem and S3 adapters return an empty list.

timeline

Returns the git-like event log for this agent. Every write, outcome, cross-agent read, and brain brief is recorded as an event. See Git-like Timeline for details.
Search by meaning using vector similarity. Requires an embedder to be configured.

watch

Register a callback for real-time change notifications. Returns a handle with a cancel() method.

commit_outcome

Record an outcome and update confidence on causal entries. If causal_entry_keys is None, uses auto-causal linking (all entries read in this session). The optional decision_summary parameter adds a human-readable description of the decision to the persisted trace. When called, the trace automatically captures:
  • Causal entry snapshots with full value, memory_type, written_by, and read_at timestamps
  • Query events from all search() and list() calls during the session, with parameters, result counts, and per-operation latency
  • Error events from any failed operations
  • Session timingsession_started_at, session_ended_at, session_duration_ms
  • State diff — entries created, updated, and confidence changes

history

Returns all versions of an entry, optionally filtered by time range. Entries are sorted by version ascending.

record_context

Record external context (tool call, API response, database query) in the causal chain without writing to storage. These appear in the external_contexts field of explain() output, making decision traces complete.

explain

Returns the causal chain for the current session: which AMFS entries were read, which external contexts were recorded, and their details. If outcome_ref is provided, labels the explanation with that reference. Returns:

briefing

Get a ranked briefing of compiled knowledge digests from the Memory Cortex. Returns pre-compiled Digest objects ranked by relevance to the given entity or agent context. If no Cortex is running, returns an empty list.

stats

Returns memory statistics.

MemoryEntry


ArtifactRef

Link memory entries to external blobs — model weights, datasets, logs, screenshots, or any binary artifact stored outside AMFS.
Example:

Provenance


OutcomeType


MemoryType


ProvenanceTier


ConflictPolicy


RecallConfig

When no embedder is configured or an entry lacks an embedding, the semantic component scores 0.0 and the remaining weights dominate.

ScoredEntry


MemoryTier


TierConfig


PriorityScorer

Computes S = (alpha * importance + beta * recency) * freq_boost * time_decay.

TierAssigner

Sorts entries by priority score and assigns them to Hot, Warm, or Archive based on configured capacities.

ImportanceEvaluator

Pass a custom evaluator to AgentMemory(importance_evaluator=...) to score entries on write. The Pro edition provides LLMImportanceEvaluator with 3-dimension scoring.

AdapterABC (new methods)


GraphEdge

Graph edges are materialized automatically:

GraphNeighborQuery


DigestType


Digest

A compiled knowledge digest produced by the Memory Cortex.

MemoryStats


MCP Tools

When used via MCP, the following tool signatures are exposed:

amfs_read

amfs_write

value is passed as a string. If it’s valid JSON, it’s parsed automatically; otherwise stored as a plain string.
Each item in artifact_refs should be a dict with uri (required), and optionally media_type, label, and size_bytes.
depth controls progressive retrieval: 1 = Hot only, 2 = Hot + Warm, 3 = all (default).

amfs_list

amfs_stats

amfs_commit_outcome

amfs_record_context

Record external context (tool call, API response) in the causal chain. Appears in amfs_explain() output.

amfs_history

Returns all versions of an entry, optionally bounded by a time range. Dates are ISO 8601 strings.

amfs_explain

Returns the causal read chain for the current session: which entries were read and their details.

amfs_retrieve

Find the most relevant memories for a natural language query. Blends semantic similarity, recency, and confidence into a single ranked list. Returns ScoredEntry-shaped results with score breakdowns. Requires an embedder for the semantic signal; without one, ranking uses recency and confidence only.

amfs_graph_neighbors

Explore the knowledge graph around an entity. Returns edges with relation types, confidence, and evidence counts. Use depth > 1 for multi-hop traversal (Postgres adapter only).

amfs_timeline

Returns the git-like event log for an agent. Every write, outcome, cross-agent read, and brain brief is recorded as an event. See Git-like Timeline.

HTTP REST API

When using the HTTP API server, the following REST endpoints are available:

Entries

All entry endpoints accept a branch parameter (query param for GET, body field for POST). Defaults to main. When targeting a non-main branch with the Pro branching module installed, the caller’s API key is checked against the branch access grants.

Agents & Timeline

Outcomes

Decision Traces

Observability

Admin — API Keys

Admin — Audit Log

Branching (Pro)

These endpoints are available when the amfs-branching module is installed: Authentication is via the X-AMFS-API-Key header. Set AMFS_API_KEYS to enable. Interactive API docs are available at /docs (Swagger UI).

Pro MCP Tools

The following tools are available only with the AMFS Pro MCP server.

amfs_critique

Run the Memory Critic to detect toxic, stale, contradictory, uncalibrated, and orphaned entries.

amfs_briefing

Get a compiled knowledge briefing — what you should know right now. Returns pre-compiled digests from the Memory Cortex ranked by relevance. Includes entity summaries, agent brain briefs, and external source summaries.

amfs_distill

Generate a distilled memory set for bootstrapping new agents.

amfs_validate

Validate a proposed memory write against safety checks (contradiction detection, temporal consistency, confidence thresholds).

amfs_retrieve

Multi-strategy retrieval combining semantic, keyword, temporal, confidence, and learned ranking signals via Reciprocal Rank Fusion. depth controls tier scope (same as amfs_search). When a learned model is trained (via amfs_retrain), it automatically contributes to ranking.

amfs_retrain

Train (or retrain) the learned ranking model from outcome data. Requires at least 20 outcome-linked entries. Returns training metrics including accuracy, sample counts, and feature importances. Once trained, the model enhances amfs_retrieve results automatically.

amfs_calibrate

Learn optimal confidence multipliers from historical outcome data. Returns calibrated multipliers and estimated decay half-life. Set per_entity=true to also produce entity-specific overrides.

amfs_export_training_data

Export decision traces as fine-tuning datasets. Format options: "sft" (supervised fine-tuning), "dpo" (direct preference optimization), "reward_model" (reward model training). See the ML Layer guide for format details.

amfs_record_llm_call

Record an LLM call in the current decision trace. Captures model, provider, token counts, cost, latency, and sampling parameters. Aggregated as total_llm_calls, total_tokens, and total_cost_usd in the trace.