LearnNewsExamplesServices
Frontmatter
id7806
titleFix add_memory failure when sessionId is omitted
stateClosed
labels
bugai
assigneestobiu
createdAtNov 19, 2025, 12:54 PM
updatedAtNov 19, 2025, 1:33 PM
githubUrlhttps://github.com/neomjs/neo/issues/7806
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtNov 19, 2025, 1:33 PM

Fix add_memory failure when sessionId is omitted

Closed v11.6.0 bugai
tobiu
tobiu commented on Nov 19, 2025, 12:54 PM

The add_memory tool fails with a 422 Unprocessable Entity error when the sessionId parameter is omitted. This violates the documented behavior (and typical MCP expectations) where a missing sessionId should either be auto-generated or handled gracefully.

Steps to Reproduce:

  1. Ensure the Memory Core MCP server is running.
  2. Call add_memory with valid prompt, thought, and response, but omit the sessionId.
  3. Observe the tool error: Error executing add_memory: 422: Unprocessable Entity.

Root Cause Analysis: The MemoryService.addMemory method likely attempts to insert undefined or null as the sessionId into the ChromaDB metadata. ChromaDB (or the validation layer) requires metadata values to be strings, numbers, or booleans, and strictly rejects undefined/null.

Proposed Fix: Modify ai/mcp/server/memory-core/services/SessionService.mjs to manage a currentSessionId (UUID generated at startup). Update MemoryService to use this ID as a default when sessionId is missing. Expose this ID via HealthService for visibility.

Implemented Solution:

  1. SessionService.mjs: Added currentSessionId (UUID) initialized at startup.
  2. MemoryService.mjs: Updated addMemory to default to SessionService.currentSessionId if no sessionId is provided.
  3. HealthService.mjs: Updated healthcheck to include the session.currentId in its response payload.
  4. openapi.yaml: Updated documentation to reflect the optional sessionId parameter and the new session field in the healthcheck response.

Verification: Verified that healthcheck returns the current session ID and that add_memory succeeds without a sessionId parameter, correctly using the default ID.

tobiu added the bug label on Nov 19, 2025, 12:54 PM
tobiu added the ai label on Nov 19, 2025, 12:54 PM
tobiu assigned to @tobiu on Nov 19, 2025, 1:33 PM
tobiu referenced in commit a8e2066 - "Fix add_memory failure when sessionId is omitted #7806" on Nov 19, 2025, 1:33 PM
tobiu closed this issue on Nov 19, 2025, 1:33 PM