The Context Engine Studio is now open source.  View on GitHub →

Read Memories and Their Links to Facts

List the memories learned about a patient and follow each one to the facts it speaks to.

Read the memories the Context Engine learned from a patient's sessions, then follow each one to the facts in the patient's record it speaks to. A memory is attributed to the person who said it, as described in Attribution, so it stays apart from the facts formed from systems of record.

Prerequisites

List the memories

List the memories one session produced:

bash
curl "https://<workspace-id>.w.clinia.cloud/v1/patients/{patientId}/sessions/{sessionId}/memories" \
  -H "Authorization: Bearer <access-token>"
json
{
  "data": [
    {
      "id": "lm_tz4a98xxat96iws9zmbrgj3a",
      "type": "adherence",
      "content": "Stopped taking the Empagliflozin a few weeks ago, it was upsetting their stomach.",
      "sessionId": "session-456",
      "createdAt": "2026-07-27T14:03:02.000Z"
    }
  ],
  "meta": { "total": 1, "page": 0, "perPage": 100 }
}

To list memories across every session of the patient, query the learned_memory nodes of the patient graph. The filter takes an optional type and an optional sessionId:

bash
curl -X POST "https://<workspace-id>.w.clinia.cloud/v1/patients/{patientId}/graph/nodes/learned_memory/query" \
  -H "Authorization: Bearer <access-token>" \
  -H "Content-Type: application/json" \
  -d '{ "filter": { "type": { "eq": "adherence" } } }'

Each node carries the memory under payload, with its type, its content and the sessionId it was said in. Both calls return the same lm_ id, sort newest first, and paginate with page and perPage.

Find the facts a memory speaks to

Only symptom memories, which link to conditions, and adherence memories, which link to medications, can be linked to facts. concern and preference memories are never linked.

List the relationship edges that touch the memory:

bash
curl "https://<workspace-id>.w.clinia.cloud/v1/patients/{patientId}/graph/edges/relationship/items?touching={memoryId}" \
  -H "Authorization: Bearer <access-token>"
json
{
  "data": [
    {
      "type": "relationship",
      "id": "rel_q8w2e4r6t8y0u2i4o6p8a0s2",
      "createdAt": "2026-07-27T14:03:09.000Z",
      "updatedAt": "2026-07-27T14:03:09.000Z",
      "from": { "type": "learned_memory", "id": "lm_tz4a98xxat96iws9zmbrgj3a" },
      "to": { "type": "fact", "id": "fct_k3j5h7g9f1d3s5a7p9o1i3u5" },
      "payload": {
        "type": "conflicts",
        "source": "llm_inferred",
        "confidence": 0.9,
        "reasoning": "The patient reports having stopped Empagliflozin, while the record lists it as active.",
        "attributes": { "fields": ["status"] }
      }
    }
  ],
  "meta": { "total": 1, "page": 0, "perPage": 100 }
}

Each edge runs from the memory to a fact. payload.type says how the memory relates to that fact. The possible values are:

  • corroborates - The memory agrees with the fact. attributes.fields names the fields it agrees with.
  • enriches - The memory adds information the fact does not carry. It names no fields.
  • conflicts - The memory contradicts the fact. attributes.fields names the fields it contradicts.

payload.reasoning explains the link in a sentence. payload.confidence scores it between 0 and 1. A memory can hold several links to the same fact, such as one that corroborates its dose and one that contradicts its status, with at most one link of each type.

Open the fact

Open the fact the edge points to:

bash
curl "https://<workspace-id>.w.clinia.cloud/v1/patients/{patientId}/graph/nodes/fact/items/{factId}" \
  -H "Authorization: Bearer <access-token>"
json
{
  "type": "fact",
  "id": "fct_k3j5h7g9f1d3s5a7p9o1i3u5",
  "payload": {
    "type": "medication",
    "display": "Empagliflozin 10 MG Oral Tablet",
    "status": "active"
  }
}

The response is shortened to the fields this example needs. The fact still reads active, because a link never changes the fact it points to, even when the memory contradicts it.

Gotchas

  • A symptom or adherence memory has no link when nothing in the patient's record matched it, or when its ingestion settled as partial because some links could not be made.
  • A link can appear after the session, because a condition or medication fact that arrives later is compared with the memories already stored.
  • Links are recomputed when a fact they point to changes, so a link's type can differ from one ingestion to the next.
  • An agent reads the same memories in the virtual file system, as described in How Interactions Become Memory.

Next steps

On this page