MemMesh — persistent, self-improving memory for AI agents. Get started →
API ReferenceBehavior Discovery

Behavior discovery API

POST /api/v1/projects/{projectId}/lattice/discover

Cluster the project’s subjects by their feature vectors and return the dense, cohesive clusters as candidate behaviors. See Behavior discovery for the concept.

The same surface is also exposed at POST /api/v1/projects/{projectId}/memory-intelligence/discover — identical request and response.

Request

All fields optional; the engine clamps to safe ranges.

{
  "simThreshold": 0.75,
  "minClusterSize": 3,
  "minStability": 0.6,
  "maxMembers": 50
}
FieldTypeNotes
simThresholdnumber [0,1]Min similarity to join a cluster. Default 0.75.
minClusterSizenumberBelow this a cluster is noise, not a behavior. Default 3.
minStabilitynumber [0,1]Drop clusters below this cohesion. Default 0.6.
maxMembersnumberCap on members returned per behavior. Default 50.

Response

{
  "behaviors": [
    {
      "label": "high-value frequent recurring of tonys-pizza",
      "prevalence": 0.32,
      "stability": 0.88,
      "size": 14,
      "memberSubjects": [ { "kind": "customer", "externalId": "acct-7" } ],
      "exemplarEvidence": ["rfm: rhi fhi mhi", "pattern: recurring_event", "entity: tonys-pizza"]
    }
  ],
  "subjectsAnalyzed": 44,
  "generatedAt": "2026-06-30T00:00:00Z",
  "durationMs": 12
}
FieldMeaning
labelDeterministic rule-based description (RFM band + frequency + dominant pattern + top entity).
prevalenceFraction of analyzed subjects in this cluster.
stabilityCohesion (mean intra-cluster similarity).
sizeTotal subjects in the cluster (may exceed memberSubjects length when capped by maxMembers).
memberSubjectsMembers, medoid first (capped by maxMembers).
exemplarEvidenceThe signals behind the label.

subjectsAnalyzed is the prevalence denominator.

⚠️

An empty behaviors array means the engine abstained — not enough signal to assert a behavior — never “this project has no behaviors”.

Naming discovered behaviors

The label is a deterministic, rule-based description. To upgrade it to a human name, run your own LLM over a discovered cluster and write the name back as metadata — the engine never calls an LLM itself during discovery. See Behaviors for the neuro-symbolic loop.

Example

curl https://app.memmesh.ai/api/v1/projects/$PID/lattice/discover \
  -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d '{ "minStability": 0.6 }'