Skip to main content
Glama

memory_relate

Create directional links between memories to record supersedes, caused_by, contradicts, or containment facts that similarity search cannot infer, improving related recall.

Instructions

Create a directional link between two memories. Relations are used by spreading activation (recalling one memory wakes its related cluster) and are returned when include_related=True in memory_recall.

An edge must encode something search cannot infer. Recall already ranks by hybrid text + semantic similarity, so "these two memories are about the same topic" is knowledge the index has for free. What only a relation can record is direction and time: which memory REPLACED which, what CAUSED what, what CONTRADICTS what, what CONTAINS what. Prefer, in this order: supersedes, contradicts, caused_by, parent_of/child_of. Reach for related_to only when a genuine connection exists that none of those describe - it is the fallback, not the default.

Quality over volume: spreading activation surfaces at most 3 neighbours per seed memory, and it weights by relation type - a directional edge outranks related_to, so on any memory with more than 3 edges the related_to ones are what lose their slot. A vague edge is therefore not merely low-value, it is likely to never fire at all; and precise edges still compete against each other for those 3 slots, so a handful of them retrieves better than a dense mesh. If you cannot name the directional fact an edge records, do not create it.

A mislabelled edge is repairable: memory_unrelate retypes or removes one.

source_id is the memory making the claim about target_id. relation_type must be one of: supersedes (source replaces target), contradicts (conflicting claims), caused_by (source was caused by target), parent_of (source contains target), child_of (source belongs to target), related_to (fallback: a real connection none of the above captures).

Batch by passing edges instead of the single-edge fields - an array of up to MAX_BATCH_EDGES objects, each with source_id, target_id and relation_type (all required; there is no default type for a batch op):

[{"source_id": "a", "target_id": "b", "relation_type": "supersedes"},
 {"source_id": "a", "target_id": "c", "relation_type": "caused_by"}]

All-or-nothing, same as memory_unrelate's batch: every op is validated (both memories exist, the type is real, no self-edge) before anything is written, and the whole set is applied in one transaction, so a failure on op k leaves ops 0..k-1 unwritten too - a half-applied relation set is the graph state hardest to notice and hardest to repair. Relate is idempotent on (source, target, type), so each result reports created or exists rather than pretending a no-op was a write. Pass either edges or the single-edge fields, never both.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
edgesNo
source_idNo
target_idNo
relation_typeNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed11 schema fields changedv0.19.0
    • addedInput schema / properties / edges
      Added value: +{
      +  "anyOf": [
      +    {
      +      "items": {},
      +      "type": "array"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Edges"
      +}
    • addedInput schema / properties / relation_type / anyOf
      Added value: +[
      +  {
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • addedInput schema / properties / relation_type / default
      Added value: +null
    • removedInput schema / properties / relation_type / type
      Removed value: -"string"
    • addedInput schema / properties / source_id / anyOf
      Added value: +[
      +  {
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • addedInput schema / properties / source_id / default
      Added value: +null
    • removedInput schema / properties / source_id / type
      Removed value: -"string"
    • addedInput schema / properties / target_id / anyOf
      Added value: +[
      +  {
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • addedInput schema / properties / target_id / default
      Added value: +null
    • removedInput schema / properties / target_id / type
      Removed value: -"string"
    • removedInput schema / required
      Removed value: -[
      -  "source_id",
      -  "target_id",
      -  "relation_type"
      -]
  2. First observedv0.3.1

TDQS

A4.9/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full behavioral burden and does so: idempotency on (source, target, type) with created/exists results, all-or-nothing transactional batch semantics with validation ordering, self-edge and existence checks, and the 3-neighbour spreading-activation cap with relation-type weighting. These are non-obvious traits that materially affect how an agent should call the tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded and well-organized with bold section labels, and the parameter enumeration and batch example are directly actionable. It is nonetheless long (roughly 350 words) and the 'Quality over volume' paragraph restates the retrieval-slot point more than once, so it is dense rather than tight.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations, no output schema and 0% schema coverage, the description fills every gap an agent needs: input shapes, batch contract, failure/transaction behavior, idempotency outcome reporting, and the downstream effect of edge quality. Nothing required for correct invocation is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must supply all parameter meaning, and it does: source_id vs target_id directionality is defined, every relation_type value is enumerated with a semantic gloss, and the edges batch array documents each required field plus a concrete example and the mutual exclusion with single-edge fields.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Create a directional link between two memories') and immediately distinguishes the tool from siblings by naming memory_unrelate and the recall paths (spreading activation, include_related=True) that consume its output. An agent can identify this as the graph-edge creation tool without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit when-to-use guidance with a preference ordering (supersedes > contradicts > caused_by > parent_of/child_of > related_to), states when NOT to create an edge ('these two memories are about the same topic' is free from the index), and gives a hard exclusion rule ('If you cannot name the directional fact an edge records, do not create it'). Routing to memory_unrelate for repair is also named.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.