Skip to content

Memory Types

Membrane defines five memory types, each with a dedicated payload schema. Every MemoryRecord has a type field that determines which payload structure it carries. See Schemas for the full MemoryRecord base type and related structures.

Episodic Memory

Type value: episodic

Episodic memory captures raw experience as a time-ordered sequence of events. It is intentionally short-lived and provides evidence for later consolidation into durable knowledge.

Key Rule

Episodic payloads are append-only. Semantic correction of episodic memory is forbidden -- the raw experience must be preserved as-is.

Payload Structure

json
{
  "kind": "episodic",
  "timeline": [
    {
      "t": "2025-01-15T10:30:00Z",
      "event_kind": "user_input",
      "ref": "session-001/msg-1",
      "summary": "User asked about deployment options"
    },
    {
      "t": "2025-01-15T10:30:05Z",
      "event_kind": "tool_call",
      "ref": "session-001/tool-1",
      "summary": "Called deploy-check tool"
    }
  ],
  "tool_graph": [
    {
      "id": "t1",
      "tool": "deploy-check",
      "args": { "env": "production" },
      "result": { "status": "ready" },
      "depends_on": []
    }
  ],
  "environment": {
    "os": "linux",
    "os_version": "6.1",
    "working_directory": "/home/user/project"
  },
  "outcome": "success",
  "artifacts": ["logs/deploy-check-001.log"]
}

Fields

FieldTypeRequiredDescription
kindstringYesAlways "episodic"
timelinearrayYesTime-ordered sequence of TimelineEvent objects
tool_grapharrayNoTool call nodes with dependency edges
environmentobjectNoOS, versions, working directory snapshot
outcomestringNosuccess, failure, or partial
artifactsarrayNoReferences to external logs, screenshots, files

Working Memory

Type value: working

Working memory captures the current state of an ongoing task. It enables resumption across sessions or devices and is freely editable. Working memory is discarded when the task ends.

Payload Structure

json
{
  "kind": "working",
  "thread_id": "thread-abc-123",
  "state": "executing",
  "active_constraints": [
    {
      "type": "budget",
      "key": "max_tokens",
      "value": 4096,
      "required": true
    }
  ],
  "next_actions": [
    "Run integration tests",
    "Update deployment manifest"
  ],
  "open_questions": [
    "Which region should we deploy to?"
  ],
  "context_summary": "Deploying v2.1 to production with zero-downtime strategy"
}

Fields

FieldTypeRequiredDescription
kindstringYesAlways "working"
thread_idstringYesIdentifier for the current thread or session
statestringYesplanning, executing, blocked, waiting, or done
active_constraintsarrayNoConstraints on task execution
next_actionsarrayNoPlanned next steps
open_questionsarrayNoUnresolved questions
context_summarystringNoHuman-readable summary of current context

Semantic Memory

Type value: semantic

Semantic memory stores stable, revisable facts as subject-predicate-object triples. It supports coexistence of multiple conditional truths and tracks revision history.

Payload Structure

json
{
  "kind": "semantic",
  "subject": "user",
  "predicate": "prefers_language",
  "object": "Python",
  "validity": {
    "mode": "global"
  },
  "evidence": [
    {
      "source_type": "observation",
      "source_id": "obs-001",
      "timestamp": "2025-01-10T09:00:00Z"
    }
  ],
  "revision_policy": "replace",
  "revision": {
    "status": "active"
  }
}

Validity Modes

Semantic facts support three validity modes:

  • global -- the fact is universally valid
  • conditional -- valid only under specific conditions (stored in conditions map)
  • timeboxed -- valid within a time window (start and end timestamps)

Fields

FieldTypeRequiredDescription
kindstringYesAlways "semantic"
subjectstringYesThe entity the fact is about
predicatestringYesThe relationship or property
objectanyYesThe value (string, number, boolean, object, or array)
validityobjectYesWhen this fact is valid
evidencearrayNoProvenance references supporting this fact
revision_policystringNoreplace, fork, or contest
revisionobjectNoRevision state: supersedes, superseded_by, status

Competence Memory

Type value: competence

Competence memory encodes procedural knowledge -- how to achieve goals reliably under specific conditions. It represents "knowing how" rather than "knowing that."

Payload Structure

json
{
  "kind": "competence",
  "skill_name": "fix-npm-peer-dependency",
  "triggers": [
    {
      "signal": "npm ERR! ERESOLVE",
      "conditions": { "package_manager": "npm" }
    }
  ],
  "recipe": [
    {
      "step": "Run npm with legacy peer deps flag",
      "tool": "shell",
      "args_schema": { "command": "string" },
      "validation": "Exit code 0 and no ERESOLVE errors in output"
    },
    {
      "step": "Verify lock file was updated",
      "tool": "file_read",
      "validation": "package-lock.json modified timestamp changed"
    }
  ],
  "required_tools": ["shell", "file_read"],
  "failure_modes": ["Flag not supported in older npm versions"],
  "fallbacks": ["Delete node_modules and reinstall"],
  "performance": {
    "success_count": 12,
    "failure_count": 2,
    "success_rate": 0.857,
    "avg_latency_ms": 4500
  },
  "version": "1.2"
}

Fields

FieldTypeRequiredDescription
kindstringYesAlways "competence"
skill_namestringYesName of the skill or procedure
triggersarrayYesConditions that activate this competence
recipearrayYesOrdered steps to execute
required_toolsarrayNoTools needed for execution
failure_modesarrayNoKnown failure cases
fallbacksarrayNoAlternative strategies
performanceobjectNoSuccess/failure statistics
versionstringNoVersion identifier

Plan Graph Memory

Type value: plan_graph

Plan graph memory stores reusable solution structures as directed graphs of actions. Plans are versioned, selectable by constraint matching, and track execution metrics.

Payload Structure

json
{
  "kind": "plan_graph",
  "plan_id": "plan-setup-go-project",
  "version": "2.0",
  "intent": "setup_go_project",
  "constraints": {
    "min_go_version": "1.21"
  },
  "nodes": [
    {
      "id": "n1",
      "op": "shell",
      "params": { "command": "go mod init {{module}}" }
    },
    {
      "id": "n2",
      "op": "file_write",
      "params": { "path": "main.go", "template": "hello_world" }
    },
    {
      "id": "n3",
      "op": "shell",
      "params": { "command": "go build ./..." },
      "guards": { "files_exist": ["go.mod", "main.go"] }
    }
  ],
  "edges": [
    { "from": "n1", "to": "n2", "kind": "control" },
    { "from": "n2", "to": "n3", "kind": "control" },
    { "from": "n1", "to": "n3", "kind": "data" }
  ],
  "metrics": {
    "avg_latency_ms": 2300,
    "failure_rate": 0.05,
    "execution_count": 40
  }
}

Fields

FieldTypeRequiredDescription
kindstringYesAlways "plan_graph"
plan_idstringYesUnique plan identifier
versionstringYesVersion identifier
intentstringNoHigh-level intent label for matching
constraintsobjectNoTrust requirements, tool requirements, etc.
inputs_schemaobjectNoExpected input parameters
outputs_schemaobjectNoExpected output format
nodesarrayYesAction nodes with id, op, params, and optional guards
edgesarrayYesDependency edges (data or control) connecting nodes
metricsobjectNoExecution statistics