Skip to content

Memory Management

Memory management is the most feature-rich module in WebUI, providing complete management capabilities for MaiBot's long-term memory system. The memory API routes (/api/webui/memory/*) are the largest code volume module among all routes, covering complete functions including graph operations, source management, memory fragments, character profiles, V5 memory actions, import, retrieval tuning, deletion and recovery.

Knowledge Graph Management

MaiBot's long-term memory is stored in the form of a knowledge graph, consisting of nodes (Node) and edges (Edge).

Graph Reading

EndpointDescription
GET /memory/graphGet graph data (can limit quantity, default 200, maximum 5000)
GET /memory/graph/searchSearch graph (keywords + quantity limit)
GET /memory/graph/node-detailGet node detailed information (including relationships, paragraphs, evidence nodes)
GET /memory/graph/edge-detailGet edge detailed information (including paragraphs, evidence nodes)

The node detail interface supports controlling the amount of returned data through relation_limit, paragraph_limit, evidence_node_limit parameters.

Node Operations

EndpointDescription
POST /memory/graph/nodeCreate node (need to provide name)
DELETE /memory/graph/nodeDelete node (need to provide name)
POST /memory/graph/node/renameRename node (need to provide old_name and new_name)

Edge Operations

EndpointDescription
POST /memory/graph/edgeCreate edge (need to provide subject, predicate, object, optional confidence)
DELETE /memory/graph/edgeDelete edge (can locate through hash or subject+object)
POST /memory/graph/edge/weightModify edge weight (need to provide weight)

Source Management

Sources record the origin information of memory data, used for traceability and batch management.

EndpointDescription
GET /memory/sourcesList all sources
POST /memory/sources/deleteDelete specified source
POST /memory/sources/batch-deleteBatch delete multiple sources

Memory Query

EndpointDescription
GET /memory/query/aggregateAggregate query memory

Aggregate query supports the following optional filter conditions:

  • query: Search keywords
  • limit: Return quantity limit (1-200)
  • chat_id: Filter by chat ID
  • person_id: Filter by person ID
  • time_start / time_end: Filter by time range (Unix timestamp)

Memory Fragment (Episode) Management

Memory fragments are processed memory units containing structured information extracted from original conversations.

EndpointDescription
GET /memory/episodesList memory fragments (supports search, source, person, time filtering)
GET /memory/episodes/{episode_id}Get single memory fragment details
POST /memory/episodes/rebuildRebuild memory fragments (by source or all)
GET /memory/episodes/statusGet memory fragment processing status
POST /memory/episodes/process-pendingProcess pending memory fragments

The process-pending interface supports limit (1-200) and max_retry (1-20) parameters to control batch processing scale and retry upper limit.

Character Profile Management

Character profiles store MaiBot's understanding and cognition of each user.

EndpointDescription
GET /memory/profiles/queryQuery character profiles (supports search by person_id or keywords)
GET /memory/profilesList all character profiles
POST /memory/profiles/overrideSet character profile override text
DELETE /memory/profiles/override/{person_id}Delete character profile override

The profile override function allows manual modification of a user's profile description, and the override text will take precedence over automatically generated profiles.

Feedback Correction Management

EndpointDescription
GET /memory/feedback-correctionsList feedback correction records (supports status and rollback status filtering)
GET /memory/feedback-corrections/{task_id}Get single correction details
POST /memory/feedback-corrections/{task_id}/rollbackRoll back a correction operation

V5 Memory Actions

The V5 memory system provides more refined memory manipulation capabilities:

EndpointDescription
GET /memory/v5/statusGet V5 memory status
GET /memory/v5/recycle-binGet V5 recycle bin content
POST /memory/v5/reinforceReinforce memory (increase memory strength)
POST /memory/v5/weakenWeaken memory (decrease memory strength)
POST /memory/v5/remember-foreverPermanent memory (mark as never forget)
POST /memory/v5/forgetForget memory (move to recycle bin)
POST /memory/v5/restoreRestore memory (restore from recycle bin)

All V5 actions support target (target identifier), strength (optional strength coefficient), reason (operation reason) parameters.

