textrawl
byJeff Green

query_memory

Query the memory graph by search, entity lookup, or listing

Query stored memories using three modes: semantic search, entity context lookup, or paginated listing.

Parameters

ParameterTypeRequiredDefaultDescription
modeenumYes-Query mode: search, entity, or list
querystringmode=search-Search query (1-1000 chars)
entityTypesenum[]NoallFilter by entity types
searchModeenumNohybridSearch mode: hybrid or semantic (mode=search only)
entityNamestringmode=entity-Entity name to look up (1-200 chars)
includeRelatedbooleanNotrueInclude relations (mode=entity only)
maxObsnumberNo20Max observations per entity (mode=entity only)
limitnumberNo10Max results (1-50 for search, 1-100 for list)
offsetnumberNo0Pagination offset (mode=list only)

Semantic search across stored memories. Replaces the former recall_memories tool.

Example

{
  "mode": "search",
  "query": "user preferences for development tools",
  "entityTypes": ["person", "preference"],
  "limit": 10,
  "searchMode": "hybrid"
}

Search Modes

ModeDescription
hybridCombines keyword matching with semantic similarity (recommended)
semanticPure semantic similarity search

Response (Compact)

{"n":3,"e":[{"n":"Jeff","t":"person","m":[{"c":"prefers TypeScript over JavaScript","s":0.92},{"c":"uses VS Code as primary editor","s":0.85}]},{"n":"Development Setup","t":"preference","m":[{"c":"dark mode enabled by default","s":0.78}]}]}

Key mapping: n=count/name, e=entities, t=type, m=memories, c=content, s=score

Response (Verbose)

{
  "query": "user preferences for development tools",
  "totalMemories": 3,
  "entities": [
    {
      "entityName": "Jeff",
      "entityType": "person",
      "memories": [
        { "content": "prefers TypeScript over JavaScript", "source": "conversation", "score": 0.92 },
        { "content": "uses VS Code as primary editor", "source": "conversation", "score": 0.85 }
      ]
    }
  ]
}

Score Interpretation

Score RangeMeaning
0.9 - 1.0Highly relevant match
0.7 - 0.9Good match
0.5 - 0.7Moderate relevance
< 0.5Weak match

Mode: entity

Get all information about a specific entity including observations and relations. Replaces the former get_entity_context tool.

Example

{
  "mode": "entity",
  "entityName": "Jeff",
  "includeRelated": true
}

Response (Compact)

{"t":"person","o":["prefers dark mode in IDEs","uses TypeScript for most projects"],"r":{"out":["works_at→Acme Corp"],"in":["Sarah→manages"]},"more":5}

Key mapping: t=type, o=observations (content strings), r=relations (string format), more=remaining observations beyond maxObs

Response (Verbose)

{
  "found": true,
  "entity": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Jeff",
    "type": "person"
  },
  "observations": [
    { "id": "...", "content": "prefers dark mode in IDEs", "source": "conversation", "confidence": 1.0 },
    { "id": "...", "content": "uses TypeScript for most projects", "source": "conversation", "confidence": 1.0 }
  ],
  "relations": {
    "outgoing": [{ "relation_type": "works_at", "to_entity": "Acme Corp", "to_entity_type": "organization" }],
    "incoming": [{ "relation_type": "manages", "from_entity": "Sarah", "from_entity_type": "person" }]
  }
}

Entity Not Found

{"found":false}

Mode: list

List all entities with optional type filtering and pagination. Replaces the former list_entities tool.

Example

{
  "mode": "list",
  "entityTypes": ["person", "organization"],
  "limit": 20,
  "offset": 0
}

Response (Compact)

{"n":45,"e":[{"n":"Jeff","t":"person"},{"n":"Acme Corp","t":"organization"}]}

Response (Verbose)

{
  "total": 45,
  "returned": 20,
  "offset": 0,
  "entities": [
    { "id": "550e8400-...", "name": "Jeff", "type": "person", "updatedAt": "2026-01-05T10:00:00Z" },
    { "id": "550e8401-...", "name": "Acme Corp", "type": "organization", "updatedAt": "2026-01-04T15:30:00Z" }
  ]
}

Output Schema

This tool MUST return structuredContent alongside the text response. The structuredContent object MUST use canonical verbose keys regardless of the COMPACT_RESPONSES setting. Fields vary by mode:

Search Mode

FieldTypeDescription
mode"search"Query mode
totalMemoriesintegerNumber of matching memories
entitiesarrayResults grouped by entity
entities[].entityNamestringEntity name
entities[].entityTypestringEntity type
entities[].memoriesarrayMatching memories
entities[].memories[].contentstringMemory content
entities[].memories[].sourcestringMemory source
entities[].memories[].scorenumberRelevance score

Entity Mode

FieldTypeDescription
mode"entity"Query mode
foundbooleanWhether the entity was found
entityobjectEntity details
entity.idstringEntity UUID
entity.namestringEntity name
entity.typestringEntity type
entity.descriptionstring?Entity description
observationsarrayEntity observations
relationsobjectEntity relations (outgoing, incoming)
hasMorebooleanWhether more observations exist
totalObservationsintegerTotal observation count

List Mode

FieldTypeDescription
mode"list"Query mode
totalintegerTotal entity count
returnedintegerEntities in this page
offsetintegerCurrent offset
entityListarrayArray of entities
entityList[].idstringEntity UUID
entityList[].namestringEntity name
entityList[].typestringEntity type
entityList[].descriptionstring?Entity description
entityList[].updatedAtstringISO update timestamp

Entity Types

Valid types: person, concept, project, preference, fact, location, organization

Errors

ErrorCauseFix
Memory not enabledENABLE_MEMORY feature flag is falseSet ENABLE_MEMORY=true
Missing querymode=search without queryProvide query parameter
Missing entityNamemode=entity without entityNameProvide entityName parameter
Embedding service not configuredMissing API keySet OPENAI_API_KEY or configure Ollama
Invalid entity typeUnknown entity type in filterUse valid types listed above
  • remember_fact - Store new facts about entities
  • build_knowledge - Store multiple facts and relations in a batch
  • relate_entities - Create relationships between entities
  • forget_entity - Delete an entity and all its memories