Deletion Management

Deletion operations adopt a preview-execute-restore safety mode:

EndpointDescription
POST /memory/delete/previewPreview deletion impact (no actual deletion)
POST /memory/delete/executeExecute deletion
POST /memory/delete/restoreRestore deleted content
GET /memory/delete/operationsList deletion operation history
GET /memory/delete/operations/{operation_id}Get single deletion operation details
POST /memory/delete/purgeCompletely clear deleted data (supports grace period)

The purge interface's grace_hours parameter can be used to retain recently deleted data within a certain number of hours, and the limit parameter controls the amount cleared in a single operation (1-5000).

Memory Import

Memory import functionality supports importing external data into long-term memory in multiple ways:

EndpointDescription
GET /memory/import/settingsGet import settings
GET /memory/import/path-aliasesGet path aliases
GET /memory/import/guideGet import guide
POST /memory/import/resolve-pathResolve path (supports aliases)
POST /memory/import/uploadUpload file import
POST /memory/import/pastePaste text import
POST /memory/import/raw-scanScan whitelist directory raw text
POST /memory/import/lpmm-openieLPMM OpenIE import
POST /memory/import/lpmm-convertLPMM format conversion import
POST /memory/import/temporal-backfillTime information backfill
POST /memory/import/maibot-migrationMigrate from MaiBot host database

Import Task Management

EndpointDescription
GET /memory/import/tasksList import tasks
GET /memory/import/tasks/{task_id}Get task details
GET /memory/import/tasks/{task_id}/chunks/{file_id}Get task chunks
POST /memory/import/tasks/{task_id}/cancelCancel import task
POST /memory/import/tasks/{task_id}/retryRetry failed import tasks

When uploading files for import, files are first temporarily stored in subdirectories under the data/memory_upload_staging/ directory and automatically cleaned up after import completion.

Retrieval Tuning

Retrieval tuning functionality is used to optimize memory retrieval effects:

EndpointDescription
GET /memory/retrieval_tuning/settingsGet tuning settings
GET /memory/retrieval_tuning/profileGet current tuning configuration
POST /memory/retrieval_tuning/profile/applyApply tuning configuration
POST /memory/retrieval_tuning/profile/rollbackRoll back tuning configuration
GET /memory/retrieval_tuning/profile/exportExport tuning configuration
POST /memory/retrieval_tuning/tasksCreate tuning tasks
GET /memory/retrieval_tuning/tasksList tuning tasks
GET /memory/retrieval_tuning/tasks/{task_id}Get task details
GET /memory/retrieval_tuning/tasks/{task_id}/roundsGet tuning rounds
POST /memory/retrieval_tuning/tasks/{task_id}/cancelCancel tuning task
POST /memory/retrieval_tuning/tasks/{task_id}/apply-bestApply best tuning results
GET /memory/retrieval_tuning/tasks/{task_id}/reportGet tuning report

Runtime and Maintenance

EndpointDescription
POST /memory/runtime/saveManually save memory data
GET /memory/config/schemaGet memory configuration schema
GET /memory/configGet memory configuration
PUT /memory/configUpdate memory configuration (structured)
GET /memory/config/rawGet raw TOML memory configuration
PUT /memory/config/rawUpdate raw TOML memory configuration
GET /memory/runtime/configGet runtime configuration
GET /memory/runtime/self-checkRun self-check
POST /memory/runtime/self-check/refreshRefresh and run self-check
GET /memory/runtime/auto-saveGet auto-save status
POST /memory/runtime/auto-saveSet auto-save switch

Maintenance Operations

EndpointDescription
GET /memory/maintenance/recycle-binGet recycle bin content
POST /memory/maintenance/restoreRestore memory from recycle bin
POST /memory/maintenance/reinforceReinforce memory relationships
POST /memory/maintenance/freezeFreeze memory (prevent automatic forgetting)
POST /memory/maintenance/protectProtect memory (specify protection duration)

Compatible Routes

For backward compatibility, some old interfaces are also mounted under the /api/webui/api/* path (compat_router), including graph operations, source management, and memory queries. New development should prioritize using the /memory/* path.